?
Solved

Reading Windows States

Posted on 1998-07-29
9
Medium Priority
?
151 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 450 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

741 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