You are on page 1of 3

#include<windows.

h>
#include "resource.h"

//#define ID_DIALOG12 18
//#define ID_DIALOG22 19
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK DialogProc(HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK DialogProc1(HWND ,UINT , WPARAM ,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine
,int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if(! hPrevInstance)
{
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WndProc;
wndclass.lpszClassName = TEXT("MyClass");
wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
if(! RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("Window not registered"),TEXT("Wind
ow"),MB_OK);
return 0;
}
}
hwnd = CreateWindow(TEXT("MyClass"),TEXT("Window"),WS_OVERLAPPEDWINDOW,1
0,20,500,500,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,NULL,NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HINSTANCE hInstance;
hInstance = (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE);
switch(message)
{
case WM_CREATE:
return 0;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_DIALOG1:
// MessageBox(hwnd, TEXT(" Welcome Garry"),"MyClass",MB_OK)
;
// return TRUE;
DialogBox(hInstance,TEXT("IDD_DIALOG1"),hwnd,DialogProc)
;
break;
case ID_DIALOG2:
DialogBox(hInstance,TEXT("IDD_DIALOG2"),hwnd,DialogProc);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
BOOL CALLBACK DialogProc(HWND hwnd,UINT message, WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return(TRUE);
case WM_COMMAND:
switch(wParam)
{
case IDOK2:
MessageBox(hwnd, TEXT(" Welcome Garry"),TEXT("MyClass"),
MB_OK);
return TRUE;
case IDOK:
EndDialog(hwnd,0);
return(TRUE);
case IDCANCEL:
EndDialog(hwnd,0);
return(TRUE);
}
break;
}
return FALSE;
}
BOOL CALLBACK DialogProc1(HWND h,UINT m, WPARAM w,LPARAM l)
{
switch(m)
{
case WM_INITDIALOG:
return(TRUE);
case WM_COMMAND:
switch(w)
{
case IDOK3:
MessageBox(h, TEXT(" Hello Sir !!! "),TEXT("MyCl
ass"),MB_OK);
return TRUE;
case IDOK:
EndDialog(h,0);
return(TRUE);
case IDCANCEL:
EndDialog(h,0);
return(TRUE);
}
break;
}
return FALSE;
}