再问一个!如何把一个程序从前台切到后台???(100分)

  • 主题发起人 主题发起人 cheng527
  • 开始时间 开始时间
C

cheng527

Unregistered / Unconfirmed
GUEST, unregistred user!
如何把一个程序从前台切到后台???
在用热键把他从后台切到前台??
有人会吗??
 
------热键
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,mmsystem,
StdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
hotkeyid :integer;
procedure WMhotkeyhandle(var msg:Tmessage);
message wm_hotkey; //响应敏感键按键消息
public
{ Public declarations }
end;

var
Form1: TForm1;
showit:boolean=false;
implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
hotkeyid:=GlobalAddAtom(pchar('UserDefineHotKey'))-$C000;
//减去$C000是为了保证取值范围的限制
registerhotkey(handle,hotkeyid,MOD_CONTROL+MOD_ALt,$41);
//敏感键为ctrl+Alt+A
end;
procedure TForm1.Wmhotkeyhandle(var msg:Tmessage);
begin
if (msg.LParamHi=$41)then
begin
msg.Result:=1; //该消息已经处理
if showit then begin
Form1.Show;
showit:=false;
end
else
begin
form1.Hide;
showit:=true;
end;
//把窗口最前面显示
end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
unregisterhotkey(handle,hotkeyid);
DeleteAtom(HotKeyID);
end;

end.
 
我有个把程序从后台放到前台的程序,你看看吧,自己改改
procedure TfrmMain.RestoreRequest(var message: TMessage);
begin

if IsIconic(Application.Handle) = TRUE then
Application.Restore
else
Application.BringToFront;



end;


//--------------------------
var
hWndPrev:HWND;

hWndPrev:=FindWindow('TfrmMain',nil);//把TfrmMain改成你的
PostMessage(hwndPrev, CM_RESTORE, 0, 0);

//另外,还有一个showform方法,你自己查查帮助吧
 
我试试先!!!

你能解决一下这个问题吗》??

http://www.delphibbs.com/delphibbs/dispq.asp?lid=1407454
 
后退
顶部