?
Solved

How to get m_hWnd after calling WinExec

Posted on 1998-05-12
4
Medium Priority
?
217 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 200 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

771 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