我能做到这一点的方式(再次感谢DavID)正在捕捉WMSizing,WMMoving,WMGetMaxMinInfo以及我的porpuose WMShowwindow消息.
我并不关闭消息处理,我认为这可能是我管理消息的方式,因为我没有得到我需要的结果.
我的应用程序中的所有表单都是模态的.但是你可以在同一个执行线程中打开很多东西. (Mainform,form1,form2,form3 … formN).
所有表格(1..N)都在我的主要形式的工作区内移动.最大化,恢复,调整大小,移动…在工作区域的限制之间.
但我无法管理如何最小化整个应用程序,然后单击活动模式窗体最小化按钮,然后单击任务栏按钮.
该应用程序将用于XP和W7 …我正在DelphiXE中开发.
该项目可以从这里下载(Project files – 主要形式,面板,按钮,SecondaryForm,单位,仅此而已),只是为了看到我尝试所有的建议,我在问这里之前.
这是原始单元的源代码,它将模态形式保留在工作区内.
unit uFormularios;interfaceuses Classes,SysUtils,windows,Messages,Forms,DBGrIDs,StdCtrls,Menus,Graphics,ComCtrls,Math;type TForm_en_ventana = class(TForm) private inicializada: boolean; bCenTrada : boolean; bMaximizada : boolean; ancho_original: integer; alto_original : integer; procedure WMShowWindow(var Message: TWMShowWindow); message WM_SHOWWINDOW; procedure WMSizing(var msg: TMessage); message WM_SIZING; procedure WMMoving(Var msg: TMessage); message WM_MOVING; procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO; public constructor Create(AOwner: TComponent); overrIDe; property cenTrada: boolean read bCenTrada write bCenTrada; property maximizada: boolean read bMaximizada write bMaximizada; end;procedure MaximizarFormulario(var F; MaximaAltura: integer = 0; MaximoAncho: integer = 0; CenTrado: boolean = TRUE);procedure InicializarVentanaTrabajo(const izq,der,arr,aba: integer);var ESPACIO_DE_TRABAJO,VENTANA_DE_TRABAJO: TRect;implementationconstructor TForm_en_ventana.Create(AOwner: TComponent);begin inherited; cenTrada := TRUE; maximizada := false; inicializada := false;end;Procedure TForm_en_ventana.WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);begin inherited; with msg.MinMaxInfo^.ptMaxposition do begin x := VENTANA_DE_TRABAJO.left; y := VENTANA_DE_TRABAJO.top; end; with msg.MinMaxInfo^.ptMaxSize do begin x := VENTANA_DE_TRABAJO.Right - VENTANA_DE_TRABAJO.left; y := VENTANA_DE_TRABAJO.Bottom - VENTANA_DE_TRABAJO.top; end; with msg.MinMaxInfo^.ptMaxTrackSize do begin x := VENTANA_DE_TRABAJO.Right - VENTANA_DE_TRABAJO.left; y := VENTANA_DE_TRABAJO.Bottom - VENTANA_DE_TRABAJO.top; end; with msg.MinMaxInfo^.ptMinTrackSize do begin x := ancho_original; y := alto_original; end;end;procedure TForm_en_ventana.WMSizing(var msg: TMessage);var R: PRect;begin R := PRect(msg.LParam); R.left := Max(R.left,VENTANA_DE_TRABAJO.left); R.Right := Min(R.Right,VENTANA_DE_TRABAJO.Right); R.top := Max(R.top,VENTANA_DE_TRABAJO.top); R.Bottom := Min(R.Bottom,VENTANA_DE_TRABAJO.Bottom); Caption := 'Ancho: ' + inttostr(ancho_original) + ' - Alto: ' + inttostr(alto_original);end;procedure TForm_en_ventana.WMMoving(var msg: TMessage);var R : PRect; dx,dy: integer;begin R := PRect(msg.LParam); dx := 0; dy := 0; if R.left < VENTANA_DE_TRABAJO.left then dx := VENTANA_DE_TRABAJO.left - R.left; if R.Right > VENTANA_DE_TRABAJO.Right then dx := VENTANA_DE_TRABAJO.Right - R.Right; if R.top < VENTANA_DE_TRABAJO.top then dy := VENTANA_DE_TRABAJO.top - R.top; if R.Bottom > VENTANA_DE_TRABAJO.Bottom then dy := VENTANA_DE_TRABAJO.Bottom - R.Bottom; OffsetRect(R^,dx,dy);end;procedure TForm_en_ventana.WMShowWindow(var Message: TWMShowWindow);begin if inicializada then Exit; inicializada := TRUE; ancho_original := WIDth; alto_original := Height; Constraints.MinHeight := Height; Constraints.MinWIDth := WIDth; if cenTrada then begin left := (((VENTANA_DE_TRABAJO.Right - VENTANA_DE_TRABAJO.left) - WIDth) div 2) + VENTANA_DE_TRABAJO.left; top := (((VENTANA_DE_TRABAJO.Bottom - VENTANA_DE_TRABAJO.top) - Height) div 2) + VENTANA_DE_TRABAJO.top; end; if maximizada then SendMessage(Handle,WM_SYSCOMMAND,SC_MAXIMIZE,0);end;procedure InicializarVentanaTrabajo(const izq,aba: integer);begin VENTANA_DE_TRABAJO.left := izq; VENTANA_DE_TRABAJO.Right := der; VENTANA_DE_TRABAJO.top := arr; VENTANA_DE_TRABAJO.Bottom := aba;end;procedure MaximizarFormulario(var F; MaximaAltura: integer = 0; MaximoAncho: integer = 0; CenTrado: boolean = TRUE);begin LockWindowUpdate(TForm(F).Handle); TForm(F).left := ESPACIO_DE_TRABAJO.left; if MaximoAncho = 0 then TForm(F).WIDth := ESPACIO_DE_TRABAJO.Right else begin if ESPACIO_DE_TRABAJO.Right < MaximoAncho then TForm(F).WIDth := ESPACIO_DE_TRABAJO.Right else TForm(F).WIDth := MaximoAncho; end; TForm(F).top := ESPACIO_DE_TRABAJO.top; if MaximaAltura = 0 then TForm(F).Height := ESPACIO_DE_TRABAJO.Bottom else begin if ESPACIO_DE_TRABAJO.Bottom < MaximaAltura then TForm(F).Height := ESPACIO_DE_TRABAJO.Bottom else TForm(F).Height := MaximaAltura; end; if ((MaximoAncho <> 0) or (MaximaAltura <> 0)) and (CenTrado) then begin TForm(F).left := (ESPACIO_DE_TRABAJO.Right - TForm(F).WIDth) div 2; TForm(F).top := (ESPACIO_DE_TRABAJO.Bottom - TForm(F).Height) div 2; end; LockWindowUpdate(0);end;initializationSystemParametersInfo(SPI_GETWORKAREA,@ESPACIO_DE_TRABAJO,0);VENTANA_DE_TRABAJO := ESPACIO_DE_TRABAJO;end.
感谢任何可以帮助我的人!
解决方法 只需捕获模态表单中的最小化和还原消息,然后执行此 *** 作…procedure TTheModalForm.WMSysCommand(var Msg: TWMSysCommand);begin if (fsModal in FormState) or not Application.MainForm.Visible then begin case Msg.CmdType of SC_MINIMIZE: begin ShowWindow(Application.Handle,SW_SHOWMINNOACTIVE); end; SC_RESTORE: begin ShowWindow(Application.Handle,SW_SHOWnorMAL); inherited; end; else inherited; end; end else inherited;end;总结
以上是内存溢出为你收集整理的表单 – 最小化子模式表单时最小化整个应用程序全部内容,希望文章能够帮你解决表单 – 最小化子模式表单时最小化整个应用程序所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)