yingkit
asked on
Findwindow?
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(pcha r('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.
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(pcha
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.
Try to use EnumWindows function.
ASKER
Edited text of question.
Full source for 5 points? :))
hehehe
sounds good ;)
sounds good ;)
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(@MyEnumWindows Proc, 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.
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
var
li: Longint;
begin
bCount := 0;
EnumWindows(@MyEnumWindows
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.
ok, ok - var WinCaption: array[0..99] of Char;
;-))
BlackDeath.
;-))
BlackDeath.
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.
ASKER
Hee....thank BlackDeath for the answers. You may submit your comments as answer, I'll increase the points and grade it.
Thanks!
Thanks!
>>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 :-)
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 :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Adjusted points to 20
-'B'-?