Solved

How to get m_hWnd after calling WinExec

Posted on 1998-05-12
4
211 Views
Last Modified: 2013-11-20
I am developing software using MS Pen Services 2.0. It comes with an executable that creates a window for handwriting input (WRITEPAL.EXE). I would like to use WinExec to start WRITEPAL.EXE, then get the m_hWnd for the WRITEPAL window so that I can trap messages going to and from it. I only have the executable; no source code and no documentation on how to use the executable.

1. Is this possible?
2. If it is possible, how do I do it?

(I will increase the number of points if somebody can tell me how to do this)
0
Comment
Question by:horn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
tma050898 earned 50 total points
ID: 1310067
One method would be to use the ::FindWindow function as follows where "xyz" is the title bar text of the application.

HWND hwnd = ::FindWindow(NULL, "xyz");

Here's a very simple example of locating Notepad (I don't have pen support installed), attaching a CWnd object to it and calling a CWnd member function.

HWND hwnd;
if (NULL != (hwnd = ::FindWindow(NULL, "Untitled - Notepad")))
{
 CWnd wnd;
 if (wnd.Attach(hwnd))
 {
  wnd.BringWindowToTop();
 }
 wnd.Detach();
}
else
{
 AfxMessageBox("Notepad not found");
}

HTH,
Tom

0
 
LVL 3

Expert Comment

by:tma050898
ID: 1310068
horn,

Did the answer above help you or do I need to provide some additional information?

If the answer above did solve your problem, could you please close it by accepting the answer and grading my help? That way, other programmers having the same problem will have the benefit of this question having been asked and answered.

Thanks,
Tom
0
 

Author Comment

by:horn
ID: 1310069
It did help. I'm sorry I took so long to grade it; I kind of
forgot about it because I had finals these last two weeks.

Thanks!
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1310070
No problem! I'm glad I was able to help.

Tom
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
method notes when mouse over in eclipse 5 94
has77  challenge 9 104
pre4 challenge 19 116
Execute multiple curl cmds with sleep and send output to file 10 121
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question