1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
//Main.cpp
#include <windows.h >
#define CHECK_BOX_C 1500
#define CHECK_BOX_C_PLUS_PLUS 1505
#define CHECK_BOX_PowerBASIC 1510
#define CHECK_BOX_Visual_Basic_6 1515
#define CHECK_BOX_Visual_Basic_NET 1520
LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HINSTANCE hIns;
HWND hCtl;
hIns=((LPCREATESTRUCT)lParam)->hInstance;
hCtl=CreateWindow("button","C Programming Language",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,10,40,250,25,hwnd,(HMENU)CHECK_BOX_C,hIns,0);
hCtl=CreateWindow("button","C++ Programming Language",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,10,70,250,25,hwnd,(HMENU)CHECK_BOX_C_PLUS_PLUS,hIns,0);
hCtl=CreateWindow("button","PowerBASIC",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,10,100,250,25,hwnd,(HMENU)CHECK_BOX_PowerBASIC,hIns,0);
hCtl=CreateWindow("button","Visual Basic 6",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,10,130,250,25,hwnd,(HMENU)CHECK_BOX_Visual_Basic_6,hIns,0);
hCtl=CreateWindow("button","Visual Basic .NET",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,10,160,250,25,hwnd,(HMENU)CHECK_BOX_Visual_Basic_NET,hIns,0);
return 0;
}
case WM_PAINT:
{
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
SetBkMode(hDC,TRANSPARENT);
TextOut(hDC,10,0,"Which Programming Languages Have You Used Today?",48);
EndPaint(hwnd,&ps);
return 0;
}
case WM_CLOSE:
{
MessageBox(hwnd,"Window Procedure Received WM_CLOSE Message!","Message Report!",MB_OK);
DestroyWindow(hwnd);
PostQuitMessage(0);
return 0;
}
}
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int iShow)
{
char szClassName[]="CheckBoxes";
WNDCLASSEX wc;
MSG messages;
HWND hWnd;
wc.lpszClassName=szClassName, wc.lpfnWndProc=fnWndProc;
wc.cbSize=sizeof (WNDCLASSEX), wc.style=CS_DBLCLKS;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION), wc.hInstance=hInstance;
wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION), wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW, wc.cbWndExtra=0;
wc.lpszMenuName=NULL, wc.cbClsExtra=0;
RegisterClassEx(&wc),
hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW,350,250,400,275,HWND_DESKTOP,0,hInstance,0);
ShowWindow(hWnd,iShow);
while(GetMessage(&messages,NULL,0,0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
|