Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get m_hWnd after calling WinExec

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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Loops Section Overview

886 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