RE: [Dev-C++] What's wrong with this code?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jaap de W. <wo...@Ne...> - 2002-11-27 12:45:22
|
Ok, I was wrong about the menu.
But Carlos, the WNDCLASS struct does not have a cbSize member. Thats =
the
WNDCLASSEX.
What is wrong about the code is -not- in WinMain, (although there =
should be
a ; after CreateWindow()) but in WndProc().
You have to put one more return statement:
In your old code you always return zero.
This is wrong for for instance the WM_NCCREATE message, this will =
prevent
your window from being created.
LRESULT CALLBACK WndProc(HWND handle, UINT msg, WPARAM wp, LPARAM lp) {
switch(msg) {
case WM_DESTROY: // close
PostQuitMessage(0);
break;
=20
default: // default
->return<- DefWindowProc(handle,msg,wp,lp);
}
=20
return 0;
}
Jaap.
> -----Original Message-----
> From: Carlos Garc=EDa del Monte [mailto:cg...@wo...]
> Sent: Wednesday, November 27, 2002 12:10 PM
> To: dev-cpp-users-list
> Subject: Re: [Dev-C++] What's wrong with this code?
>=20
>=20
> TCHAR is one character never a string. For a string use=20
> either TCHAR* or LPTSTR.
> (Pointing about an answer by Marc Heiliger)
> Answering to Jaap, it's not needed to give a menu, you can=20
> use NULL if you don't
> want have one. That's just the default code for a window app=20
> and it works,
> giving a window with nothing.
> The answer is that you are not initializing the cbSize field=20
> of the WNDCLASS
> structure, you must initialize it so when the program watches=20
> at it it can use
> the memory space needed. You must add this line:
> wndclass.cbSize =3D sizeof(WNDCLASS);
> Remember this, always you need to use an structure you have=20
> ALWAYS to fill a
> member of it which is the size of the structure with=20
> structure.sizeMember =3D
> sizeof(STRUCTURE); The structures never know what's its own=20
> size, so you must
> provide it with that member.
>=20
> The answer can be too in the line, but I'm almost sure it is=20
> defined in the
> header, however I say it:
> wndclass.lpfnWndProc =3D WndProc;
> This member of the struct defines which is the window's=20
> callback function, which
> must have been defined before, but it is not defined, at=20
> least in this file.
> Add at the begin of it the line
> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
> And some place after in the file write the function.
> LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam,=20
> LPARAM lParam);
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.net email is sponsored by: Get the new Palm Tungsten T=20
> handheld. Power & Color in a compact size!=20
> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|