Exemplo n.º 1
0
Arquivo: qa.c Projeto: mingpen/OpenNT
int IdleThread(DWORD dw)
{
     for (;;) 
     {
	if (AppIdle())
            Sleep(10);  //????
     }
     return 0;	
}
Exemplo n.º 2
0
/*--------------------------------------------
	メイン
---------------------------------------------*/
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int)
{
	// デバッグ ヒープ マネージャによるメモリ割り当ての追跡方法を設定
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	// XNA Mathライブラリのサポート チェック
    if (XMVerifyCPUSupport() != TRUE)
	{
		DXTRACE_MSG(L"WinMain XMVerifyCPUSupport");
		return 0;
	}

	// アプリケーションに関する初期化
	HRESULT hr = InitApp(hInst);
	if (FAILED(hr))
	{
		DXTRACE_ERR(L"WinMain InitApp", hr);
		return 0;
	}

	// Direct3Dの初期化
	hr = InitDirect3D();
	if (FAILED(hr)) {
		DXTRACE_ERR(L"WinMain InitDirect3D", hr);
		CleanupDirect3D();
		CleanupApp();
		return 0;
	}

	// メッセージ ループ
	MSG msg;
	do
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			// アイドル処理
			if (!AppIdle())
				// エラーがある場合,アプリケーションを終了する
				DestroyWindow(g_hWindow);
		}
	} while (msg.message != WM_QUIT);

	// アプリケーションの終了処理
	CleanupApp();

	return (int)msg.wParam;
}
Exemplo n.º 3
0
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow)
{
	MSG msg;

	// Perform application initialization:
	if (!InitInstance(hInstance, nCmdShow, lpCmdLine)) 
	{
		return FALSE;
	}

#ifndef WIN32_PLATFORM_WFSP
	HACCEL hAccelTable;
	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WCEVP));
#endif // !WIN32_PLATFORM_WFSP

	// Main message loop:
    for(;;) {
        if (g_bAppActive) {
            if (PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE )) {
                if (msg.message == WM_QUIT)
                    break;
                else 
#ifndef WIN32_PLATFORM_WFSP
                    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
#endif // !WIN32_PLATFORM_WFSP
                {
                    TranslateMessage(&msg);
                    DispatchMessage(&msg);
                }
            } 
            else
                AppIdle();
        }
        else {
            if (GetMessage(&msg, NULL, 0U, 0U)) {
#ifndef WIN32_PLATFORM_WFSP
                if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
#endif // !WIN32_PLATFORM_WFSP
                {
                    TranslateMessage(&msg);
                    DispatchMessage(&msg);
                }
            } 
            else
                break;
        }
    }
	return (int) msg.wParam;
}
Exemplo n.º 4
0
Arquivo: qa.c Projeto: mingpen/OpenNT
/*----------------------------------------------------------------------------*\
|   WinMain( hInst, hPrev, lpszCmdLine, cmdShow )                              |
|                                                                              |
|   Description:                                                               |
|       The main procedure for the App.  After initializing, it just goes      |
|       into a message-processing loop until it gets a WM_QUIT message         |
|       (meaning the app was closed).                                          |
|                                                                              |
|   Arguments:                                                                 |
|       hInst           instance handle of this instance of the app            |
|       hPrev           instance handle of previous instance, NULL if first    |
|       szCmdLine       ->null-terminated command line                         |
|       cmdShow         specifies how the window is initially displayed        |
|                                                                              |
|   Returns:                                                                   |
|       The exit code as specified in the WM_QUIT message.                     |
|                                                                              |
\*----------------------------------------------------------------------------*/
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
    MSG     msg;
    DWORD   dw=0;

    /* Call initialization procedure */
    if (!AppInit(hInst,hPrev,sw,szCmdLine))
        return FALSE;

#ifdef WIN32
    CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)IdleThread, 0, 0, &dw);
#endif

    /*
     * Polling messages from event queue
     */
    for (;;)
    {
        if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
                break;

	    if (hAccelApp && TranslateAccelerator(hwndApp, hAccelApp, &msg))
		continue;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
	{
	    if (dw!=0 || AppIdle())
                WaitMessage();
        }
    }

    AppExit();
    return msg.wParam;
}
Exemplo n.º 5
0
/*----------------------------------------------------------------------------*\
|   WinMain( hInst, hPrev, lpszCmdLine, cmdShow )                              |
|                                                                              |
|   Description:                                                               |
|       The main procedure for the App.  After initializing, it just goes      |
|       into a message-processing loop until it gets a WM_QUIT message         |
|       (meaning the app was closed).                                          |
|                                                                              |
|   Arguments:                                                                 |
|       hInst           instance handle of this instance of the app            |
|       hPrev           instance handle of previous instance, NULL if first    |
|       szCmdLine       ->null-terminated command line                         |
|       cmdShow         specifies how the window is initially displayed        |
|                                                                              |
|   Returns:                                                                   |
|       The exit code as specified in the WM_QUIT message.                     |
|                                                                              |
\*----------------------------------------------------------------------------*/
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
    MSG     msg;

    if (!WinG.Load()) {				//link to WinG DLL.
		   MessageBox(0,"Can't find WING32.DLL","WTWIN Error!",MB_OK);
		   return FALSE;
    }

    /* Call initialization procedure */
    if (!AppInit(hInst,hPrev,sw,szCmdLine))
			return FALSE;

    /*
     * Polling messages from event queue
     */
    for (;;)
    {
        if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
                break;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
		 {
	    if (AppIdle())
                WaitMessage();
        }
    }

    AppExit();
    WinG.Free();						//terminate WinG DLL link.
    return msg.wParam;
}