Print | Email | del.icio.us | A | A | A |

#include "windows.h"

/*int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
MessageBox(NULL,"Hello Welcome","Sample",MB_OK);
return 0;
}
*/


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


LRESULT CALLBACK testProc(HWND hwnd, UINT my_message, WPARAM wParam, LPARAM lParam)
{
int xPos;
int yPos;
xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
HDC hdc;
PAINTSTRUCT ps;
switch(my_message)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);

RECT ra;
GetClientRect(hwnd,&ra);

ra.left = 0;
ra.top = 0;
//ra.right = ;
//ra.bottom = 200;


DrawText(hdc,"Top Left",8,&ra,DT_LEFT);
DrawText(hdc,"Top Center",10,&ra,DT_CENTER);
DrawText(hdc,"Top Right",9,&ra,DT_RIGHT);

RECT ra1;
GetClientRect(hwnd,&ra1);


ra1.left = 0;
ra1.top = ra.bottom/2 - 20;
ra1.right = ra.right;
ra1.bottom = ra.bottom/2;

DrawText(hdc,"Center Left",11,&ra1,DT_LEFT);
DrawText(hdc,"Center",6,&ra1,DT_CENTER);
DrawText(hdc,"Center Right",12,&ra1,DT_RIGHT);


ra1.left = 0;
ra1.top = ra.bottom - 20;
ra1.bottom = ra.bottom;
//ra1.right = ;
//ra1.bottom = 200;

DrawText(hdc,"Bottom Left",11,&ra1,DT_LEFT);
DrawText(hdc,"Bottom Center",13,&ra1,DT_CENTER);
DrawText(hdc,"Bottom Right",12,&ra1,DT_RIGHT);
break;

case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"Left Mouse Button Clicked","MOUSE OPTIONS",MB_OK);
break;
case WM_RBUTTONDOWN:
MessageBox(hwnd,"Right Mouse Button Clicked","MOUSE OPTIONS",MB_OK);
break;
case WM_MBUTTONDOWN:
MessageBox(hwnd,"Middle Mouse Button Clicked","MOUSE OPTIONS",MB_OK);
break;
case WM_LBUTTONDBLCLK:
MessageBox(hwnd,"Left Mouse Button DOUBLE Clicked","MOUSE OPTIONS",MB_OK);
break;
case WM_RBUTTONDBLCLK:
MessageBox(hwnd,"Right Mouse Button DOUBLE Clicked","MOUSE OPTIONS",MB_OK);
break;
case WM_MBUTTONDBLCLK:
MessageBox(hwnd,"Middle Mouse Button DOUBLE Clicked","MOUSE OPTIONS",MB_OK);
break;
case WM_NCLBUTTONDOWN:
MessageBox(hwnd,"Left Mouse Button in Non-Client Area","MOUSE OPTIONS",MB_OK);
break;
case WM_NCRBUTTONDOWN:
hdc = GetDC(hwnd);
TextOut(hdc,xPos,yPos,"Right Mouse Button in Non-Client Area",36);
// MessageBox(hwnd,"MOUSE OPTIONS","Right Mouse Button in Non-Client Area",MB_OK);
ReleaseDC(hwnd,hdc);
return 0;
break;
}
return DefWindowProc(hwnd, my_message, wParam, lParam);
}





int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd;
WNDCLASS wclass;
MSG msg;
wclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wclass.lpfnWndProc = (WNDPROC)testProc;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
wclass.hInstance = hInstance;
wclass.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_APPLICATION);
wclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wclass.lpszMenuName = NULL;
wclass.lpszClassName = "Mouse cls";
RegisterClass(&wclass);
hwnd = CreateWindow("Mouse cls","Mouse Operations", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}




--
------------------------~!~----------------------
Best Regards,
G.Arun Bala
B.Tech Information Technology
SSNCE,Kalavakkam
http://dmatriz.wordpress.com
-------------------------~!~---------------------



If you want a custom URL for this text, click here ($2/year)

If you want to create your own free URL , click here

Comments [Refresh] [ RSS ]




3. >> More coding necessary in LBTN_DOWN part too
2/4/2007 10:16:01 AM

2. it works fine other wise too....

fine....
2/4/2007 10:15:23 AM

1. Hi..

do include #include "stdafx.h"
2/4/2007 10:14:35 AM