Delphi引入的单元文件(uses 部分) 有什么技巧知道它在哪个单元模块中?
例如下面的代码中:
unit Unit4;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.ComCtrls;
type
TForm4 = class(TForm)
HotKey: THotKey;
procedure CmdSetClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
HotKeyID: Integer;
procedure SetKey();
procedure HotKeyDown(var Msg: TWMHotKey); message WM_HOTKEY; //热键消息
public
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
uses
menus, inifiles;
procedure TForm4.FormCreate(Sender: TObject);
begin
SetKey; //注册热键
end;
procedure TForm4.FormDestroy(Sender: TObject);
begin
UnregisterHotKey(Handle, HotKeyID);
DeleteAtom(HotKeyID);
end;
procedure TForm4.HotKeyDown(var Msg: TWMHotKey);
begin
if (Msg.HotKey = HotKeyID) then
begin
//
end;
end;
procedure TForm4.SetKey();
var
Sc: TShortCut;
Modifiers, vk: Word;
Shift: TShiftState;
Str: string;
begin
{注册热键}
HotKeyID := GlobalAddAtom('HotKeyID') - $C000;
with TIniFile.Create('Config.ini') do
begin
Modifiers := 0;
vk := 0;
Str := ReadString('Config', 'CustomKey', 'Ctrl+F11');
if Str = '' then
Str := 'Ctrl+F11';
Sc := TextToShortCut(Str);
ShortCutToKey(Sc, vk, Shift);
if ssShift in Shift then
Modifiers := Modifiers or MOD_SHIFT;
if ssCtrl in Shift then
Modifiers := Modifiers or MOD_CONTROL;
if ssAlt in Shift then
Modifiers := Modifiers or MOD_ALT;
Free;
end;
UnregisterHotKey(Handle, HotKeyID);
RegisterHotKey(Handle, HotKeyID, Modifiers, vk);
end;
procedure TForm4.CmdSetClick(Sender: TObject);
var
F: TFrmSet;===> 这行报错了,我用CnPack的单元引入工具时,出来长长的ListBox选择这么多,我哪知是哪一个呢?有什么技巧吗?
我不认识它,它更不认识我
Ini: TIniFile;
BB: Boolean;
begin
F := TFrmSet.Create(self);
Ini := TIniFile.Create('Config.ini');
try
with F do
begin
//读到INI热键参数到 hotkey 控件中
HotKey.Hint := Ini.ReadString('Config', 'CustomKey', 'Ctrl+F11');
if HotKey.Hint = '' then
HotKey.Hint := 'Ctrl+F11';
HotKey.HotKey := TextToShortCut(HotKey.Hint);
HotKey.Hint := '';
if ShowModal = mrok then
begin
Ini.WriteString('Config', 'CustomKey', ShortCutToText(HotKey.HotKey)); //写入新的热键设置
SetKey; //生效新的热键
end;
end;
finally
Ini.Free;
F.Free;
end;
end;
end.
别跟我说 Ctrl+ 类型 点击
貌似没加 uses 类型的 ,它自己就不识认。{:301_981:} 你把整个工程打包传上来,我帮你解决问题 我是说整个工程
页:
[1]