You are on page 1of 5

Program 1

#include<windows.h>

int WINAPI WinMain(HINSTANCE i, HINSTANCE j, LPSTR k, int l)

MessageBox(NULL,TEXT("sadsds"),_TEXT("dfgdf"),0);

return 0;

Program 2

#include<windows.h>

int WINAPI WinMain(HINSTANCE i, HINSTANCE j, LPSTR k, int l)

HWND h;

MSG m;

h=CreateWindow(TEXT("BUTTON"),TEXT("Press"),BS_PUSHBUTTON,CW_USEDEFAULT,CW_USEDEFAULT
,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,i,NULL);

ShowWindow(h,l);

while(GetMessage(&m,NULL,NULL,NULL))

{
DispatchMessage(&m);

return 0; // If we will comment this line, then output will be sustained otherwise the
output will be shown for 1 second and then disappears as this return 0 will terminate while loop and
return 0 to return type of WinMain

return m.wParam;

Another variation of above code

#include<windows.h>

int WINAPI WinMain(HINSTANCE i, HINSTANCE j, LPSTR k, int l)

HWND h;

MSG m;

h=CreateWindow(TEXT("BUTTON"),TEXT("Press"),BS_PUSHBUTTON,CW_USEDEFAULT,CW_USEDEFAULT
,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,i,NULL);

ShowWindow(h,l);

while(GetMessage(&m,NULL,NULL,NULL))

if(m.message==WM_LBUTTONDOWN)

break;
else

DefWindowProc(m.hWnd,m.message,m.wParam,m.lParam);

return m.wParam;

Program 3
#include<windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE i, HINSTANCE j, LPSTR k, int l)

HWND h;

MSG m;

WNDCLASS w;

w.cbClsExtra=0;

w.cbWndExtra=0;

w.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);

w.hCursor=LoadCursor(NULL,IDC_ARROW);

w.hIcon=LoadIcon(NULL,IDI_APPLICATION);

w.hInstance=i;

w.lpfnWndProc=WndProc;
w.lpszClassName=TEXT("RSS");

w.lpszMenuName=NULL;

w.style=CS_HREDRAW | CS_VREDRAW;

if(!RegisterClass(&w)) {

return 0;

h=CreateWindow(TEXT("RSS"),TEXT("Ha
Ha"),WS_OVERLAPPEDWINDOW,50,50,100,100,NULL,NULL,i,NULL);

ShowWindow(h,l);

while(GetMessage(&m,NULL,NULL,NULL))

DispatchMessage(&m);

return 0;

LRESULT CALLBACK WndProc(HWND windowId, UINT messageId, WPARAM info, LPARAM addinfo)

switch(messageId)

case WM_DESTROY:

PostQuitMessage(0);

break;
}

return DefWindowProc(windowId,messageId,info, addinfo);

You might also like