Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Mapping?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a prgm in VC++ that opens other prgms and generates BM_CLICK messages.&nbsp;&nbsp;What I want to do is to have those messages sent to the third-party prgms buttons.&nbsp;&nbsp;I think I can achieve this by inputting the second paramater of a Message Map function with the ID_ of the button.&nbsp;&nbsp;Would anyone know if this is possible?&nbsp;&nbsp;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.&nbsp;&nbsp;Is it possible to replace the function/Class param with the ID_ of the button and have the message sent to that button.<br><br>Any and all help is appreciated!
 
Dear HEY DUDE,<br><br>&gt; What I want to do is to have those messages sent to the third-party prgms buttons.&nbsp;&nbsp;<br><br>Have you ever sent any window message to a window that is not owned by your application?<br><br>&gt; I think I can achieve this by inputting the second paramater of a Message Map <br>&gt; function with the ID_ of the button.&nbsp;&nbsp;Would anyone know if this is possible?&nbsp;&nbsp;<br><br>Please define 'the button', what button?<br><br>&gt; The way I was told was that a Message Map fucntion takes 2 params, first the message it's <br>&gt; screening for and second, the function or Class the message is routed to.&nbsp;&nbsp;<br><br>Different messages require different numbers of arguments. Have you ever used the SendMessage() or PostMessage() API's for the Win16 or Win32 SDK?<br><br>-pete
 
HEY PETE,<br><br><br>I was originally thinking that it would be easier to send messages to child controls of the Third-party app.&nbsp;&nbsp;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.&nbsp;&nbsp;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.&nbsp;&nbsp;I do appreciate your reply!&nbsp;&nbsp;&nbsp;&nbsp;<br><br>HWND hWnd;<br>STARTUPINFO si;<br>PROCESS_INFORMATION pi;<br>CreateProcess(NULL, &quot;sndrec32.exe&quot;, NULL, NULL, FALSE, 0, NULL, &quot;.&quot;, &si,&pi);<br>// may need to wait a moment here until the app launches...<br>Sleep(1000);<br>// search by title bar text<br>//hWnd = FindWindow(NULL, &quot;Sound - Sound Recorder&quot;);<br>// or search by window class (if the title may change)<br>hWnd = FindWindow(&quot;SoundRec&quot;, 0);<br>if (hWnd) {<br>// press the Play button (control ID 207 sniffed out by Spy++)<br>SetForegroundWindow(hWnd);<br>SendMessage(GetDlgItem(hWnd, 207), BM_CLICK, 0, 0);<br>}<br><br>
 
Dear Dude,<br><br>Here is some comments and urls on MSDN from a past Dr GUI article:<br><br>Hope this helps<br>-pete<br><br>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 &quot;HOWTO: Get a Window Handle Without Specifying an Exact Title&quot; (<A HREF=" TARGET="_new"> This article describes a FindWindowLike function that you can write.<br><br>A much harder and rarely used technique is to search for the process by its module name (See Microsoft Knowledge Base Q175030, &quot;HOWTO: Enumerate Applications in Win32&quot; <A HREF=" TARGET="_new"> 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.<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top