winexec

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.
 
 
djamalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footlooseCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbhaktaCommented:
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
mbhaktaCommented:
It is advisable to use CreateProcess() instead of WinExec() for Win32.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

djamalAuthor Commented:
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
footlooseCommented:
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
djamalAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.