Solved

winexec

Posted on 1997-05-01
6
638 Views
Last Modified: 2013-11-20
Environment: VC++1.52, Win3.11

Hi All,

I have a little question.

In my program i open a notepad.exe by using WinExec:

WinExec("notepad.exe");
...????

What i can put just after WinExec, in order my program wait until the user close
the notepad program???

Thanks,
                                          Dja.
 
 
0
Comment
Question by:djamal
  • 2
  • 2
  • 2
6 Comments
 

Accepted Solution

by:
footloose earned 20 total points
ID: 1301255
After successful WinExec, use FindWindow to get the title of the NotePad window. The title will be unique, because it will be something like "filename - NotePad".

Start a timer that periodically checks for the existence of a window with that title. Then set focus to NotePad. If the timer callback finds that the window does not exist anymore, then it gets focus and does the necessary stuff.

If you want stricter control, you might want to try subclassing the app.

0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1301256
Sorry to interrupt your discussion. But just a point to make. The FindWindow() would not work for titles texts, if you plan to use it for international windows versions as Notepad has different names under different languages and hence findwindow w.r.t title will not successed. I recommend using Findwindow w.r.t the class name i.e. "Notepad".

I agree with the timer to some extent, Once the notepad is found , you can use the CDialog::DoModal() technique where the parent window is disabled and notepad is on top. This way you can give Notepad a modal dialog feel. Get your timer to enable your window and bring it on top once it finds the Notepad window has been destroyed.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1301257
It is advisable to use CreateProcess() instead of WinExec() for Win32.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:djamal
ID: 1301258
Hi All,

About the arguments of FindWindow:

How i can know the class name and window name of my application?

And in general how i can know the class name and window name of window
application like notepad, word, control panel etc...

Thanks,


                                    Dja.
0
 

Expert Comment

by:footloose
ID: 1301259
I agree with mbhakta on using the classname rather than the title. Class name for notepad is "Notepad". Give a NULL pointer argument for the title.
Use SPY.EXE to find the class name of apps.
The class name of your app is set when you create your main window. If you want to change that, register a new class and override PreCreateWindow of the mainframe to set the classname to that of yours.
0
 

Author Comment

by:djamal
ID: 1301260
In MainFrame, I've tried to assign class name inside virtual "PreCreateWindow", and it looked OK. However, it causes
error in "OpenDocumentFile" (msg: Fail to create empty document), then program quits.

How to change the default class name by another class name without change others parameter inside of WNDCLAS struct.?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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: 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 …
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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