<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # UI 的第一步 > 原文: [http://zetcode.com/gui/winapi/firststeps/](http://zetcode.com/gui/winapi/firststeps/) 在 Windows API 教程的這一部分中,我們將創建一些簡單的 UI 示例。 ## 簡單的程序 這是一個非常簡單的程序。 它將彈出一個小對話框。 `simple.c` ```c #include <windows.h> int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int CmdShow) { MessageBoxW(NULL, L"First Program", L"First", MB_OK); return 0; } ``` 屏幕上會顯示一個小對話框。 它具有標題,消息和“確定”按鈕。 ```c #include <windows.h> ``` 我們包括基本的函數聲明,常量,數據類型和結構。 ```c int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int CmdShow) ``` `wWinMain()`函數是我們應用的入口。 ```c MessageBoxW(NULL, L"First Program", L"First", MB_OK); ``` `MessageBoxW()`函數顯示一個簡單的消息框。 第一個參數是所有者窗口。 在我們的情況下,該對話框沒有所有者。 接下來的兩個參數提供消息文本和標題。 最后一個參數定義消息對話框的類型。 `MB_OK`值使對話框具有一個“確定”按鈕。 ![Simple message box](https://img.kancloud.cn/26/78/26786ce38c1ead8422c9cd6d16f95ca1_123x126.jpg) 圖:簡單 message box ## 使窗口居中 在下一個代碼示例中,我們將窗口置于屏幕中央。 `SetWindowPos()`函數更改子項,彈出窗口或頂級窗口的大小,位置和 Z 順序。 ```c BOOL WINAPI SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags); ``` 第一個參數是窗口的句柄。 第二個參數是窗口的句柄,該窗口的句柄以 Z 順序或特殊標志位于定位的窗口之前。 例如,`HWND_BOTTOM`標志將窗口置于 Z 順序的底部,`HWND_TOP`標志置于 Z 順序的頂部。 `x`和`y`參數是客戶端坐標中窗口左側和頂部的新位置。 `cx`和`cy`是窗口的新寬度和高度大小,以像素為單位。 最后一個參數是大小和位置標志的組合。 例如`SWP_NOMOVE`保留當前位置(忽略`x`和`y`參數)或`SWP_NOSIZE`保留當前大小(忽略`cx`和`cy`參數)。 `centering.c` ```c #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void CenterWindow(HWND); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { MSG msg; WNDCLASSW wc = {0}; wc.lpszClassName = L"Center"; wc.hInstance = hInstance; wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&wc); CreateWindowW(wc.lpszClassName, L"Center", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 250, 150, 0, 0, hInstance, 0); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: CenterWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } void CenterWindow(HWND hwnd) { RECT rc = {0}; GetWindowRect(hwnd, &rc); int win_w = rc.right - rc.left; int win_h = rc.bottom - rc.top; int screen_w = GetSystemMetrics(SM_CXSCREEN); int screen_h = GetSystemMetrics(SM_CYSCREEN); SetWindowPos(hwnd, HWND_TOP, (screen_w - win_w)/2, (screen_h - win_h)/2, 0, 0, SWP_NOSIZE); } ``` 為了使窗口在屏幕上居中,我們需要確定窗口和屏幕的大小。 ```c case WM_CREATE: CenterWindow(hwnd); break; ``` 我們在`WM_CREATE`消息期間調用用戶定義的`CenterWindow()`函數。 ```c GetWindowRect(hwnd, &rc) ; ``` 使用`GetWindowRect()`函數,我們檢索指定窗口的邊界矩形的大小。 ```c int win_w = rc.right - rc.left; int win_h = rc.bottom - rc.top; ``` 計算窗口的寬度和高度。 ```c int screen_w = GetSystemMetrics(SM_CXSCREEN) int screen_h = GetSystemMetrics(SM_CYSCREEN); ``` 通過`GetSystemMetrics()`函數,我們可以確定屏幕的寬度和高度。 ```c SetWindowPos(hwnd, HWND_TOP, (screen_w - win_w)/2, (screen_h - win_h)/2, 0, 0, SWP_NOSIZE); ``` 我們使用`SetWindowPos()`函數將應用窗口放置在屏幕中央。 ## 熱鍵 在以下示例中,我們顯示了如何注冊熱鍵。 熱鍵是用于執行特定操作的組合鍵。 熱鍵已通過`RegisterHotKey()`函數注冊。 ```c BOOL WINAPI RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk); ``` 第一個參數是窗口的句柄,該窗口將接收由熱鍵生成的`WM_HOTKEY`消息。 第二個參數是熱鍵的 ID。 第三個參數由修飾符組成; 必須將這些鍵與`vk`參數指定的鍵組合在一起才能生成`WM_HOTKEY`消息。 改性劑的實例包括`MOD_ALT`或`MOD_CONTROL`。 最后一個參數是熱鍵的虛擬鍵代碼。 `hotkey.c` ```c #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void CenterWindow(HWND); #define ID_HOTKEY 1 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASSW wc = {0}; wc.lpszClassName = L"Application"; wc.hInstance = hInstance; wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&wc); hwnd = CreateWindowW(wc.lpszClassName, L"Hot key", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 270, 170, 0, 0, 0, 0); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: RegisterHotKey(hwnd, ID_HOTKEY, MOD_CONTROL, 0x43); break; case WM_HOTKEY: if ((wParam) == ID_HOTKEY) { CenterWindow(hwnd); } break; case WM_DESTROY: UnregisterHotKey(hwnd, ID_HOTKEY); PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } void CenterWindow(HWND hwnd) { RECT rc = {0}; GetWindowRect(hwnd, &rc); int win_w = rc.right - rc.left; int win_h = rc.bottom - rc.top; int screen_w = GetSystemMetrics(SM_CXSCREEN); int screen_h = GetSystemMetrics(SM_CYSCREEN); SetWindowPos(hwnd, HWND_TOP, (screen_w - win_w)/2, (screen_h - win_h)/2, 0, 0, SWP_NOSIZE); } ``` 在示例中,我們注冊了 `Ctrl + C` 熱鍵。 它將窗口居中在屏幕上。 ```c case WM_CREATE: RegisterHotKey(hwnd, ID_HOTKEY, MOD_CONTROL, 0x43); break; ``` 在創建窗口的過程中,我們使用`RegisterHotKey()`函數注冊了 `Ctrl + C` 熱鍵。 ```c case WM_HOTKEY: if ((wParam) == ID_HOTKEY) { CenterWindow(hwnd); } break; ``` 調用熱鍵時會生成`WM_HOTKEY`消息。 我們通過檢查`wParam`參數來識別我們的熱鍵,然后調用`CenterWindow()`函數。 ```c case WM_DESTROY: UnregisterHotKey(hwnd, ID_HOTKEY); PostQuitMessage(0); break; ``` 當窗口被破壞時,我們使用`UnregisterHotKey()`函數取消注冊熱鍵。 MSDN 尚不清楚是否必須調用此函數。 ## 更多窗口 從特定的窗口類創建一個窗口。 窗口類定義了幾個窗口共有的一組行為。 一些類已經在系統中預定義。 自定義窗口類必須注冊。 之后,我們可以創建此新窗口類的窗口。 使用`CreateWindowW()`函數創建一個窗口。 它的第一個參數是窗口類名稱。 每個窗口都有一個窗口過程。 當用戶與窗口交互時,此函數由 OS 調用。 在下面的示例中,我們創建三個窗口:一個父窗口和兩個子窗口。 `morewindows.c` ```c #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK PanelProc(HWND, UINT, WPARAM, LPARAM); void RegisterRedPanelClass(void); void RegisterBluePanelClass(void); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) { MSG msg; WNDCLASSW wc = {0}; wc.lpszClassName = L"Windows"; wc.hInstance = hInstance; wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&wc); CreateWindowW(wc.lpszClassName, L"Windows", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 250, 180, 0, 0, hInstance, 0); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: RegisterRedPanelClass(); CreateWindowW(L"RedPanelClass", NULL, WS_CHILD | WS_VISIBLE, 20, 20, 80, 80, hwnd, (HMENU) 1, NULL, NULL); RegisterBluePanelClass(); CreateWindowW(L"BluePanelClass", NULL, WS_CHILD | WS_VISIBLE, 120, 20, 80, 80, hwnd, (HMENU) 2, NULL, NULL); break; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProcW(hwnd, msg, wParam, lParam); } LRESULT CALLBACK PanelProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_LBUTTONUP: MessageBeep(MB_OK); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } void RegisterRedPanelClass(void) { HBRUSH hbrush = CreateSolidBrush(RGB(255, 0, 0)); WNDCLASSW rwc = {0}; rwc.lpszClassName = L"RedPanelClass"; rwc.hbrBackground = hbrush; rwc.lpfnWndProc = PanelProc; rwc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&rwc); } void RegisterBluePanelClass(void) { HBRUSH hbrush = CreateSolidBrush(RGB(0, 0, 255)); WNDCLASSW rwc = {0}; rwc.lpszClassName = L"BluePanelClass"; rwc.hbrBackground = hbrush; rwc.lpfnWndProc = PanelProc; rwc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&rwc); } ``` 我們有一個帶有兩個子窗口的應用窗口。 兩個子窗口具有藍色和紅色背景。 ```c HBRUSH hbrush = CreateSolidBrush(RGB(255, 0, 0)); ... rwc.hbrBackground = hbrush; ``` 要創建彩色窗口背景,我們通過調用`CreateSolidBrush()`函數來創建自定義的實心畫筆。 要指定顏色,我們使用`RGB`宏。 眾所周知,可以通過組合紅色,綠色和藍色來創建任何顏色。 然后,將窗口類結構的`hbrBackground`參數設置為此新創建的畫筆。 ```c RegisterRedPanelClass(); CreateWindowW(L"RedPanelClass", NULL, WS_CHILD | WS_VISIBLE, 20, 20, 80, 80, hwnd, (HMENU) 1, NULL, NULL); ``` 首先,我們注冊一個新的窗口類。 完成此步驟后,我們將創建此類的窗口。 我們的兩個子窗口都共享`PanelProc`窗口過程。 當我們與 Windows OS 進行交互時,將調用此過程。 ```c case WM_LBUTTONUP: MessageBeep(MB_OK); break; ``` 單擊子窗口時,我們將與它們交互。 通過在子窗口上單擊鼠標左鍵,Windows 操作系統將調用子窗口過程并發送`WM_LBUTTONUP`消息。 在我們的示例中,我們調用`MessageBeep()`函數。 如果我們在兩個子窗口的背景上單擊鼠標左鍵,則會聽到 Windows 默認的蜂鳴聲。 ```c void RegisterBluePanelClass(void) { HBRUSH hbrush = CreateSolidBrush(RGB(0, 0, 255)); WNDCLASSW rwc = {0}; rwc.lpszClassName = L"BluePanelClass"; rwc.hbrBackground = hbrush; rwc.lpfnWndProc = PanelProc; rwc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&rwc); } ``` 該函數注冊一個新的窗口類。 此窗口類類型的窗口具有紅色背景。 編輯,按鈕和靜態控件是從預定義的窗口類創建的,這些窗口類已可用于所有進程。 因此,在這些情況下,我們不需要為其注冊窗口類。 ![More windows](https://img.kancloud.cn/c1/6b/c16b65acca9cd1c2fe64f7679bfde71d_250x180.jpg) 圖:更多窗口 ## 退出鍵 通常,通過按 `Escape` 鍵可以終止應用。 還顯示一個消息框以確認終止。 `escapekey.c` ```c #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int CmdShow) { MSG msg; WNDCLASSW wc = {0}; wc.lpszClassName = L"Escape"; wc.hInstance = hInstance; wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&wc); CreateWindowW(wc.lpszClassName, L"Escape", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 250, 180, 0, 0, hInstance, 0); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_KEYDOWN: if (wParam == VK_ESCAPE) { int ret = MessageBoxW(hwnd, L"Are you sure to quit?", L"Message", MB_OKCANCEL); if (ret == IDOK) { SendMessage(hwnd, WM_CLOSE, 0, 0); } } break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } ``` 詢問用戶是否確實要關閉應用是一種常見的做法。 如果我們有時鐘或計算器,那就沒關系了。 但是,如果我們有文本編輯器或繪圖應用,那確實很重要。 我們可能不小心按了 `Escape` 鍵并失去了所有修改。 ```c case WM_KEYDOWN: if (wParam == VK_ESCAPE) { int ret = MessageBoxW(hwnd, L"Are you sure to quit?", L"Message", MB_OKCANCEL); if (ret == IDOK) { SendMessage(hwnd, WM_CLOSE, 0, 0); } } break; ``` 如果我們按一個鍵,則窗口過程會收到`WM_KEYDOWN`消息。 `wParam`參數具有鍵碼。 我們可以通過發送`WM_CLOSE`消息來關閉窗口。 該消息通過`SendMessage()`函數發送。 ## 移動窗口 當我們在屏幕上移動窗口時,窗口過程會收到`WM_MOVE`消息。 在我們的示例中,我們在屏幕上顯示當前窗口的位置-我們顯示窗口左上角的坐標。 `moving.c` ```c #include <windows.h> #include <wchar.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void CreateLabels(HWND); HWND hwndSta1; HWND hwndSta2; int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int CmdShow) { HWND hwnd; MSG msg; WNDCLASSW wc = {0}; wc.lpszClassName = L"Moving"; wc.hInstance = hInstance ; wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&wc); hwnd = CreateWindowW(wc.lpszClassName, L"Moving", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 150, 150, 250, 180, 0, 0, hInstance, 0); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { wchar_t buf[10]; RECT rect; switch(msg) { case WM_CREATE: CreateLabels(hwnd); break; case WM_MOVE: GetWindowRect(hwnd, &rect); StringCbPrintfW(buf, BUF_LEN, L"%ld", rect.left); SetWindowTextW(hwndSta1, buf); StringCbPrintfW(buf, BUF_LEN, L"%ld", rect.top); SetWindowTextW(hwndSta2, buf); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } void CreateLabels(HWND hwnd) { CreateWindowW(L"static", L"x: ", WS_CHILD | WS_VISIBLE, 10, 10, 25, 25, hwnd, (HMENU) 1, NULL, NULL); hwndSta1 = CreateWindowW(L"static", L"150", WS_CHILD | WS_VISIBLE, 40, 10, 55, 25, hwnd, (HMENU) 2, NULL, NULL); CreateWindowW(L"static", L"y: ", WS_CHILD | WS_VISIBLE, 10, 30, 25, 25, hwnd, (HMENU) 3, NULL, NULL); hwndSta2 = CreateWindowW(L"static", L"150", WS_CHILD | WS_VISIBLE, 40, 30, 55, 25, hwnd, (HMENU) 4, NULL, NULL); } ``` 靜態文本控件的創建委托給`CreateLabels()`函數。 ```c void CreateLabels(HWND hwnd) { CreateWindowW(L"static", L"x: ", WS_CHILD | WS_VISIBLE, 10, 10, 25, 25, hwnd, (HMENU) 1, NULL, NULL); hwndSta1 = CreateWindowW(L"static", L"150", WS_CHILD | WS_VISIBLE, 40, 10, 55, 25, hwnd, (HMENU) 2, NULL, NULL); CreateWindowW(L"static", L"y: ", WS_CHILD | WS_VISIBLE, 10, 30, 25, 25, hwnd, (HMENU) 3, NULL, NULL); hwndSta2 = CreateWindowW(L"static", L"150", WS_CHILD | WS_VISIBLE, 40, 30, 55, 25, hwnd, (HMENU) 4, NULL, NULL); } ``` 有四個靜態文本控件。 在應用的生命周期中,其中兩個會更改。 因此,我們只需要兩個句柄。 ```c case WM_MOVE: GetWindowRect(hwnd, &rect); StringCbPrintfW(buf, BUF_LEN, L"%ld", rect.left); SetWindowTextW(hwndSta1, buf); StringCbPrintfW(buf, BUF_LEN, L"%ld", rect.top); SetWindowTextW(hwndSta2, buf); break; ``` 要獲取窗口坐標,我們調用`GetWindowRect()`函數。 由于坐標是數字,因此必須將其轉換為字符串。 為此,我們使用`StringCbPrintfW()`函數。 ![Moving a window](https://img.kancloud.cn/00/fa/00fae9d9d18311aff72acd1e4a1a2e5c_250x180.jpg) 圖:移動窗口 ## 閃爍窗口 有時,當發生重要事件時,標題欄或任務欄按鈕開始閃爍。 閃爍是標題欄從非活動狀態更改為活動狀態,反之亦然。 當我們收到新消息時,這是 Miranda IM 中的常見功能。 `flashing.c` ```c #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) { MSG msg; WNDCLASSW wc = {0}; wc.lpszClassName = L"Flash"; wc.hInstance = hInstance; wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(0,IDC_ARROW); RegisterClassW(&wc); CreateWindowW(wc.lpszClassName, L"Flash", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 250, 180, 0, 0, hInstance, 0); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { FLASHWINFO fwi; switch(msg) { case WM_CREATE: CreateWindowW(L"Button", L"Flash", WS_CHILD | WS_VISIBLE, 10, 10, 80, 25, hwnd, (HMENU) 1, NULL, NULL); break; case WM_COMMAND: fwi.cbSize = sizeof(fwi); fwi.dwFlags = FLASHW_ALL; fwi.dwTimeout = 0; fwi.hwnd = hwnd; fwi.uCount = 4; FlashWindowEx(&fwi); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } ``` 為了刷新窗口,我們必須執行兩個步驟:創建并填充`FLASHWINFO`結構并調用`FlashWindowEx()`函數。 ```c fwi.dwFlags = FLASHW_ALL; ``` 我們已經設置了`FLASHW_ALL`標志。 這將同時閃爍標題欄和任務欄按鈕。 要僅閃爍標題欄,我們可以使用`FLASHW_CAPTION`標簽。 要閃爍任務欄按鈕,我們可以使用`FLASHW_TRAY`標志。 ```c fwi.dwTimeout = 0; ``` `dwTimeout`成員是刷新窗口的速率,以毫秒為單位。 如果`dwTimeout`為零,則該功能使用默認的光標閃爍速率。 ```c fwi.hwnd = hwnd; fwi.uCount = 4; ``` 在這里,我們設置要閃爍的窗口以及要閃爍多少次。 在本例中,我們將主窗口閃爍四次。 ```c FlashWindowEx(&fwi); ``` `FlashWindowEx()`開始閃爍。 在 Windows API 教程的這一部分中,我們創建了一些簡單的 UI 示例。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看