使用SetForeGroundWindow后,窗口不能最小化,如何处理?(100分)

  • 主题发起人 主题发起人 kofxdm
  • 开始时间 开始时间
K

kofxdm

Unregistered / Unconfirmed
GUEST, unregistred user!
var<br>&nbsp; mHandle, fHandle: THandle;<br>begin<br>&nbsp; Application.Initialize;<br>&nbsp; Application.Title := '控制中心';<br>&nbsp; Application.HelpFile := '';<br>&nbsp; mHandle := CreateMutex(nil, True, '控制中心');<br>&nbsp; if mHandle &lt;&gt; 0 then <br>&nbsp; begin <br>&nbsp; &nbsp; if GetLastError = ERROR_ALREADY_EXISTS then<br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; fHandle := FindWindow(PChar('TfrmCenter'), nil);<br>&nbsp; &nbsp; &nbsp; //BringWindowToTop(fHandle);<br>&nbsp; &nbsp; &nbsp; ShowWindow(fHandle, SW_RESTORE );<br>&nbsp; &nbsp; &nbsp; SetForeGroundWindow(fHandle);<br>&nbsp; &nbsp; &nbsp; ReleaseMutex(mHandle);<br>&nbsp; &nbsp; &nbsp; Halt;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; Application.CreateForm(TfrmCenter, frmCenter);<br>&nbsp; Application.Run;<br>end.<br>使用上面的代码,程序最小化后,再次执行,这时主窗口恢复原窗口大小,并且置在最前面,但是,此时窗口的最小化按钮不起作用,如何改进?
 
取得Application.Handle后,如下判断。<br>if IsIconic(AppWnd) then<br>&nbsp; &nbsp;ShowWindow(Appwnd,SW_RESTORE)//假如缩小为图标,恢复原大小<br>else<br>&nbsp; &nbsp;SetForegroundWindow(AppWnd);//否则,到最前面来 <br>
 
后退
顶部