Solved

ShowWindow does not work properly

Posted on 1998-03-09
4
395 Views
Last Modified: 2010-04-06
I am using Delphi under NT and the following code:-

handle:=findwindow(nil,'Directory');
if handle>0 then
   begin
   if IsIconic(handle) then
        begin
        ShowWindow(handle, sw_restore);
        SetActiveWindow( handle);
        end
      else
        setforegroundwindow(handle);

It works okay if the other app is in a normal state, but if it is minimized it will not restore itself properly.

You can use the window but you cannot minimize it unless you right mouse click on the program icon and select restore. I have read about Delphi using a hidden form, does this affect it?
0
Comment
Question by:ostevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360297
Don't know, what if you use ShowWindow(handle, SW_SHOWNormal) instead of

begin
...Sw_Restore
setactive...
end
0
 

Author Comment

by:ostevens
ID: 1360298
No, Ive tried all of the show commands and it still doesnt work.
I took out the IsIconic bit as well to make sure it was working and used shellexecute instead of executefile.

I changed the program from my other delphi app to Calculator, and it worked okay. I created a blank delphi app 'form1' and this had the same problem.
0
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1360299
Yo,
Delphi uses a 1x1 pixel, invisible window as a wrapper for the Application object. And you get the handle of this wrapper window.
Replace
handle:=findwindow(nil,'Directory');
with
handle:=findwindow(TMyAppForm,nil);
where TMyAppForm is the class name of the main form of your application (mostly TForm1). Change it to your form class name. It is a good idea to take a 'unique' name for the forma class because you want to identify your window in nearly any situation.

Hope this helps,
Slash/d003303
0
 

Author Comment

by:ostevens
ID: 1360300
Sorted, found the right handle to do it.
Cheers mate.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question