Solved

Reading Windows States

Posted on 1998-07-29
9
148 Views
Last Modified: 2010-04-04
Hey all,

I'm currently writing a delphi program (it's a toolbar of sorts) that needs to be visible if internet explorer (ie3/4) is running and visible, and not visible when ie3/4 is either not running or more importantly, not visible.... i.e. it's practically part of the ie3/4 window for all intents and purposes. If someone could give me a few pointers on how to find out whether a window is minimised or not, and if it's an ie3/4 window, that would be much appreciated.

Also, is it possible find what colour is at a particular point on a window in delphi 2?

Much thanks,
Matt
0
Comment
Question by:mattg072998
[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
  • 3
  • 3
  • 3
9 Comments
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358982
function GetWindowPlacement(Wnd: HWnd; Placement: PWindowPlacement): Bool;

TWindowPlacement = record
  length: Word;
  flags: Word;
  showCmd: Word;
  ptMinPosition: TPoint;
  ptMaxPosition: TPoint;
  rcNormalPosition: TRect;
end;

c help 4 API.

Black Death.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358983
mattg!

sorry, i didn't mean 2 answer, i just wanted 2 comment.
please reject, even if accepted.

Black Death.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1358984
I just figured out an answer to your question ... here it is...
Put this procedure in OnTimer()
{**********************************************}
procedure TForm1.Timer1Timer(Sender: TObject);
var hNotepad: HWND;
begin
  hNotepad := FindWindow('Notepad',nil);
  if IsWindowVisible(hWin) = true then
    ShowWindow(handle,SW_SHOW) else
      ShowWindow(handle,SW_HIDE);
end;
{**********************************************}
Since I've deleted InternetExplorer I tried it with Notepad and it works....

Regards,
Viktor Ivanov

0
Industry Leaders: 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!

 
LVL 10

Expert Comment

by:viktornet
ID: 1358985
OOOpppppssss....A little mistake..This would be like this....
     {**********************************************}
     procedure TForm1.Timer1Timer(Sender: TObject);
     var hNotepad: HWND;
     begin
       hNotepad := FindWindow('Notepad',nil);
       if IsWindowVisible(hNotepad) = true then {  <<<- After I tried the if this works I've changed            the code so you know what's going on...but I forgot to change all names...well here it is...}
         ShowWindow(handle,SW_SHOW) else
           ShowWindow(handle,SW_HIDE);
     end;
     {**********************************************}
0
 

Author Comment

by:mattg072998
ID: 1358986
Thanks viktornet and blackdeath for solutions and comments.

I'll reopen the question so viktornet can get the points, which is what i assume you were asking for, blackdeath.

Anyone have any quick tips for the second small question?
0
 
LVL 10

Accepted Solution

by:
viktornet earned 150 total points
ID: 1358987
Ok, then....the answer is up there....Ok let me put it again..

procedure TForm1.Timer1Timer(Sender: TObject);
          var hNotepad: HWND;
          begin
            hNotepad := FindWindow('Notepad',nil);
            if IsWindowVisible(hNotepad) = true then
              ShowWindow(handle,SW_SHOW) else
                ShowWindow(handle,SW_HIDE);
          end;
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1358988
hi, mattg.

which 1 do u put in2 action?
i'm just asking cos i'd like 2 know if mine is handy in case i should need something like that, 2. otherwise i'd use vik's.

Black Death.
0
 

Author Comment

by:mattg072998
ID: 1358989
I'm using an adapted version of viktor's, because I wasn't sure how to properly implement your suggestions.

I've adapted viktor's because IsWindowVisible was not quite what i wanted. Instead, i'm using:

hWindow := WindowFromPoint(point);

to determine which window is on top at a particular point. Unfortunately, i'm finding that different points on the same application return different hWnd values. I'm not sure why, although i have a suspicion that it is something to do with child windows or similar. But then again i may be totally wrong, because i'm not exactly familiar with the winapi :)

I was thinking another solution may be to change the Z order of windows, so that the toolbar always stays on top of any Internet Explorer windows.
0
 

Author Comment

by:mattg072998
ID: 1358990
here is the code i've decided on using for anyone still interested. It is adapted from viktor's idea, thanks for the pointers everyone. Try it on notepad, it works well, even with multiple instances. All I have to do is convert it to internet explorer for it to fulfil its original purpose.

procedure TformMain.Timer1Timer(Sender: TObject);
var
   hNotepad: HWND;
   hWindow: HWND;

begin
   hWindow := GetForegroundWindow();
   hNotepad := FindWindow('Notepad',nil);

   if ((hWindow = hNotepad) AND (NOT(IsIconic(hNotepad)))) then
       ShowWindow(handle, SW_SHOWNOACTIVATE);
   else
       ShowWindow(handle,SW_HIDE);
end;


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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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