Jump to content
  • Advertisement
Sign in to follow this  

Question on Windows Messages

This topic is 2928 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 dabbling in some windows programming lately, and am confused on a point about window Handles and Messages.

For one, I can't seem to get a window by it's title as I supposedly should be able to. I know for sure what the title is, and am using the following command:

theTracker = FindWindowEx(NULL, NULL, NULL, "OpenMPT");

to try and grab the handle. However, it always returns NULL. My understanding is that this command should search every active window (including children), using the desktop as the parent, for a window with the title of "OpenMPT". However, it never finds anything.

Turning instead to the PostMessage() function, I tried to post to the 'current thread' by replacing the handle parameter with NULL as described here. Also doesn't seem to work.

The messages I'm trying to send are found in a message map, which I reproduce here:


I am trying to Post or SendMessage() with the ID_FILE_NEW message. Can't get it to work.

One final question: is ID_FILE_NEW the actual message name? It seems it should be, but I thought maybe Windows might append some other prefix to it?

Any help, even a pointer to some nice reading on this stuff, would be great.

Share this post

Link to post
Share on other sites
Are you trying to manipulate a window in a different program?

There are limitations on what can be done across process boundaries in Windows.

Share this post

Link to post
Share on other sites
FindWindowEx should work unless the process is running with elevated permissions compared to your own process. I would use a tool like Spy++ (or whatever is available recently) to find out what the window class is, instead of the caption. Lots of apps change their caption when they are playing/viewing a different file, for example.

The ID_* constants aren't windows messages, they're parameters for a message. The message you want (I believe) is WM_COMMAND. Pass the ID_* value as the wParam. You'll have to figure out what their actual integer value is, though, since they're custom defined in that app itself, not in the Win32 API.

Share this post

Link to post
Share on other sites
Not in a different program, I'm adding this code directly into the already-existing program.

Thank Nypyren, that's helped a good deal. Still ain't working, sadly, but you led me to the Resource.h file where all the constants are defined - and it doesn't seem like ID_FILE_NEW actually is, only the ID_FILE_NEWIT and such. Which is weird, cuz then how can ID_FILE_NEW have it's own command in the message map? Aie.

I've got ProcessExplorer, but none of the info it gives me is much help.

EDIT: I'm beginning to think there's something wonky going on with the code I'm modifying, as even GetActiveWindow returns null when there is a very definite active window. In other words, I think I need to abandon the windows handle thing and try something else. Thanks for the help, guys. I'll have to return to this stuff with my own projects so I know more about what's going on.

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!