需要一个截取活动窗口标题的Delphi空间 请教一下用什么空间可以用来监视当前桌面活动窗口标题,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不用控件,调用APIunit CapWinU;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;type TForm1 = class(TForm) ListBox1: TListBox; Timer1: TTimer; Button1: TButton; Button2: TButton; Button3: TButton; Edit1: TEdit; procedure Timer1Timer(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}var scrdc: HDC;procedure TForm1.Timer1Timer(Sender: TObject);var hwnd: THandle; buf: array [0..127] of Char; winclass: string; wintitle: string;begin hwnd := GetForegroundWindow(); if GetClassName(hwnd, buf, 127) > 0 then begin winclass := StrPas(buf); if GetWindowText(hwnd, buf, 127) > 0 then wintitle := StrPas(buf) else wintitle := ''; winclass := winclass + '(' + wintitle + ')'; end; if winclass = '' then winclass := '######'; if ListBox1.Items.Indexof(winclass) < 0 then ListBox1.Items.Add(winclass); if scrdc <> 0 then begin FillRect(scrdc, Rect(200, 0, 600, 32), COLOR_WINDOW+1); TextOut(scrdc, 220, 8, @winclass[1], Length(winclass)); end;end;procedure TForm1.Button1Click(Sender: TObject);begin ListBox1.Items.Clear();end;procedure TForm1.Button2Click(Sender: TObject);begin if ListBox1.ItemIndex >= 0 then ListBox1.Items.Delete(ListBox1.ItemIndex);end;procedure TForm1.Button3Click(Sender: TObject);begin ListBox1.Items.SaveToFile(Edit1.Text); end;procedure TForm1.FormCreate(Sender: TObject);begin scrdc := GetDC(0);end;procedure TForm1.FormDestroy(Sender: TObject);begin if scrdc <> 0 then ReleaseDC(0, scrdc);end;end. 查询语句问题? 保存时候报错 数据统计问题? ADOconnect怎么自定义,设置参数,连接数据库mssql 在线等待...急用啊 如何使用 group by?■■■■■ 这段代码到底哪里有错? 实际课题碰到的难题,请有兴趣的朋友帮忙解决,非常感谢。。。 进度条显示问题 idhttp.get不了验证码 "Can't Make a Visible Window Modal" 这种现象怎样处理?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
ListBox1: TListBox;
Timer1: TTimer;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
var
scrdc: HDC;procedure TForm1.Timer1Timer(Sender: TObject);
var
hwnd: THandle;
buf: array [0..127] of Char;
winclass: string;
wintitle: string;
begin
hwnd := GetForegroundWindow();
if GetClassName(hwnd, buf, 127) > 0 then
begin
winclass := StrPas(buf);
if GetWindowText(hwnd, buf, 127) > 0 then
wintitle := StrPas(buf)
else
wintitle := '';
winclass := winclass + '(' + wintitle + ')';
end;
if winclass = '' then
winclass := '######';
if ListBox1.Items.Indexof(winclass) < 0 then
ListBox1.Items.Add(winclass);
if scrdc <> 0 then
begin
FillRect(scrdc, Rect(200, 0, 600, 32), COLOR_WINDOW+1);
TextOut(scrdc, 220, 8, @winclass[1], Length(winclass));
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Clear();
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if ListBox1.ItemIndex >= 0 then
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;procedure TForm1.Button3Click(Sender: TObject);
begin
ListBox1.Items.SaveToFile(Edit1.Text);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
scrdc := GetDC(0);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
if scrdc <> 0 then
ReleaseDC(0, scrdc);
end;end.