Board logo

Subject: CnTrayIcon.pas的ShowApplication恢复仍然有问题 [Print This Page]

Author: yinsim    Time: 2012-6-6 11:13     Subject: CnTrayIcon.pas的ShowApplication恢复仍然有问题

新建一工程,加入CnTrayIcon控件, AutoHide=True; UseAppIcon=True,其余默认,为双击添加如下事件:

[Copy to clipboard]
CODE:
procedure TForm1.CnTrayIconDblClick(Sender: TObject);
begin
  if Application.MainForm.WindowState = wsMinimized then
    CnTrayIcon.ShowApplication
  else
    CnTrayIcon.HideApplication;
end;

在Windows XP/7/2008下面都无法正常还原窗口,表现为最小化的任务栏图标,需要鼠标再次点击才能恢复.

CnPack是否可以考虑在CnTrayIcon.pas添加多一行Application.BringToFront?

[Copy to clipboard]
CODE:
procedure TCnTrayIcon.ShowApplication;
begin
  ShowWindow(Application.Handle, SW_SHOW);
  Application.Restore;
  if Application.MainForm <> nil then
  begin
    if FSaveWindowState <> wsMinimized then
      Application.MainForm.WindowState := FSaveWindowState
    else
      Application.MainForm.WindowState := wsNormal;
    Application.MainForm.Show;
    Application.BringToFront;
  end;
end;


Author: Passion    Time: 2012-6-15 09:56

楼主在加了Application.BringToFront;后是否此问题就修复了?




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0