S
sy0116
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码中fbhandle和gothandle均为全局变量,可是,在使用中发现,fbhandle:=hd这一句是起作用的,而gothandle:='True';却不起作用,表现为每次按下热键时显示的gothandle值都是空的,而如果在FormCreate中加上gothandle:=‘false’的话显示的就是False,请问这是为什么?还有一小问:Boolean型如何转成String呢?
function getw(hd:HWND;aform:TForm1):Boolean;stdcall;
var
pid:dWord;
classname,title:array[0..255] of char;
begin
GetWindowText(hd,title,254);
if Pos('MyForm',title)<>0 then
begin
gothandle:='True';
fbhandle:=hd;
end
else
gothandle:='False';
Result:=True;
end;
procedure tform1.ONHotkey(var message:Tmessage);
begin
ShowMessage(gothandle);
if gothandle='False' then
begin
EnumWindows(@getw,0);
//……
end
else
begin
//……
end;
end;
function getw(hd:HWND;aform:TForm1):Boolean;stdcall;
var
pid:dWord;
classname,title:array[0..255] of char;
begin
GetWindowText(hd,title,254);
if Pos('MyForm',title)<>0 then
begin
gothandle:='True';
fbhandle:=hd;
end
else
gothandle:='False';
Result:=True;
end;
procedure tform1.ONHotkey(var message:Tmessage);
begin
ShowMessage(gothandle);
if gothandle='False' then
begin
EnumWindows(@getw,0);
//……
end
else
begin
//……
end;
end;