Solved

How to get m_hWnd after calling WinExec

Posted on 1998-05-12
4
209 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
sum28 challenge 31 117
mapBully challenge 6 177
Is there a simple front-end menu system. 9 120
moto 4g phone enable finger print 4 46
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

749 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