hi all
i am attaching a C program for windows 2000. I am trying to run
this in VC++. I get no errors or warnings but the windows
doesn't shows up!
What is wrong?Please tell me..
Thanks in advance
Printable View
hi all
i am attaching a C program for windows 2000. I am trying to run
this in VC++. I get no errors or warnings but the windows
doesn't shows up!
What is wrong?Please tell me..
Thanks in advance
I don't know why your code does not work, but if you change RegisterClassEx to RegisterClass then it works for some reason. Perhaps someone else knows exactly why.
PHP Code:
#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
char szWinName[] = "MyWin";
int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInst,LPSTR
lpszArgs, int nWinMode)
{
HWND hWnd;
MSG msg;
WNDCLASS wcl;
wcl.hInstance = hThisInstance;
wcl.lpszClassName = szWinName;
wcl.lpfnWndProc = WindowFunc;
wcl.style = CS_HREDRAW | CS_VREDRAW;
wcl.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wcl.hCursor = LoadCursor(NULL,IDC_ARROW);
wcl.lpszMenuName = NULL;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
if(!RegisterClass(&wcl)) return 0;
hWnd = CreateWindow(
szWinName,
"My First Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hThisInstance,
NULL
);
ShowWindow(hWnd,nWinMode);
UpdateWindow(hWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,message,wParam,lParam);
}
return 0;
}
You must set the hIconSm member of WNDCLASSEX