Avatar of TheRealLoki
TheRealLoki
Flag 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
Delphi

Avatar of undefined
Last Comment
TheRealLoki

8/22/2022 - Mon
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
CodedK

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Russell Libby

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
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?
CodedK

Yes...
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
TheRealLoki

ASKER
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
CodedK

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
TheRealLoki

ASKER
thanks guys. points split because there was some useful information in many answers