Borland Delphi 窗口类核心问题,请大家进入讨论!!! (200分)

  • 主题发起人 主题发起人 pcexplorer
  • 开始时间 开始时间
P

pcexplorer

Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我从TForm继承的叫TAppFrm功能是更改系统菜单<br>(主要是Delphi写的程序都有个通病,就是系统菜单和标准<br>的不一样,太丑)<br>你可以发现在任务栏上单击右键弹出的系统菜单和标准的<br>是一样的,但问题来了当你从TAppFrm继承创建一个实例<br>如Form1在Form1上放一个Button,再创建一个实例<br>如Form2,Button的Click中<br>if not assigned(Form2) then<br>&nbsp; Form2:=TForm2.Create(self);<br>try<br>&nbsp; Form2.ShowModal;<br>finally<br>&nbsp; Form2.Free;<br>&nbsp; Form2:=nil;<br>end;<br>你可以首先使程序失去焦点然后在任务栏上单击该程序,问题<br>就出现在这里你发先主窗口Form1盖住了Form2由于是ShowModal<br>所以你的Form1是无法接受键盘和鼠标的,于是我想到了<br>CreateParams中的WndParent,我从TForm继承叫AppChildFrm<br>重载CreateParams.<br>将Params.WndParent:=Application.MainForm.Handle;<br>Modal Window问题解决,但是我又发现问题问题还有<br>当你在Form1上放置一个TOpenDialog用同样的方法发现<br>OpenDialog窗口到主窗口后面去了<br><br>先看看我的自定义类和测试程序<br>我是百思不得其解!!!<br><br>{这是一个封装标准Windows窗口的类,其中TAppFrm窗口类}<br>{是具有标准Windows风格主窗口类,TAppFrm窗口类必须和}<br>{TAppChildFrm窗口类一起使用}<br>unit AppWnd;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br><br>type<br>&nbsp; TAppFrm = class(TForm)<br>&nbsp; &nbsp; procedure CreateParams(var Params:TCreateParams);override;<br>&nbsp; private<br>&nbsp; &nbsp; procedure WMSysCommand(var Msg:TWMSysCommand);message WM_SYSCOMMAND;<br>&nbsp; &nbsp; procedure WMMenuSelect(var Msg:TWMMenuSelect);message WM_MENUSELECT;<br>&nbsp; &nbsp; procedure CreateAppWnd;<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; constructor Create(AOwner: TComponent); override;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; end;<br><br>{--------------------------------------------------------------}<br>&nbsp; TAppChildFrm = class(TForm)<br>&nbsp; &nbsp; procedure CreateParams(var Params:TCreateParams);override;<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; constructor Create(AOwner: TComponent); override;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; end;<br>{--------------------------------------------------------------}<br><br>implementation<br><br>{ TAppFrm }<br><br>constructor TAppFrm.Create(AOwner: TComponent);<br>begin<br>&nbsp; inherited;<br>&nbsp; CreateAppWnd;<br>end;<br><br>procedure TAppFrm.CreateAppWnd;<br>begin<br>&nbsp; SetWindowLong(Application.Handle,GWL_EXSTYLE,<br>&nbsp; &nbsp; &nbsp; &nbsp; GetWindowLong(Application.Handle,GWL_EXSTYLE) or WS_EX_TOOLWINDOW);<br>end;<br><br>procedure TAppFrm.CreateParams(var Params: TCreateParams);<br>begin<br>&nbsp; inherited CreateParams(Params);<br>&nbsp; Params.ExStyle:=WS_EX_APPWINDOW;<br>end;<br><br>destructor TAppFrm.Destroy;<br>begin<br>&nbsp; inherited;<br>&nbsp; //<br>end;<br><br>procedure TAppFrm.WMMenuSelect(var Msg: TWMMenuSelect);<br>begin<br>&nbsp; inherited;<br>&nbsp; with Application do<br>&nbsp; &nbsp; case Msg.IDItem of<br>&nbsp; &nbsp; &nbsp; SC_MINIMIZE :Hint:='将该窗口缩小为图标。';<br>&nbsp; &nbsp; &nbsp; SC_CLOSE &nbsp; &nbsp;:Hint:='关闭该窗口。';<br>&nbsp; &nbsp; &nbsp; SC_MAXIMIZE :Hint:='将该窗口扩大为全屏幕显示。';<br>&nbsp; &nbsp; &nbsp; SC_SIZE &nbsp; &nbsp; :Hint:='重新调整该窗口的尺寸。';<br>&nbsp; &nbsp; &nbsp; SC_MOVE &nbsp; &nbsp; :Hint:='移动该窗口。';<br>&nbsp; &nbsp; &nbsp; SC_RESTORE &nbsp;:Hint:='将该窗口恢复为正常大小。'<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; if Msg.MenuFlag = MF_SYSMENU then<br>&nbsp; &nbsp; &nbsp; &nbsp; Hint:='';<br>&nbsp; &nbsp; end;<br>end;<br><br>procedure TAppFrm.WMSysCommand(var Msg: TWMSysCommand);<br>begin<br>&nbsp; if Msg.CmdType=SC_MINIMIZE then<br>&nbsp; &nbsp; WindowState:=wsMinimized<br>&nbsp; else<br>&nbsp; &nbsp; inherited;<br>end;<br><br>{--------------------------------------------------------------}<br><br>{ TAppChildFrm }<br><br>constructor TAppChildFrm.Create(AOwner: TComponent);<br>begin<br>&nbsp; inherited;<br>&nbsp; //<br>end;<br><br>procedure TAppChildFrm.CreateParams(var Params:TCreateParams);<br>begin<br>&nbsp; inherited CreateParams(Params);<br>&nbsp; Params.WndParent:=Application.MainForm.Handle;<br>end;<br><br>destructor TAppChildFrm.Destroy;<br>begin<br>&nbsp; inherited;<br>&nbsp; //<br>end;<br><br>end.<br><br>{----------------------以下是我的测试程序-------------------------------}<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; if opendialog1.Execute then<br>&nbsp; begin<br>&nbsp; //<br>&nbsp; end;<br>end;<br><br>{在Form2中别忘了要引用我的AppWnd单元}<br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; if not Assigned(Form2) then<br>&nbsp; &nbsp; Form2:=TForm2.Create(self);//从我的AppChildFrm继承<br>&nbsp; try<br>&nbsp; &nbsp; Form2.ShowModal;<br>&nbsp; finally<br>&nbsp; &nbsp; Form2.Free;<br>&nbsp; &nbsp; Form2:=nil;<br>&nbsp; end;<br>end;<br><br>{不引用我的AppWnd单元}<br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>&nbsp; if not Assigned(Form3) then<br>&nbsp; &nbsp; Form3:=TForm3.Create(self);//直接从TForm创建<br>&nbsp; try<br>&nbsp; &nbsp; Form3.ShowModal;<br>&nbsp; finally<br>&nbsp; &nbsp; Form3.Free;<br>&nbsp; &nbsp; Form3:=nil;<br>&nbsp; end;<br>end;<br><br>{千万要试了再发言,不要灌水,如果你是低手请你不要发言}
 
1:我不是高手<br>2:你上面的代码我没看<br>3:当然我也没试<br>4:不是灌水<br>5: 我没选EMAIL通知<br>但是我可以猜一下吧:<br>将工程打包:project options -&gt;packages-&gt;build with runtime package <br><br>你可以试一下
 
这是handle的问题,因为OpenDialog是从TCommonDialog继承下来的,<br>constructor TCommonDialog.Create(AOwner: TComponent);<br>begin<br>&nbsp; inherited Create(AOwner);<br>&nbsp; FCtl3D := True;<br>&nbsp; FObjectInstance := Classes.MakeObjectInstance(MainWndProc);<br>end;<br>这里没有指明Handle ,类似的,如果你用MessageDlg来显示对话框,也会出现这个问题,<br>但是如果用MessageBox就不会,因为你可以在MessageBox(self.Handle..)中指明对应的<br>handle.<br><br>解决办法:<br>1、对话框之类的:重新构造TCommonDialog<br>constructor TMyCommonDialog.Create(AOwner: TComponent);<br>begin<br>&nbsp; inherited Create(AOwner);<br>&nbsp; FCtl3D := True;<br>&nbsp; FObjectInstance := MakeObjectInstance(MainWndProc);<br>&nbsp; if AOwner is TForm then<br>&nbsp; &nbsp; FParentHandle := (AOwner as TForm).Handle<br>&nbsp; else<br>&nbsp; &nbsp; FParentHandle := 0;<br>end;<br>2、对普通窗口,所以的窗口可以在下面的代码上再继承<br>type<br>&nbsp; TMyForm = class(TForm)<br>&nbsp; private<br>&nbsp; &nbsp; FParentForm : TForm;<br>&nbsp; protected<br>&nbsp; &nbsp; procedure CreateParams(VAR Params: TCreateParams); override;<br>&nbsp; public<br>&nbsp; &nbsp; property ParentForm :TForm read FParentForm write FParentForm;<br>&nbsp; &nbsp; constructor Create(Sender: TComponent);override;<br>&nbsp; end;<br><br>constructor TMyForm.Create(Sender:TComponent);<br>begin<br>&nbsp; if Sender is TForm then<br>&nbsp; &nbsp; FParentForm := Sender as TForm<br>&nbsp; else<br>&nbsp; &nbsp; FParentForm := nil;<br><br>&nbsp; inherited Create(Sender);<br>end;<br><br>procedure TMyForm.CreateParams(VAR Params: TCreateParams);<br>begin<br>&nbsp; Inherited CreateParams(Params);<br>&nbsp; if assigned(FParentForm) then<br>&nbsp; &nbsp; Params.WndParent := FParentForm.Handle;<br>end;<br><br>完了,希望对你有帮助:)
 
我不是高手,正正经经的低手一个。不过好在这个问题也基本上属于白痴才问得出来,<br>我这个低手正好答一下。高手同志,窗口风格是不能自己吃饱了撑的瞎改的。给你贴<br>上来修改后的东东。<br><br>type<br>&nbsp; TAppFrm = class(TForm)<br>&nbsp; &nbsp; procedure CreateParams(var Params:TCreateParams);override;<br>&nbsp; private<br>&nbsp; &nbsp; procedure WMSysCommand(var Msg:TWMSysCommand);message WM_SYSCOMMAND;<br>&nbsp; &nbsp; procedure WMMenuSelect(var Msg:TWMMenuSelect);message WM_MENUSELECT;<br>&nbsp; // &nbsp;procedure CreateAppWnd;<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; constructor Create(AOwner: TComponent); override;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; end;<br><br>{--------------------------------------------------------------}<br>&nbsp; TAppChildFrm = class(TForm)<br>&nbsp; &nbsp; procedure CreateParams(var Params:TCreateParams);override;<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; constructor Create(AOwner: TComponent); override;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; end;<br>{--------------------------------------------------------------}<br><br>implementation<br><br>{ TAppFrm }<br><br>constructor TAppFrm.Create(AOwner: TComponent);<br>begin<br>&nbsp; inherited;<br>// &nbsp;CreateAppWnd;<br>end;<br>{<br>procedure TAppFrm.CreateAppWnd;<br>begin<br>&nbsp; SetWindowLong(Application.Handle,GWL_EXSTYLE,<br>&nbsp; &nbsp; &nbsp; &nbsp; GetWindowLong(Application.Handle,GWL_EXSTYLE) or WS_EX_TOOLWINDOW);<br>end;<br>&nbsp;}<br>procedure TAppFrm.CreateParams(var Params: TCreateParams);<br>begin<br>&nbsp; Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;<br>&nbsp; inherited CreateParams(Params);<br>// &nbsp;Params.ExStyle:=WS_EX_APPWINDOW;<br>end;<br>
 
忘记说了,<br>1. 给你贴的东东我试过了。<br>2. 这种弱智问题不必写什么高手请进、低手莫入之类的话吧?又不是什么像样的问题。
 
To: mikedeakins<br><br>TMD如过我不要风格的话何必你注释<br>我直接从TForm创建实例不就得了吗<br><br>To:woodstock<br>我也觉得是Handle问题<br>MessageBox就没有问题<br>问题是更改之前Delphi是没有这个问题的
 
一般情况下遇到什么低手未入的标题我都不回答
 
低手未入应改一改!!!!!
 
你是说 TaskBar 上右击程序对应的按钮弹出来的菜单少了一些选项的问题吗?不用这么麻烦<br>吧,看看 Forms.pas 中 TApplication.CreateHandle 方法:<br>procedure TApplication.CreateHandle;<br>...<br>begin<br>&nbsp; ...<br>&nbsp; &nbsp; SysMenu := GetSystemMenu(FHandle, False);<br>&nbsp; &nbsp; DeleteMenu(SysMenu, SC_MAXIMIZE, MF_BYCOMAND);<br>&nbsp; &nbsp; DeleteMenu(SysMenu, SC_SIZE, MF_BYCOMAND);<br>&nbsp; &nbsp; if NewStyleControls then DeleteMenu(SysMenu, SC_MOVWE, MF_BYCOMAND);<br>&nbsp; ...<br>end; <br>把这几行注释掉,再在 TApplication.WndProc 中将相应消息转发给 MainForm 就行了吧。<br>procedure TApplication.WndProc(var Message: TMessage);<br>...<br>begin<br>....<br>&nbsp; with Message do<br>&nbsp; &nbsp;WM_SYSCOMMAND:<br>&nbsp; &nbsp; &nbsp;case WParam and $FFF0 of<br>&nbsp; &nbsp; &nbsp; &nbsp;...<br>&nbsp; &nbsp; &nbsp; &nbsp;SC_SIZE, SC_MOVE, SC_MAXIMIZE: <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if MainForm &lt;&gt; nil then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MainForm.WndProc(Message)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Default;<br>&nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Default;<br>&nbsp; ...<br>end;<br>&nbsp;
 
to pcexplorer, <br>孩子,眼睛睁大点看我给你的程序。<br><br>&nbsp; Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;<br><br>这一行干什么用的?你看了吗?你自作聪明更改窗口风格,这种弱智问题居然还什么高手<br>莫入,直接说自己是呆子就行了。
 
我现在知道了什么叫狗血淋头了
 
http://go2.163.com/eagleboost/issues/Materials/Articles/DelphiWindow.htm<br>用我的土方法,很好用。
 
To:CathyEagle<br>问题是占用资源而且还没有解决问题<br><br>To:mikedeakins<br>我不知你的意思我试了,好象有回到了原来的系统菜单,<br>说白了,我现在就是要实现任务栏的菜单要和主窗口的系统菜单一样该怎么办???<br><br>To:bbkxjy<br>你的方法也不行,因为系统菜单中的有些选项被禁止了<br><br>To:所有人<br>如果分数不够可以加!!!<br><br>我始终觉得是Handle和Application.Handle的问题<br><br>
 
我想这种问题高手都懒得回答。
 
难道就没有一个人能回答吗???<br>是不是因为标题还是......<br>
 
对于有些菜单项被禁止,除了照上面修改之外,还需要作以下修改:<br>1、TApplication.CreateHandle<br>procedure TApplication.CreateHandle;<br>...<br>&nbsp; FHandle := CreateWindow(WindowClass.lpszClassName, PChar(FTitle),<br>&nbsp; &nbsp; WS_POPUP or WS_CAPTION or WS_CLIPSIBLINGS or WS_SYSMENU <br>&nbsp; &nbsp; or WS_MINIMIZEBOX or WS_MAXIMIZEBOX or WS_SIZEBOX,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2,<br>&nbsp; &nbsp; 0, 0, 0, 0, HInstance, nil);//加上 WS_SIZEBOX 风格,设座标令窗口在屏幕之外<br>&nbsp; ...<br>end;<br>2、TApplication.Minimize;<br>procedure TApplication.Minimize;<br>...<br>&nbsp; if (MainForm &lt;&gt; nil) and (ShowMainForm or MainForm.Visible) then<br>&nbsp; begin<br>&nbsp; &nbsp; SetWindowPos(FHandle, MainForm.Handle, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, SWP_SHOWWINDOW);<br>&nbsp; &nbsp; ...<br>&nbsp; end;<br>... &nbsp;<br>end;<br>3、TApplication.Restore;<br>procedure TApplication.Restore;<br>...<br>&nbsp; if IsIconic(FHandle) then<br>&nbsp; begin<br>&nbsp; &nbsp; ...<br>&nbsp; &nbsp; SetWindowPos(FHandle, 0, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, SWP_SHOWWINDOW);<br>&nbsp; &nbsp; ...<br>&nbsp; end;<br>&nbsp; ...<br>end;<br>4、TApplication.UpdateVisible;<br>proceudre TApplication.UpdateVisible;<br>&nbsp; proceudre SetVisible(Value: Boolean);<br>&nbsp; ...<br>&nbsp; begin<br>&nbsp; &nbsp; if ... then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; SetWindowPos(FHandle, 0, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, ShowFlags[Value]);<br>&nbsp; &nbsp; &nbsp; ...<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>...<br>begin<br>&nbsp;...<br>end;<br>主要是加上 WS_SIZEBOX 后,虽然 TApplication 窗口的 width,height 为 0, 仍然会显示<br>出来,隐藏不了,需要修改 x, y,令窗口在屏幕之外。 &nbsp;
 
对于有些菜单项被禁止,除了照上面修改之外,还需要作以下修改:<br>1、TApplication.CreateHandle<br>procedure TApplication.CreateHandle;<br>...<br>&nbsp; FHandle := CreateWindow(WindowClass.lpszClassName, PChar(FTitle),<br>&nbsp; &nbsp; WS_POPUP or WS_CAPTION or WS_CLIPSIBLINGS or WS_SYSMENU <br>&nbsp; &nbsp; or WS_MINIMIZEBOX or WS_MAXIMIZEBOX or WS_SIZEBOX,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2,<br>&nbsp; &nbsp; 0, 0, 0, 0, HInstance, nil);//加上 WS_SIZEBOX 风格,设座标令窗口在屏幕之外<br>&nbsp; ...<br>end;<br>2、TApplication.Minimize;<br>procedure TApplication.Minimize;<br>...<br>&nbsp; if (MainForm &lt;&gt; nil) and (ShowMainForm or MainForm.Visible) then<br>&nbsp; begin<br>&nbsp; &nbsp; SetWindowPos(FHandle, MainForm.Handle, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, SWP_SHOWWINDOW);<br>&nbsp; &nbsp; ...<br>&nbsp; end;<br>... &nbsp;<br>end;<br>3、TApplication.Restore;<br>procedure TApplication.Restore;<br>...<br>&nbsp; if IsIconic(FHandle) then<br>&nbsp; begin<br>&nbsp; &nbsp; ...<br>&nbsp; &nbsp; SetWindowPos(FHandle, 0, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, SWP_SHOWWINDOW);<br>&nbsp; &nbsp; ...<br>&nbsp; end;<br>&nbsp; ...<br>end;<br>4、TApplication.UpdateVisible;<br>proceudre TApplication.UpdateVisible;<br>&nbsp; proceudre SetVisible(Value: Boolean);<br>&nbsp; ...<br>&nbsp; begin<br>&nbsp; &nbsp; if ... then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; SetWindowPos(FHandle, 0, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, ShowFlags[Value]);<br>&nbsp; &nbsp; &nbsp; ...<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>...<br>begin<br>&nbsp;...<br>end;<br>主要是加上 WS_SIZEBOX 后,虽然 TApplication 窗口的 width,height 为 0, 仍然会显示<br>出来,隐藏不了,需要修改 x, y,令窗口在屏幕之外。 &nbsp;
 
对于有些菜单项被禁止,除了照上面修改之外,还需要作以下修改:<br>1、TApplication.CreateHandle<br>procedure TApplication.CreateHandle;<br>...<br>&nbsp; FHandle := CreateWindow(WindowClass.lpszClassName, PChar(FTitle),<br>&nbsp; &nbsp; WS_POPUP or WS_CAPTION or WS_CLIPSIBLINGS or WS_SYSMENU <br>&nbsp; &nbsp; or WS_MINIMIZEBOX or WS_MAXIMIZEBOX or WS_SIZEBOX,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2,<br>&nbsp; &nbsp; 0, 0, 0, 0, HInstance, nil);//加上 WS_SIZEBOX 风格,设座标令窗口在屏幕之外<br>&nbsp; ...<br>end;<br>2、TApplication.Minimize;<br>procedure TApplication.Minimize;<br>...<br>&nbsp; if (MainForm &lt;&gt; nil) and (ShowMainForm or MainForm.Visible) then<br>&nbsp; begin<br>&nbsp; &nbsp; SetWindowPos(FHandle, MainForm.Handle, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, SWP_SHOWWINDOW);<br>&nbsp; &nbsp; ...<br>&nbsp; end;<br>... &nbsp;<br>end;<br>3、TApplication.Restore;<br>procedure TApplication.Restore;<br>...<br>&nbsp; if IsIconic(FHandle) then<br>&nbsp; begin<br>&nbsp; &nbsp; ...<br>&nbsp; &nbsp; SetWindowPos(FHandle, 0, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, SWP_SHOWWINDOW);<br>&nbsp; &nbsp; ...<br>&nbsp; end;<br>&nbsp; ...<br>end;<br>4、TApplication.UpdateVisible;<br>proceudre TApplication.UpdateVisible;<br>&nbsp; proceudre SetVisible(Value: Boolean);<br>&nbsp; ...<br>&nbsp; begin<br>&nbsp; &nbsp; if ... then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; SetWindowPos(FHandle, 0, -GetSystemMetrics(SM_CXSCREEN) div 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; -GetSystemMetrics(SM_CYSCREEN) div 2, 0, 0, ShowFlags[Value]);<br>&nbsp; &nbsp; &nbsp; ...<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>...<br>begin<br>&nbsp;...<br>end;<br>主要是加上 WS_SIZEBOX 后,虽然 TApplication 窗口的 width,height 为 0, 仍然会显示<br>出来,隐藏不了,需要修改 x, y,令窗口在屏幕之外。 &nbsp;
 
问题出在 TApplication 类上面!<br>如果用 Win32 Api 函数来创建一个窗口的话就不会出现少了几项菜单的问题!
 
后退
顶部