×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Message Mapping?

Message Mapping?

Message Mapping?

(OP)
I have a prgm in VC++ that opens other prgms and generates BM_CLICK messages.  What I want to do is to have those messages sent to the third-party prgms buttons.  I think I can achieve this by inputting the second paramater of a Message Map function with the ID_ of the button.  Would anyone know if this is possible?  The way I was told was that a Message Map fucntion takes 2 params, first the message it's screening for and second, the function or Class the message is routed to.  Is it possible to replace the function/Class param with the ID_ of the button and have the message sent to that button.

Any and all help is appreciated!

RE: Message Mapping?

Dear HEY DUDE,

> What I want to do is to have those messages sent to the third-party prgms buttons.  

Have you ever sent any window message to a window that is not owned by your application?

> I think I can achieve this by inputting the second paramater of a Message Map
> function with the ID_ of the button.  Would anyone know if this is possible?  

Please define 'the button', what button?

> The way I was told was that a Message Map fucntion takes 2 params, first the message it's
> screening for and second, the function or Class the message is routed to.  

Different messages require different numbers of arguments. Have you ever used the SendMessage() or PostMessage() API's for the Win16 or Win32 SDK?

-pete

RE: Message Mapping?

(OP)
HEY PETE,


I was originally thinking that it would be easier to send messages to child controls of the Third-party app.  through the Message Map but someone has pointed out that I would probably still need to get the hWnd's of the parent processes first which is what I was trying to avoid.  As you can see below is some code someone sent me on how to retrieve an hWnd from a luanched app. and use SendMessage to send BM_CLICK's. The one thing that would make things even easier for me is if there was a way to return an hWnd directly from the CreateProcess() function, if you know how please let me know.  I do appreciate your reply!    

HWND hWnd;
STARTUPINFO si;
PROCESS_INFORMATION pi;
CreateProcess(NULL, "sndrec32.exe", NULL, NULL, FALSE, 0, NULL, ".", &si,&pi);
// may need to wait a moment here until the app launches...
Sleep(1000);
// search by title bar text
//hWnd = FindWindow(NULL, "Sound - Sound Recorder");
// or search by window class (if the title may change)
hWnd = FindWindow("SoundRec", 0);
if (hWnd) {
// press the Play button (control ID 207 sniffed out by Spy++)
SetForegroundWindow(hWnd);
SendMessage(GetDlgItem(hWnd, 207), BM_CLICK, 0, 0);
}

RE: Message Mapping?

Dear Dude,

Here is some comments and urls on MSDN from a past Dr GUI article:

Hope this helps
-pete

Another potential problem is that you don't know the exact title of the window you want to activate. If you have the class name and it's unique, you're ready to operate-see above. But, if the class name isn't unique, you can search through the top-level windows using the technique described in Microsoft Knowledge Base article Q147659 "HOWTO: Get a Window Handle Without Specifying an Exact Title" (http://support.microsoft.com/support/kb/articles/q147/6/59.asp). This article describes a FindWindowLike function that you can write.

A much harder and rarely used technique is to search for the process by its module name (See Microsoft Knowledge Base Q175030, "HOWTO: Enumerate Applications in Win32" http://support.microsoft.com/support/kb/articles/q175/0/30.asp). There is no portable way to implement this on both Windows 95 and Windows NT. You will have to write separate code for each platform. In Windows 95, you will need to use the Tool Help Library of functions, and in Windows NT, the PSAPI.DLL functions. After you get the process handle, you will then need to find a top-level window via EnumThreadWindows() to call SetForegroundWindow() on.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close