资源描述:
《MINIGUI-主窗口和控件的理解.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、MINIGUI中大体分为主窗口、控件(即子窗口),而其他的一些都属于这两类,如对话框属于主窗口,按键等属于控件对于主窗口、控件的理解,根据以下程序和效果图,更容易明白。/***********************************************************************************利用预定义控件类创建控件**********************************************************************************
2、/#include#include#include#include#include#include#include/*CreateWindow(class_name,caption,style,id,x,y,w,h,parent,add_data)*/#defineIDC_STATIC1100#define
3、IDC_STATIC2150#defineIDC_BUTTON1110#defineIDC_BUTTON2120#defineIDC_EDIT1130#defineIDC_EDIT2140staticintCreateWindow_s(HWNDhWnd){HWNDhStaticWnd1,hStaticWnd2,hButton1,hButton2,hEdit1,hEdit2;//创建一个静态框hStaticWnd1=CreateWindow(CTRL_STATIC,"Thisisastaticcontrol",WS_CH
4、ILD
5、SS_NOTIFY
6、SS_SIMPLE
7、WS_VISIBLE
8、WS_BORDER,IDC_STATIC1,10,10,180,300,hWnd,0);//在hStaticWnd1中创建两个按钮控件hButton1=CreateWindow(CTRL_BUTTON,"Button1",WS_CHILD
9、BS_PUSHBUTTON
10、WS_VISIBLE,IDC_BUTTON1,20,20,80,20,hStaticWnd1,0);hButton2=CreateWindow(CTRL_BUTTON,"Button2"
11、,WS_CHILD
12、BS_PUSHBUTTON
13、WS_VISIBLE,IDC_BUTTON2,20,50,80,20,hStaticWnd1,0);//在hStaticWnd1中创建一个编辑框控件hEdit1=CreateWindow(CTRL_EDIT,"Editbox1",WS_CHILD
14、WS_VISIBLE
15、WS_BORDER,IDC_EDIT1,20,80,100,24,hStaticWnd1,0);//在hStaticWnd1中创建一个静态框hStaticWnd2hStaticWnd2=CreateWind
16、ow(CTRL_STATIC,"Thisischildstaticcontrol",WS_CHILD
17、SS_NOTIFY
18、SS_SIMPLE
19、WS_VISIBLE
20、WS_BORDER,IDC_STATIC2,20,110,150,50,hStaticWnd1,0);//在hStaticWnd2中创建一个编辑框控件hEdit2,这时,hEdit2是hStaticWnd1的孙窗口hEdit2=CreateWindow(CTRL_EDIT,"EditBox2",WS_CHILD
21、WS_VISIBLE
22、WS_BORDER,ID
23、C_EDIT2,0,20,100,24,hStaticWnd2,0);return0;}/*staticvoidUnregisterMyControl(void){UnregisterWindowClass(MY_CTRL_NAME);}*/staticintHelloWinProc(HWNDhWnd,intmessage,WPARAMwParam,LPARAMlParam){switch(message){caseMSG_CREATE:CreateWindow_s(hWnd);return0;caseMSG_DEST
24、ROY:DestroyAllControls(hWnd);return0;caseMSG_CLOSE:DestroyMainWindow(hWnd);PostQuitMessage(hWnd);return0;}returnDefaultMainWinProc(hWnd,message,wParam,lParam);}intMin