Solved

ShowWindow does not work properly

Posted on 1998-03-09
4
392 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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