Solved

ShowWindow does not work properly

Posted on 1998-03-09
4
387 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
Comment Utility
Don't know, what if you use ShowWindow(handle, SW_SHOWNormal) instead of

begin
...Sw_Restore
setactive...
end
0
 

Author Comment

by:ostevens
Comment Utility
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
Comment Utility
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
Comment Utility
Sorted, found the right handle to do it.
Cheers mate.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now