Solved

ShowWindow does not work properly

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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