Solved

How to get m_hWnd after calling WinExec

Posted on 1998-05-12
4
197 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This video discusses moving either the default database or any database to a new volume.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now