Link to home
Start Free TrialLog in
Avatar of TheRealLoki
TheRealLokiFlag for New Zealand

asked on

Set another application's top, left, width and height from my app?

How can I set another applications top, left, width and height from my app?
eg. I want to do a CreateProcess and start "explorer.exe c:\temp"

And then later on, when I click on "Button1"
bring the explorer window (the one I created with CreateProcess) to the foreground, and
set it to Top:10, Left 10 width 400, height 300
Avatar of lacrewga
lacrewga

You can call explorer.exe with
......Place ShellAPI in Form Uses Clause
ShellExecute(Form1.Handle, 'open', 'c:\windows\explorer.exe',
  '', 'c:\temp', SW_SHOWNORMAL);
However, you can't set placement parameters with this call.
One possibility would be to surf for explorer like component on internet and just call it up in a window. Good luck.
ASKER CERTIFIED SOLUTION
Avatar of CodedK
CodedK
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheRealLoki

ASKER

hmmm
the user may change the current folder, so I will still need to kep track of it
If I create an explorer, then use 1 of the methods above to get it's handle straight away.
I store that handle.
WIll that handle remain constant even if the user changes the current folder in that explorer?
Yes...
ok, I can now get the correct list of "explorer windows"
however, when I try to bring them to the front, and set their position, sometimes it is not working
if i try again, it may/may not work. This is intermittent, but a pain
I'm using the following method since I am holding the window handles in a list
     SetForeGroundWindow(H1);
     SetWindowPos(H1,HWND_BOTTOM,10,10,400,300,0)

I've added checks for "IsIconic() and IsZoomed()" but still sometimes it does not bring the window to front and set it's dimensions. sometimes it does though...
Is there a way to make ths reliable?
Thanks, Loki
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks guys. points split because there was some useful information in many answers