■■■■■如何将文字写到屏幕上,而且处于最前端,就像是调节显示器设置时显示的那样? 如何将文字写到屏幕上,而且处于最前端,就像是调节显示器设置时显示的那样?最好不是写在透明窗体上的那种,因为弹出窗体的时候可能会导致其他窗体失去焦点!我想要实现的是直接利用显示器的编程接口来写屏幕。如何做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如hdc = CreateDC (TEXT ("DISPLAY"), NULL, NULL, NULL)取得屏幕句柄 ... 其它程序行...DeleteDC (hdc) ; 如果要捕获键盘,可用hook技术,这方面的内容网上很多 用了TransForm控件unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, TransForm, StdCtrls, ExtCtrls;type TForm1 = class(TForm) TranForm1: TTranForm; Button1: TButton; Timer1: TTimer; Button2: TButton; Label1: TLabel; procedure FormPaint(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormPaint(Sender: TObject);var hdc: THandle;begin hdc := GetDC(Handle); if hdc <> 0 then begin TextOut(hdc, 20, 20, 'Front Text Example', 18); end; ReleaseDC(Handle, hdc);end;procedure TForm1.Button1Click(Sender: TObject);begin Close();end;procedure TForm1.Timer1Timer(Sender: TObject);begin if Left < 0 then Left := Left + 10000; SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);end;procedure TForm1.Button2Click(Sender: TObject);begin Left := Left - 10000;end;end. object Form1: TForm1 Left = 388 Top = 328 BorderIcons = [] BorderStyle = bsNone ClientHeight = 130 ClientWidth = 174 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnPaint = FormPaint PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 64 Top = 48 Width = 32 Height = 13 Caption = 'Label1' end object Button1: TButton Left = 104 Top = 80 Width = 49 Height = 25 Caption = 'Close' TabOrder = 0 OnClick = Button1Click end object Button2: TButton Left = 24 Top = 80 Width = 49 Height = 25 Caption = 'Hide' TabOrder = 1 OnClick = Button2Click end object TranForm1: TTranForm AlphaValue = 180 TransMouse = False Left = 160 Top = 64 end object Timer1: TTimer Interval = 5000 OnTimer = Timer1Timer Left = 40 Top = 16 endend 用ALWAYSONTOP窗口PS:此贴转移到VC区 使用一个部分透明的窗口在 2000 和 XP 系统中,可以使用 WS_EX_LAYERED 风格加上 UpdateLayeredAttribute 来完成 求解思路 (自由画笔的结构体设计) winpcap 关于bogus savefile header的问题 请问带有事件的普通COM怎么使用 关于用线程来控制进度条的问题 关于vc60.pdb的问题 图像保存 closesocket()遇到WSAEINPROGRESS的情况怎么才能让它关闭? typeid是什么东西 谁帮我看看这段代码什么意思?typedef这样用是什么用法?谢谢! 在设备管理器中,监视器是什么意思? CS模式到BS模式??? VS2003里面怎么实现每编译一次版本号自动 加1
hdc = CreateDC (TEXT ("DISPLAY"), NULL, NULL, NULL)取得屏幕句柄
...
其它程序行
...
DeleteDC (hdc) ;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
TransForm, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
TranForm1: TTranForm;
Button1: TButton;
Timer1: TTimer;
Button2: TButton;
Label1: TLabel;
procedure FormPaint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormPaint(Sender: TObject);
var
hdc: THandle;
begin
hdc := GetDC(Handle);
if hdc <> 0 then
begin
TextOut(hdc, 20, 20, 'Front Text Example', 18);
end;
ReleaseDC(Handle, hdc);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Close();
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Left < 0 then
Left := Left + 10000;
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Left := Left - 10000;
end;end.
Left = 388
Top = 328
BorderIcons = []
BorderStyle = bsNone
ClientHeight = 130
ClientWidth = 174
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnPaint = FormPaint
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 64
Top = 48
Width = 32
Height = 13
Caption = 'Label1'
end
object Button1: TButton
Left = 104
Top = 80
Width = 49
Height = 25
Caption = 'Close'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 24
Top = 80
Width = 49
Height = 25
Caption = 'Hide'
TabOrder = 1
OnClick = Button2Click
end
object TranForm1: TTranForm
AlphaValue = 180
TransMouse = False
Left = 160
Top = 64
end
object Timer1: TTimer
Interval = 5000
OnTimer = Timer1Timer
Left = 40
Top = 16
end
end
PS:此贴转移到VC区
在 2000 和 XP 系统中,可以使用 WS_EX_LAYERED 风格加上 UpdateLayeredAttribute 来完成