Creating Dialogbased Win32 Application (1) / 建立基於對話方塊的Win32應用程式(一)建立表單 / Win32, VC++, Windows

來源:互聯網
上載者:User

標籤:

建立基於對話方塊的Win32應用程式(一) —— 建立表單

 

1、建立一個Visual C++的Empty Project。 

2、在Solution Explorer中右鍵Add New Item,添加 .cpp 檔案,並提供Win32應用程式的進入點函數。 

3、在Solution Explorer或 Resources View 中右鍵Add Resource,選擇Dialog。並在修改相關內容。

4、切換到 .cpp檔案中,建立回呼函數(Dlg_Proc),並在進入點函數中調用DialogBoxParam。 

 1 #include <Windows.h> 2 #include <tchar.h> 3 #include "Resource.h" 4  5 INT_PTR WINAPI Dlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { 6     switch (uMsg) 7     { 8     case WM_CLOSE: 9         EndDialog(hwnd, 0);10         break;11     }12 13     return(FALSE);14 }15 16 int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) {17     DialogBoxParam(hinstExe, MAKEINTRESOURCE(IDD_DIALOG),18         NULL, Dlg_Proc, _ttoi(pszCmdLine));19     return(0);20 }
Win32WindowsApplication.cpp

5、此時按下F5 Start Debugging,可以看到剛才建立的對話方塊。

————————————————

本文為本人原創,轉載請註明出處。

Creating Dialogbased Win32 Application (1) / 建立基於對話方塊的Win32應用程式(一)建立表單 / Win32, VC++, Windows

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.