冥界3大法王 发表于 2021-10-2 18:41

为啥报错呢?

unit 读取写入ini_3;



interface



uses

Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,

System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,

Vcl.StdCtrls;



type

TForm3 = class(TForm)

    GroupBox1: TGroupBox;

    Label6: TLabel;

    Edit1: TEdit;

    Label1: TLabel;

    Edit2: TEdit;

    Label2: TLabel;

    Edit3: TEdit;

    Label3: TLabel;

    Edit4: TEdit;

    Label4: TLabel;

    Edit5: TEdit;

    procedure hotykey(var msg: TMessage); message WM_HOTKEY;

    procedure FormCreate(Sender: TObject);

    procedure FormDestroy(Sender: TObject);

private

    { Private declarations }

public

    { Public declarations }

end;



var

Form3: TForm3;

idF1: Integer;



implementation



{$R *.dfm}



procedure TForm3.FormDestroy(Sender: TObject);

begin

UnRegisterHotKey(handle, idF1);

end;



procedure TForm3.hotykey(var msg: TMessage);

var

F: string;

begin

if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(VK_F1) < 0) then

begin

//    ShowMessage('Ctrl+Shift+F1');

    F := ActiveControl.Name;

    ShowMessage(F);                                    

    Edit3.Text := F + '_' + Edit3.Text;            ================================》就这里,不设热键也没事发生啊~~ 想不通呢?

end;

end;



procedure TForm3.FormCreate(Sender: TObject);

begin

idF1 := GlobalAddAtom('hotkeyF1');

RegisterHotKey(handle, idF1, MOD_CONTROL + MOD_SHIFT, VK_F1);

end;



end.

冥界3大法王 发表于 2021-10-2 18:43

哈哈,我想明白了。得在主Form1里设用,3号Form没出来,当然烦病了。
页: [1]
查看完整版本: 为啥报错呢?