Earn without any Investment!

Wednesday, January 12, 2011

VC++ Program to Display Welcome while Clicking

#include<windows.h>
long _stdcall myfunc(HWND,UINT,UINT,long);
WNDCLASSA a;
int _stdcall WinMain(HINSTANCE i,HINSTANCE j,char *k,int l)
{
    HWND h;
    MSG m;
    a.hInstance=i;
    a.lpszClassName="my";
    a.lpfnWndProc=myfunc;
    a.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    RegisterClassA(&a);
    h=CreateWindowA("my","Click on the Window Area",WS_OVERLAPPEDWINDOW,10,10,150,100,0,0,i,0);
    ShowWindow(h,3);
    while(GetMessage(&m,0,0,0))
        DispatchMessage(&m);
    return 0;
}
long _stdcall myfunc(HWND w,UINT x,UINT y,long z)
{
    HDC d;
    int x1,y1;
    switch(x)
    {
    case WM_LBUTTONDOWN:
        x1=LOWORD(z);
        y1=HIWORD(z);
        d=GetDC(w);
        TextOutA(d,x1,y1,"Welcome",7);
        ReleaseDC(w,d);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProcA(w,x,y,z);
    }
    return 0L;
}

No comments:

Post a Comment