Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AndreaKing

okay... HWND

This topic is 5651 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

everyone keeps telling me that i should put InvalidateRect in WinMain() loop, in order to keep the thing refreshing... which sounds very obvious to me... but nowhere in WinMain() is HWND handle defined... now i know this is probably a petty question, but i know for a fact that i CAN"T just define a window handle without initializing it... how do i go about doing that in WinMain? will HWND hWnd; work without initializing it?

Share this post


Link to post
Share on other sites
Advertisement
You''ll need to create a window with CreateWindow or CreateWindowEx before calling InvalidateRect. The call to CreateWindow/CreateWindowEx will return the needed HWND (if all goes well ).

HTH

SysOp_1101

Share this post


Link to post
Share on other sites
okay, well i''m basing off a HELLO WORLD win32 app... should i take the createwindow() out of InitInstance() and put it into winmain?

Share this post


Link to post
Share on other sites
According to MSDN:

Return Values (for CreateWindow or CreateWindowEx):

If the function succeeds, the return value is a handle to the new window.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Register the returned HWND as your local copy.

Note that I am not advocating the InvalidateRect idea. Invalidating the window contents when not needed is at best only inefficient. It really depends on what type of application you are writing. Think about it, if nothing has changed since the last update, why would you want to invalidate the current window contents. There are plenty of messages to handle repainting things when the window changes size, gets covered, etc... Again, all this depend on what you are writing. If you were using DX then I really dont think you would be concerned with this at all. Anyway, thats my 2 cents. Good luck.

Share this post


Link to post
Share on other sites
quote:
Original post by AndreaKing
okay, well i'm basing off a HELLO WORLD win32 app... should i take the createwindow() out of InitInstance() and put it into winmain?


You could do that. You could also modify InitInstance to return a HWND. You could also modify InitInstance to store the returned HWND in a global variable. Global variables are not advisable, but a global hWndMain turns up in quite a lot of code.

jplocster makes a good point regarding InvalidateRect. Putting that call in the main message loop might create a lot of flicker.



"Beautiful maiden," answered Candide, "when a man is in love, is jealous, and has been flogged by the Inquisition, he becomes lost to all reflection."


[edited by - lessbread on December 6, 2002 8:59:55 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!