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?
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.
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.
Did you start the other program by CreateProcess?
If yes you should have a look at STARTUPINFO structure.
If yes you should have a look at STARTUPINFO structure.
I recommend searching msdn on M$ for:
CreateProcess
WaitForInputIdle
If this does give you enough information ask again ok?
CreateProcess
WaitForInputIdle
If this does give you enough information ask again ok?
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?
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?
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.
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.
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. :(
What about using ShellExecute/Ex?
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.
Marwin, this is how I would probably do it, step by step:
Posted on 2002-08-12 05:15:21 by iblis
Posted on 2002-08-12 05:15:21 by iblis
Hi iblis. Think this would help me. I'll try it.
:) Thank you, Marwin
:) Thank you, 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?
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.
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.
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.
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.
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).