下面是源代码,我是想注册两个热键,一个是ALt+F12来实现隐藏后窗体的显示,另外一个是Ctrl+C来实现当在别的地方拷贝了一些文字的时候,程序当中可以通过剪切板把这段文字读到一个memo中去,第一个是别人给的源码,可以实现了,然后我自己比着葫芦画瓢就是画不出来!也不报错,也不显示,根本没有动静。希望各位高手告知原因!
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls,clipbrd;type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    c:tclipboard;
  aatom:atom;
  procedure hotkey(var msg:tmessage);message wm_hotkey;
  procedure copy(var msg:tmessage);message WM_COPY;
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.hotkey(var msg:tmessage);
begin
  if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT)  then
    begin
      self.Show;
      if self.WindowState=wsMinimized then
        self.WindowState:=wsNormal;
        SetForegroundWindow(Handle);
    end;
end;procedure tform1.copy(var msg:tmessage);begin
  if (msg.LParamHi =67) and (msg.LParamLo =mod_control) then
    begin
      self.Show ;
      self.Memo1.Text:=c.AsText;
    end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
      c:=tclipboard.Create;  aatom:=globaladdatom('hotkey');
  RegisterHotKey(handle,aatom,MOD_ALT,vk_F12);
  aatom:=globaladdatom('copy');
  registerhotkey(Handle,aatom,MOD_CONTROL,67);end;procedure TForm1.Button1Click(Sender: TObject);
begin
  self.Hide;
end;end.

解决方案 »

  1.   

    ctrl+C不用你自搞,windows自带的!!!
      

  2.   

    是这样的。我想达到这种效果!
    程序在后台运行,在别的地方譬如写字板里面操作,如果我按了Ctrl+C或者别的热键,这个时候程序就会把剪切板里面的东西读出来,然后显示到一个memo里面.并不是在本窗体操作.
      

  3.   

    晕,有wm_copy吗?ctrl+c也是热键,也应该是用wm_hotkey的消息处理函数才对吧.下面这样试试看
    procedure TForm1.hotkey(var msg:tmessage);
    begin
      if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT)  then
        begin
          self.Show;
          if self.WindowState=wsMinimized then
            self.WindowState:=wsNormal;
            SetForegroundWindow(Handle);
        end;
     if (msg.LParamHi =67) and (msg.LParamLo =mod_control) then
        begin
          self.Show ;
          self.Memo1.Text:=c.AsText;
          msg.result:1;//该消息已处理
        end;
    end;