D
DF7C3
Unregistered / Unconfirmed
GUEST, unregistred user!
我想让程序只运行一份,于是写了如下代码。问题是当主窗体最小化以后,如果再次运行程序,主窗体并不能显示到前面来,因为IsIconic(HWindow)永远返回False,后面那一句SendMessage无法执行!请问这是怎么回事,如何解决?program Project1;uses Forms, Windows, Messages, MyUnit_MDIParent in 'MyUnit_MDIParent.pas' {My_MDIParent};{$R *.res}var HWindow: THandle;begin Application.Initialize; HWindow := FindWindow('TMy_MDIParent', 'My_MDIParent'); if HWindow <> 0 then begin if IsIconic(HWindow) then begin SendMessage(HWindow, WM_SYSCOMMAND, SC_RESTORE, 0); end; SetForeGroundWindow(HWindow); Application.Terminate; Exit; end; Application.Title := 'My_MDIParent'; Application.CreateForm(TMy_MDIParent, My_MDIParent); Application.Run;end.