PDA

View Full Version : سوال: کپشن فرمهای فعال



Mask
سه شنبه 07 دی 1389, 17:18 عصر
با سلام
چطوری باید کپشن کلیه پنجره ها و فرمها که در سیستم بازه رو در یه ListBox ریخت.
ممنون.

Felony
سه شنبه 07 دی 1389, 17:38 عصر
میتونید از EnumWindows که یک CallBack Function هست استفاده کنید :

function EnumWindowsFunc(Handle: THandle; List: TStringList) : boolean ; stdcall;
var
Caption: array[0..256] of Char;
begin
if IsWindowVisible(Handle) then
if GetWindowText(Handle, Caption, GetWindowTextLength(Handle)+1) <> 0 then
List.Add(Caption);
result :=True;
end;
استفاده :

ListBox1.Clear;
EnumWindows(@EnumWindowsFunc, LParam(ListBox1.Items)) ;

این کد رو هم زمان جوونی نوشته بودم که همون کار رو میکنه :

var
Hand: THandle;
Str: Array [0..256] of char;
begin
Hand:= GetForegroundWindow;
Hand:= GetNextWindow(Hand, GW_HWNDFIRST);
while Hand <> GetNextWindow(Hand, GW_HWNDLAST) do
begin
if IsWindowVisible(Hand) then
if GetWindowText(Hand, Str, GetWindowTextLength(Hand)+1) <> 0 then
ListBox1.Items.Add(Str);
Hand:= GetNextWindow(Hand, GW_HWNDNEXT);
end;
end;