Jan 29th, 2002, 01:48 PM
#1
Thread Starter
Hyperactive Member
Where am i wrong?
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
Attached Files
Jan 29th, 2002, 04:51 PM
#2
Member
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 ;
}
Jan 29th, 2002, 05:20 PM
#3
You must set the hIconSm member of WNDCLASSEX
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width