0% found this document useful (0 votes)
27 views3 pages

#Include #Include #Include Long - Stdcall Long Int - Stdcall Char Int

The document defines functions for handling window messages in a Windows application. It registers a window class and creates a window instance. The MyFunction callback handles WM_CHAR, WM_PAINT, and WM_DESTROY messages by drawing text to the window in response to key presses and repaint requests. It displays the character of a key press in WM_CHAR and refreshes the text during WM_PAINT. WM_DESTROY closes the application.

Uploaded by

kirands07
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

#Include #Include #Include Long - Stdcall Long Int - Stdcall Char Int

The document defines functions for handling window messages in a Windows application. It registers a window class and creates a window instance. The MyFunction callback handles WM_CHAR, WM_PAINT, and WM_DESTROY messages by drawing text to the window in response to key presses and repaint requests. It displays the character of a key press in WM_CHAR and refreshes the text during WM_PAINT. WM_DESTROY closes the application.

Uploaded by

kirands07
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<Windows.h> #include<stdio.h> #include<string.

h> long _stdcall MyFunction(HWND,UINT,UINT,long); WNDCLASS obj; int _stdcall WinMain(HINSTANCE a,HINSTANCE b,char *c,int d) { HWND hnd; MSG msg; obj.hInstance=a; obj.lpszClassName="Myclass"; obj.lpfnWndProc=MyFunction; obj.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); RegisterClass(&obj); hnd=CreateWindow("Myclass","Window Application For text handling",WS_OVERLAPPEDWINDOW,10,10,300,300,0,0,a,0); ShowWindow(hnd,1); UpdateWindow(hnd); while(GetMessage(&msg,0,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } long _stdcall MyFunction(HWND i,UINT j,WPARAM k,LPARAM l) { HDC dev; char str[100]=""; switch(j) { case WM_CHAR: dev=GetDC(i); sprintf(str,"The character is %c",(char)k); TextOut(dev,1,1,str,strlen(str)); ReleaseDC(i,dev); break; case WM_KEYDOWN:strcpy(str,"The key is down"); switch((char)k) { case VK_UP: strcat(str,"UP Arrow key pressed"); break; case VK_DOWN: strcat(str,"DOWN Arrow key pressed"); break; case VK_LEFT: strcat(str,"LEFt Arrow key pressed"); break; case VK_RIGHT: strcat(str,"RIGHT Arrow key pressed"); break; case VK_SHIFT: strcat(str,"SHIFT key pressed"); break; case VK_HOME: strcat(str,"HOME key pressed"); break;

case VK_END: strcat(str,"END key pressed"); break; } strcat(str,""); dev=GetDC(i); TextOut(dev,1,1,str,strlen(str)); ReleaseDC(i,dev); break; case WM_KEYUP:dev=GetDC(i); sprintf(str,"Key is now up"); TextOut(dev,1,20,str,strlen(str)); ReleaseDC(i,dev); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(i,j,k,l); } return 0L; }

#include<Windows.h> #include<stdio.h> #include<string.h> long _stdcall MyFunction(HWND,UINT,UINT,long); WNDCLASS obj; int _stdcall WinMain(HINSTANCE a,HINSTANCE b,char *c,int d) { HWND hnd; MSG msg; obj.hInstance=a; obj.lpszClassName="Myclass"; obj.lpfnWndProc=MyFunction; obj.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); RegisterClass(&obj); hnd=CreateWindow("Myclass","Window Application For text handling",WS_OVERLAPPEDWINDOW,10,10,300,300,0,0,a,0); ShowWindow(hnd,1); UpdateWindow(hnd); while(GetMessage(&msg,0,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } long _stdcall MyFunction(HWND i,UINT j,WPARAM k,LPARAM l) { HDC dev; PAINTSTRUCT ps; char str[255]=""; switch(j) { case WM_CHAR: dev=GetDC(i);

TextOut(dev,200,200," ",3); sprintf(str,"%c",(char)k); TextOut(dev,200,200,str,strlen(str)); ReleaseDC(i,dev); break; case WM_PAINT: dev=BeginPaint(i,&ps); TextOut(dev,200,200,str,strlen(str)); EndPaint(i,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(i,j,k,l); } return 0L; }

You might also like