1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| class procedure TNotifyTaskBarXXXForm.Popup();
function FindAllWindow(const ClassName, WindowName: string; Index: Integer = 0): THandle;
var
HandleFound, Parent: THandle;
lpRes : array[0..256] of Char;
StrClass: string;
StrCaption: string;
iChild: Integer;
lpClassName, lpWindowName: PChar;
begin
Result := 0;
iChild := -1;
if Trim(ClassName) <> '' then lpClassName := PChar(ClassName) else lpClassName := nil;
if Trim(WindowName) <> '' then lpWindowName := PChar(WindowName) else lpWindowName := nil;
Parent := GetActiveWindow(); // Peu Importe c'est quoi, on rebalaye tout !
HandleFound := GetWindow(Parent, GW_HWNDFIRST);
while HandleFound > 0 do
begin
GetClassName(HandleFound, lpRes, SizeOf(lpRes));
StrClass := lpRes;
GetWindowText(HandleFound, lpRes, SizeOf(lpRes));
StrCaption := lpRes;
if ((ClassName = '') or SameText(ClassName, StrClass)) and ((WindowName = '') or SameText(WindowName, StrCaption)) then
begin
Inc(iChild);
if iChild >= Index then begin
Result := HandleFound;
Exit;
end;
end;
HandleFound := GetWindow(HandleFound, GW_HWNDNEXT);
end;
end;
var
Index: Integer;
Handle: THandle;
begin
Index := 0;
repeat
Handle := FindAllWindow(ClassName, '', Index);
Inc(Index);
SendMessage(Handle, WM_MYTOPEVENT, 0, 0);
until Handle <= 0;
end; |
Partager