谁帮我把这段VB代码翻译成delphi吗?(50)

  • 主题发起人 主题发起人 eye0eye
  • 开始时间 开始时间
E

eye0eye

Unregistered / Unconfirmed
GUEST, unregistred user!
Dim WithEvents hk As cHotKeyPrivate Sub Form_Load() Set hk = New cHotKey With hk .frmHwnd = cmdExit.hWnd '指定接收热键消息的句柄 .AddHotKey 36 '指定热键 .AddHotKey 35 '指定热键 .StartHotKeys Timer1 '启动热键捕捉过程 End Withen
d Sub
 
雾水一头[:(!]
 
cHotKey是个VB的第三方类库吧?Delphi下说不定没有这个类库的……orz
 
没有,delphi使用api函数来设置热键的。拷贝一下别人代码:--------------------------------------------把ALT+F4定义成自己程序的热键.参考以下代码:unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private { Private declarations } procedure HotKeyDown(var Msg: Tmessage);
message WM_HOTKEY;
{ Private declarations } public { Public declarations } end;
var Form1: TForm1;
HotKeyId: Integer;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
HotKeyId := GlobalAddAtom('HotKey') - $C000;
RegisterHotKey(Handle, hotkeyid, Mod_Alt, VK_F4);
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
UnRegisterHotKey(handle, HotKeyId);
end;
procedure TForm1.HotKeyDown(var Msg: Tmessage);//热键处理程序。begin
if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then
begin
SHOWMESSAGE('AA');
end;
end;
end.
 
Dim WithEvents hk As cHotKey'这里是给一个已存在的类定义一个对象Private Sub Form_Load() Set hk = New cHotKey'建立对象实例 '以下的是使用类中的方法,因为没有类,很难解释它在干什么 With hk .frmHwnd = cmdExit.hWnd '指定接收热键消息的句柄 .AddHotKey 36 '指定热键 .AddHotKey 35 '指定热键 .StartHotKeys Timer1 '启动热键捕捉过程 End Withen
d Sub
 
后退
顶部