码迷,mamicode.com
首页 > 编程语言 > 详细

9th 学习博客:使用Codebloks实现C++的图形化界面

时间:2016-11-17 07:54:03      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:llb   comm   code   man   ati   click   printf   c++   ima   

main.cpp

 1 #include <windows.h>
 2 #include <commctrl.h>
 3 #include <stdio.h>
 4 #include "resource.h"
 5 
 6 HINSTANCE hInst;
 7 HWND button1;
 8 
 9 BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
10 {
11     switch(uMsg)
12     {
13     case WM_INITDIALOG:
14     {
15 
16     }
17     return TRUE;
18 
19     case WM_CLOSE:
20     {
21         if(MessageBox(hwndDlg,"Close the dialog?","Prompt",MB_YESNO) == IDYES)
22         {
23             EndDialog(hwndDlg, 0);
24         }
25     }
26     return TRUE;
27 
28     case WM_COMMAND:
29     {
30         switch(LOWORD(wParam))
31         {
32         case IDC_BUTTON1:
33             printf("the button1 is clicked!\n");
34             SetWindowText(button1,TEXT("my button"));
35             break;
36         }
37     }
38     return TRUE;
39     }
40     return FALSE;
41 }
42 
43 
44 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
45 {
46     hInst=hInstance;
47     InitCommonControls();
48     return DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DlgMain);
49 }

resource.h

1 #ifndef IDC_STATIC
2 #define IDC_STATIC (-1)
3 #endif
4 
5 #define DLG_MAIN                                100
6 #define IDC_BUTTON1                             40000

执行效果图

技术分享

 

9th 学习博客:使用Codebloks实现C++的图形化界面

标签:llb   comm   code   man   ati   click   printf   c++   ima   

原文地址:http://www.cnblogs.com/landscape/p/6072246.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!