Code:
#include <windows.h>
LRESULT CALLBACK WndProc(HWND , UINT , WPARAM , LPARAM);
static char szAppName[] = "test";
int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR szCmdLine , int iCmdShow)
{
HWND hwnd , button1 , button2;
MSG msg;
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL , IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL , IDC_ARROW);
wc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
wc.lpszMenuName = NULL;
wc.lpszClassName = szAppName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL,"class reg failed","doh!",MB_OK);
return(1);
}
hwnd = CreateWindowEx(0 , szAppName , "test" ,
WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT , CW_USEDEFAULT ,
CW_USEDEFAULT , CW_USEDEFAULT ,
HWND_DESKTOP , NULL , hInstance , NULL);
button1 = CreateWindow("button" , "test" ,
WS_CHILD | WS_VISIBLE | BS_GROUPBOX ,
50 , 50 ,
200 , 100 ,
hwnd ,
NULL ,
(HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) ,
NULL);
button2 = CreateWindowEx(WS_EX_WINDOWEDGE , "button" , "test" ,
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
75 , 75 ,
120 , 20 ,
hwnd ,
NULL ,
(HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) ,
NULL);
ShowWindow(hwnd , SW_SHOW);
UpdateWindow(hwnd);
while(GetMessage(&msg , NULL , 0 , 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd , message , wParam , lParam);
}
changes made: