Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Findwindow?

Posted on 1999-07-23
12
Medium Priority
?
512 Views
Last Modified: 2010-04-04
Hi,
A simple question, so here is only 5 points. ^_^
For examples, THREE windows with the same caption and same class.  I used the following code:
ShowWindow(FindWindow(pchar('Caption'),pchar('ClassHere')),SW_HIDE);
Even execute the above code three times, I can still only hide one of them, how can I hide ALL of them?  And if I want to hide only two of them, how can I do so?
PS.  Full source codes required.
0
Comment
Question by:yingkit
[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
  • 4
  • 3
  • 2
  • +3
12 Comments
 
LVL 2

Expert Comment

by:kotik
ID: 1390709
Try to use EnumWindows function.
0
 

Author Comment

by:yingkit
ID: 1390710
Edited text of question.
0
 
LVL 2

Expert Comment

by:kotik
ID: 1390711
Full source for 5 points? :))
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 1

Expert Comment

by:m_adil
ID: 1390712
hehehe
sounds good ;)
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1390713
var
  bCount: Byte;

function MyEnumWindowsProc(h: HWND; p: Longint): longBool; stdcall;
begin
  GetWindowText(h, @WinCaption[0], 100);
  if StrPas(@WinCaption[0]) = 'Rechner' then begin
    Inc(bCount);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  li: Longint;
begin
  bCount := 0;
  EnumWindows(@MyEnumWindowsProc, li);
  MessageDlg('found ' + IntToStr(bCount) + ' times', mtInformation,
    [mbOk], 0);
end;

this one counts the instances of the calculator (in german: 'Rechner') -

in MyEnumWindowsProc u can do whatever u wanna do with the found window.

i think this should b enough 4 5 points. figure out what's to b done now by yourself or adjust the points.

;-)

BlackDeath.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1390714
ok, ok - var WinCaption: array[0..99] of Char;

;-))

BlackDeath.
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1390715
I like your answer. I used a list box to store the window captions. I only had a two programs running. There was about 100 items. Wow.
0
 

Author Comment

by:yingkit
ID: 1390716
Hee....thank BlackDeath for the answers.  You may submit your comments as answer, I'll increase the points and grade it.
Thanks!
0
 
LVL 17

Expert Comment

by:inthe
ID: 1390717
>>I only had a two programs running. There was about 100 items. Wow

hi calvin,
once i did a postmessage with wm_syscommand and scminimize in  a loop and used the wrong handle for sending.you should have seen all the windows that appeared in the taskbar ..
its amazing how many there are when even nothing running :-)
0
 
LVL 1

Accepted Solution

by:
BlackDeath earned 60 total points
ID: 1390718
no prob.
;-)
BlackDeath.
0
 

Author Comment

by:yingkit
ID: 1390719
Adjusted points to 20
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1390720
-'B'-?
0

Featured Post

Technology Partners: 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

670 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