菜鸟求教:窗口问题`~也可能是sendmessage的问题`~(100分)

  • 主题发起人 主题发起人 lovewh119
  • 开始时间 开始时间
L

lovewh119

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp;自己写了一个当程序窗口最小化时应用程序不出现在Windows的任务栏上的事件,然后通过<br>托盘图标事件来把窗口恢复时,怎么也恢复不了,那位高手指点一下吧`~<br>unit Unit1;<br>interface<br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, Menus, TrayIcon, StdCtrls;<br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; TrayNotifyIcon1: TTrayNotifyIcon;<br>&nbsp; &nbsp; `~<br>&nbsp; &nbsp; `~ &nbsp;<br>&nbsp; private<br>&nbsp; &nbsp; procedure WMSYSCOMMAND(var Msg: Tmessage); message WM_SYSCOMMAND;<br>&nbsp; `~`````<br>implementation<br><br>{$R *.dfm}<br>procedure Tform1.WMSYSCOMMAND(var Msg: Tmessage); //处理message WM_SYSCOMMAND;<br>begin<br>&nbsp; if msg.WParam=SC_MINIMIZE then //当要最小化窗口时<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; self.Hide;<br>&nbsp; &nbsp; &nbsp; SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; // 使应用程序不不不出现在Windows的任务栏上<br>&nbsp; &nbsp; &nbsp; self.Show;<br>&nbsp; &nbsp; &nbsp; TrayNotifyIcon1.IconVisible:=true;<br>&nbsp; &nbsp; end;<br>&nbsp; inherited;<br>end;<br>`~~```````<br>procedure TForm1.showClick(Sender: TObject);<br>begin<br>&nbsp; form1.Show;<br>&nbsp; sendmessage(application.Handle,SC_RESTORE,0,0);<br>&nbsp; //TrayNotifyIcon1.IconVisible:=false;<br>&nbsp;end;<br>end.<br>反正我怎么sendmessage都无法恢复窗口,哪位高手指点一下吧`~<br>
 
我来拣分!<br>不要用消息,消息不一定可靠,用函数就行!<br>&nbsp; 把sendmessage(application.Handle,SC_RESTORE,0,0);<br>&nbsp;改成 &nbsp;ShowWindow(Application.Handle,SW_RESTORE);<br>&nbsp;肯定行!
 
同意,或application.Restore
 
begin<br>&nbsp; form1.Show;<br>&nbsp; sendmessage(application.Handle,SC_RESTORE,0,0);<br>&nbsp; //TrayNotifyIcon1.IconVisible:=false;<br>&nbsp;end;<br>改成<br>  form1.show;<br>&nbsp; &nbsp; SetForegroundWindow(form1.handle);<br>&nbsp; &nbsp;
 
接受答案,并谢谢各位了`~
 

Similar threads

后退
顶部