Jump to content
  • Advertisement
Sign in to follow this  
DarkSlayer

win32 - understanding windows

This topic is 5410 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

I'm currently reading up on windows stuff, and find myself puzzeled. Reading the Programming windows by petzold, I was thinking of messing around a bit. Take a simpel example like the ... sysmets4. winmain() HWND MSG WNDCLASSEX - fills the struct RegisterClassEx( WNDCLASSEX ) hwnd = CreateWindow(lots of stuff) ShowWindow() UpdateWindow() messageloop goes here Am i right that the messageloop belongs to the window created by the CreateWindow()? I would like to make an window object ... or put as much of windowing, graphics etc into a view class or something ... so I then could just create a view object, give it a few settings, get the window up, when done .. destroy it. I was also thinking of adding a simple splash screen without using too much of the resource editor stuff. But if I have made a window like it is done in the sysmets, then I guess I have to make a splash window .. view it, destroy it, create the new window for my main program, becuase you can't have 2 windows, unless messing with the mdi? creating a parent window, then a child ... or maybe that's the best anyway... could someone kick my brain in the right direction? I kinda have several "explanations/codes" for splash screen, and I kinda doesn't get it. I just want an explanation please.

Share this post


Link to post
Share on other sites
Advertisement
The message loop is not only for the main window. It will receive all the messages for the application. This means that if you have only one window, the messages are meant for this window.

But most applications also have dialogs. As you might know there are two kinds of dialogs. Modal and Modeless dialogs. The modal boxes are commonly know as for example the message boxes. You must press the Ok button before the main window gets the focus back. The modeless dialogs are the dialogs that you want to use for the splash screens. You can show the dialog while the main window can continue loading and do other stuff. Make it a topwindow so it will stay on top of your application.

In visual studio it isn't that hard to make a good splash dialog resource. You can then create the dialog with the CreateDialog function (make sure you check the visible option) so your dialog shows up immediately.

Also, you should better leave the MDI part away till you are comfortable with the default SDI and dialog applications.

Share this post


Link to post
Share on other sites
The messages you get by calling GetMessage() or PeekMessage() should be sent to the correct WinProc() by calling TranslateMessage() then DispatchMessage(). You should check for the quit message here as well (before dispatching), and exit your program. All other messages should be proccessed in the WinProc().

Share this post


Link to post
Share on other sites
Quote:
Original post by jeroenb
The message loop is not only for the main window. It will receive all the messages for the application.
Incorrect.

The GetMessage and PeekMessage APIs can retrieve messages posted to the message queues of any thread within the process space. Passing a null HWND parameter causes them to check all message queues, which is the most common approach since the WM_QUIT message is not sent to any particular window and additional steps would be necessary to respond to it otherwise. You can constrain your message pump to an individual window/thread, though; this is often done in multithreaded applications.

Share this post


Link to post
Share on other sites
mmm ok

tried to mess around here with a dialog and stuff, understand what you said about them. But I also tried to mess with showing/hiding a window ... not sure if I get it.

In the normal program above you have the ShowWindow() to view the window. But is it possible to trigger the view'ing of the main window from the messageQ? I didn't make it. Thought the HWND in the winproc was the same as the hwnd in winmain ... CreateWindow returns a hwnd .. and isn't this the same hwnd?

... just to be able to controll the view'ing more...

Share this post


Link to post
Share on other sites
hmm ... can't say I got wiser from this...

Dlg = CreateDialog()

ShowWindow(hwnd, SW_HIDE);
UpdateWindow(hwnd); <-probably useless

Sleep(1000);

ShowWindow(hwnd, SW_SHOW);
UpdateWindow (hwnd);

This is the best simulating environment I can think of... What I see is that the window has to be created before you use an DialogBOx, so then it has to be hidden to create the wanted effect. hmm hmm.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!