delphi - How make Form2 never be resized for down? -
i have code puts 2 forms side side , works fine, can see when i'm resizing form1, form2 resized, resized down.
so, how make form2 no resize down (since form1 greater form2) when form1 resized?
following code used put 2 forms side side:
unit unit1; interface uses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics, vcl.controls, vcl.forms, vcl.dialogs, vcl.stdctrls; type tform1 = class(tform) button1: tbutton; procedure button1click(sender: tobject); procedure formclose(sender: tobject; var action: tcloseaction); // close on close procedure formresize(sender: tobject); // maximized, minimized etc private { private declarations } public { public declarations } procedure wmmoveform(var amessage: twmmove); message wm_move; // lip form2 main on form size changed procedure wmsizemove(var amessage: twmsize); message wm_sizing; // lip form2 main on form move end; var form1: tform1; implementation {$r *.dfm} uses unit2; procedure tform1.button1click(sender: tobject); begin form2.show(); end; procedure tform1.formclose(sender: tobject; var action: tcloseaction); begin if action = cafree form2.close; end; procedure tform1.formresize(sender: tobject); begin form2.visible := self.windowstate <> wsmaximized; if form2.visible form2.windowstate := self.windowstate; { case self.windowstate of twindowstate.wsnormal: postmessage(form2.handle, wm_syscommand, sc_minimize, 0); twindowstate.wsminimized: postmessage(form2.handle, wm_syscommand, sc_minimize, 0); twindowstate.wsmaximized: postmessage(form2.handle, wm_syscommand, sc_restore, 0); end;} end; procedure tform1.wmmoveform(var amessage: twmmove); begin if assigned(form2) , form2.visible begin form2.top := self.top; form2.left := self.left + self.width; end; inherited; end; procedure tform1.wmsizemove(var amessage: twmsize); begin if form2.visible begin form2.top := self.top; form2.left := self.left + self.width; form2.height := self.height; end; inherited; end; end.
if 'resize down' means resize vertically remove
form2.height := self.height;
from
procedure tform1.wmsizemove(var amessage: twmsize);
Comments
Post a Comment