My program starts another one. I want to get the handle of the main window to move it to a specified position! How could I realize this?
Posted on 2002-08-08 14:09:03 by Marwin
Hmm,

couldn't you just use FindWindow?
You know the title of your other program, and then you get the handle to this window.

Or am I wrong here?

Greets YaWNS aka Stefan K.
Posted on 2002-08-08 14:59:21 by YaWNS
Did you start the other program by CreateProcess?
If yes you should have a look at STARTUPINFO structure.
Posted on 2002-08-08 20:46:08 by C.Z.
I recommend searching msdn on M$ for:

CreateProcess
WaitForInputIdle

If this does give you enough information ask again ok?
Posted on 2002-08-08 20:50:01 by Roy Cline
YaWNS
No I can't use FindWindow, because I don't know the title. The problem is that the program what I want to move is userdefined. So it could be a helpfile, notepad, the explorer or others.

bomb01
If I use CreateProcess, isn't the started program automaticly terminated when my program is terminated?
Posted on 2002-08-09 13:57:50 by Marwin
Then how are you starting the other program if you don't use
CreateProcess?
To save time, note in the 32bit Windows Winexec just calls CreateProcess.
If your program starts another program that is user define then
you can retieve the of the exe file, yes?
Then you could try --

The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.
Posted on 2002-08-09 15:34:47 by Roy Cline
Sorry, I've tried to use CreateProcess. But the problem is that you could start only executeble file with this function. But I also want to open documents like helpfiles. I tried a lot, but haven't found any solution. Argh, I think I have to resign this feature of my program. :(
Posted on 2002-08-11 13:50:10 by Marwin
What about using ShellExecute/Ex?
Posted on 2002-08-11 23:01:40 by CodeLover
This is the function I used until now CodeLover! I think that's the only one with what I could open documents as well as executable files.
Posted on 2002-08-12 03:41:03 by Marwin
Marwin, this is how I would probably do it, step by step:

Posted on 2002-08-12 05:15:21 by iblis
Hi iblis. Think this would help me. I'll try it.

:) Thank you, Marwin
Posted on 2002-08-12 05:44:22 by Marwin
Just another question iblis. If I want to register a file type (for example .asm) could I create an key named HKEY_CLASSES_ROOT\.asm (and fill in the open\command)? Or do I have to do other things too?
Posted on 2002-08-12 06:10:29 by Marwin
Marwin,

There is a Microsoft-specific way to register your program to handle different file types. Different types of programs will have to do it different ways.

This MSDN article should help get you started.


Edit: Oh yeah, I must also strongly stress that you be considerate when modifying the registry. I think I speak for most people when I say that I do not appreciate a program that messes with my file associations without telling me about it. Try to give the user the opportunity to veto the change, or at the very least try to inform them of what's happening.
Posted on 2002-08-12 06:21:38 by iblis
Look this up in the the MSDN.

HINSTANCE FindExecutable(
LPCTSTR lpFile,
LPCTSTR lpDirectory,
LPTSTR lpResult
);

Should return name of program.
If you want to know if a file is exe bat com etc try
SHFileInfo.
Posted on 2002-08-12 21:54:55 by Roy Cline
Yes I know Roy, or you take PathFindExtension (to find the beginning-offset of the extension in the filename) or PathMatchSpec (to compare the extension of a filename with an extension in a buffer).
Posted on 2002-08-13 03:52:57 by Marwin