问题发现了,这个程序在WIN2000下能行,但在XP下不行。但又有个问题看代码:界面隐藏了却无法还原,帮忙看看:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> procedure FormCreate(Sender: TObject);<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> private<br> procedure HotKeyDown(var Msg:Tmessage);message WM_HOTKEY;<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br>var<br> Form1: TForm1;<br> HotKeyid,HotKeyid1,HotKeyid2:Integer;<br> pHwnd:Hwnd;<br> style,exstyle:longint;<br> devmode1
EVMODE;<br><br>implementation<br>uses Math;<br>{$R *.dfm}<br><br><br>procedure TForm1.FormCreate(Sender: TObject);<br><br>begin<br> HotKeyid:=GlobalAddAtom('MyHotKey')-$C00;<br> [red]RegisterHotKey(Handle,HotKeyid1,0,VK_F9);<br> RegisterHotKey(Handle,HotKeyid2,0,VK_F10);<br> RegisterHotKey(Handle,HotKeyid,0,VK_F11);[/red]<br><br>end;<br>procedure TForm1.HotKeyDown(var Msg:Tmessage);<br>begin<br> if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F11) then<br> begin<br> pHwnd:=GetForegroundWindow();<br> if EnumDisplaySettings(0,0,devmode1) then<br> begin<br> devmode1.dmPelsWidth:=1024;<br> devmode1.dmPelsHeight:=768;<br> devmode1.dmBitsPerPel:=32;<br> devmode1.dmDisplayFrequency:=75;<br> ChangeDisplaySettings(devmode1,0);<br> end;<br> style:=GetWindowLong(pHwnd,GWL_STYLE);<br> style:=WS_OVERLAPPEDWINDOW or WS_VISIBLE ;<br> SetWindowLong(pHwnd,GWL_STYLE,style);<br> exstyle:=GetWindowLong(pHwnd,GWL_EXSTYLE);<br> exstyle:=WS_EX_APPWINDOW or WS_EX_WINDOWEDGE;<br> SetWindowLong(pHwnd,GWL_EXSTYLE,exstyle);<br> SetWindowPos(pHwnd,HWND_NOTOPMOST,0,0,800,600,SWP_SHOWWINDOW);<br> ShowWindow(pHwnd,SW_SHOWNORMAL);<br> end;<br> if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F10) then<br> ShowWindow(pHwnd,SW_HIDE);<br> [red] if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F9) then<br> ShowWindow(pHwnd,SW_RESTORE);[/red]<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> UnRegisterHotKey(handle,HotKeyid);<br>end;<br><br>end.