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
Solved

ShowWindow does not work properly

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 57
Delphi XE10 Round Image 2 154
Delphi: Connect to running MS Outlook 4 118
Delphi problems to abort a printjob 9 24
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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