Jump to content
  • Advertisement
Sign in to follow this  
xyuri

getting HWND and message loop without a window

This topic is 4563 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 am wanting to process messages and such, but, dont want a window. Is this possible? Considering the message loop is tied to a HWND, and HWND is a window handle... Any input is appreciated, thanks :)

Share this post


Link to post
Share on other sites
Advertisement
I've never tried it but it seems that the message loop is tied to the window class you register, not the handle. So maybe you can leave out CreateWindow().

ace

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Use PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE) to create a message queue for the thread, then use PostThreadMessage using the thread ID to send the messages

Share this post


Link to post
Share on other sites
Thanks for that fella's, I'm still getting used to windows programming with the api's :)

Could have sworn that when i tried the message loop without creating a window last time that it didnt work, but this time it is working... need to look into this a bit more.

Thanks again :)

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
I've never tried it but it seems that the message loop is tied to the window class you register, not the handle. So maybe you can leave out CreateWindow().


Actually, the WndProc is tied to the window class. The message loop is tied to the thread. AP pointed in the right direction - PeekMessage and PostThreadMessage.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Use PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE) to create a message queue for the thread, then use PostThreadMessage using the thread ID to send the messages


That was me. Anyways, this works well in multithreaded environments, or if your only using a single thread, you can still use GetCurrentThreadId to get your main thread's ID.

-D

Share this post


Link to post
Share on other sites
From MSDN:

Message-Only Windows
A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.

To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function. You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent function.

To find message-only windows, specify HWND_MESSAGE in the hwndParent parameter of the FindWindowEx function. In addition, FindWindowEx searches message-only windows as well as top-level windows if both the hwndParent and hwndChildAfter parameters are NULL.

Share this post


Link to post
Share on other sites
Quote:
Original post by Bezben
From MSDN:

Message-Only Windows
A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.

To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function. You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent function.

To find message-only windows, specify HWND_MESSAGE in the hwndParent parameter of the FindWindowEx function. In addition, FindWindowEx searches message-only windows as well as top-level windows if both the hwndParent and hwndChildAfter parameters are NULL.


Thank you Bezben :) Simply changing this value worked a treat. For some reason, it worked on one case but not another... wierd. (I made a copy of the app for testing, and for each timer tick wrote something to a text file, but useing the method mentioned in this post, it did not work.)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
message only windows dont work in win versions other than 2k xp and newer

threads each have their own message queque, and it works even on win 95 or maybe even earlier (there are still win ver 3.x tutorials on msdn...lol)

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.

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

Sign me up!