请问如何在程序中加入一个Alt+F8 就可以实现程序(窗体from1)的隐藏
源代码是什么 我需要最简单的一种方法
本人是初学者,希望可以比较详细说明!
谢谢!
源代码是什么 我需要最简单的一种方法
本人是初学者,希望可以比较详细说明!
谢谢!
解决方案 »
- 开始激情了,先问个问题...
- 帮帮忙 修改下
- 帮忙messagedlg('发送失败!',mterror,[mbyes],0)
- 如何在自己的程序里创建wps对象,用wps对象来完成打开,另存为和关闭等操作.大家来帮帮忙!
- 请问一下,哪里能有delphi的中文帮助文档下载?
- 版主,让我借这里问个问题吧,哪里有联想功能的拼音下载?打完一个“电”字,自动出来选择让你选“话”“脑”“视”等,就象手机一样,这
- 会者不难,make file的问题
- 怎样写自动关机程序
- 自定义控件问题
- 文件叠加(如何将两文件合并,如何在合并后分离)
- 【Delphi爱好者大聚会,欢迎大家加入delphi技术讨论群】
- 我的运行时包缺少动态链接库???
Shift: TShiftState);
begin
if (key = VK_F8) and (Shift = [ssAlt]) then
form1.Hide;end;
设置窗口的
KeyPreview 属性为 true;
======================================
應該是Alt+F8吧?
http://community.csdn.net/Expert/topic/4571/4571807.xml?temp=.341778和楼主提到的一样。
另:楼上的那位提到
http://community.csdn.net/Expert/topic/4571/4571807.xml?temp=.341778
这里只实现了运行隐藏程序,但是呼出后怎么再次隐藏呢?源代码如下请会的帮我写一下再次按下F2隐藏程序的代码 谢谢了!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
FHotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
FHotKeyId := GlobalAddAtom('MyHotKey') - $C000;
RegisterHotKey(Handle, FHotKeyId, MOD_CONTROL, VK_F2);
end;procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = MOD_CONTROL) AND (Msg.LParamHi = VK_F2) then // 假设热键为ALT+F8
begin
ShowWindow(Application.Handle, SW_SHOW);
ShowWindow(Self.Handle, SW_SHOW);
if IsIconic(Application.Handle) then
ShowWindow(Application.Handle, SW_RESTORE)
else
SetForegroundWindow(Application.Handle);
end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, FHotKeyId);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
ShowWindow(Self.Handle, SW_HIDE);
end;procedure TForm1.FormActivate(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
ShowWindow(Self.Handle, SW_HIDE);
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FHotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;
public
{ Public declarations }
end;var
Form1: TForm1;
showFlag: Boolean;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
FHotKeyId := GlobalAddAtom('MyHotKey') - $C000;
RegisterHotKey(Handle, FHotKeyId, MOD_CONTROL, VK_F2);
showFlag := true;
end;procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = MOD_CONTROL) AND (Msg.LParamHi = VK_F2) then
begin
if showFlag then
begin
ShowWindow(Application.Handle, SW_HIDE);
ShowWindow(Self.Handle, SW_HIDE);
end
else
begin
ShowWindow(Application.Handle, SW_SHOW);
ShowWindow(Self.Handle, SW_SHOW);
if IsIconic(Application.Handle) then
ShowWindow(Application.Handle, SW_RESTORE)
else
SetForegroundWindow(Application.Handle);
end;
showFlag := Not(showFlag);
end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, FHotKeyId);
end;end.