[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Reading Windows States

Posted on 1998-07-29
9
Medium Priority
?
155 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 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