PostQuitMessage,函式名。該函式向系統表明有個執行緒有終止請求。通常用來回響WM_DESTROY訊息。
基本介紹
- 外文名:PostQuitMessage
- 函式原型:VOID PostQuitMessage
- nExitCode:指定應用程式退出代碼
函式原型,備註,示例,
函式原型
void PostQuitMessage(int nExitCode)參數:nExitCode:指定應用程式退出代碼。此值被用作訊息WM_QUIT的wParam參數。返回值:無。
備註
PostQuitMessage寄送一個WM_QUIT訊息給執行緒的訊息佇列並立即返回;此函式向系統表明有個執行緒請求在隨後的某一時間終止。
速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:1.0及以上版本;頭檔案:winuser.h;輸入庫:user32.lib:Uhicode:在Wihdows NT環境下以Unicode和ANSI方式實現。
示例
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ static int cxChar, cxCaps, cyChar; TCHAR szBuffer[10]; HDC hdc; int i; PAINTSTRUCT ps; TEXTMETRIC tm; switch (message) { case WM_CREATE: hdc = GetDC(hwnd); GetTextMetrics(hdc, &tm); cxChar = tm.tmAveCharWidth; cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2; cyChar = tm.tmHeight + tm.tmExternalLeading; ReleaseDC(hwnd, hdc); return 0; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); for(i = 0; i < NUMLINES; i++) { ExtTextOut(hdc, 0, cyChar * i, 0, NULL, devcaps[i].szDesc, lstrlen(devcaps[i].szDesc), NULL); SetTextAlign(hdc, TA_RIGHT | TA_TOP); ExtTextOut(hdc, cxChar * 47, cyChar * i, 0, NULL,szBuffer, wsprintf(szBuffer, TEXT("%5d"), GetDeviceCaps(hdc, devcaps[i].iIndex)), NULL); SetTextAlign (hdc, TA_LEFT | TA_TOP) ; } EndPaint(hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0 ; } return DefWindowProc(hwnd, message, wParam, lParam);}