当前位置:主页>仓库管理软件> 列表

窗口内的控件也随着变大? 找erp软件是什么

库存管理软件版1楼: 如何在运行delphi程序时,将窗口自动扩大到全屏,同时窗口内的控件也随着变大?

謝謝~!

2楼: 控件的anchors的属性全部改成ture,或者align属性改成alClient 如速达软件

3楼: 这样比例可能失调吧

4楼: ScaleBy(M, D: Integer)

5楼: 能详细吗?

分全部给你.

6楼: Anchors這個屬性,近件都有。不過很難調~
你自己可以試試~~

库存管理软件版7楼: 将你要变大的控件的align属性改成client
如果有两个控件的话,可把上面一个的改成altop,把下面的再写成alclient...

8楼: 知道你想做一个适应不同分辨率的程序。
窗口扩大到全屏
form1.width:=screen.width;
form1.height:=screen.height;
如果想同比扩大控件,就要设计
繁复的界面计算了。比如
if screen.width:=600 then component1.width:=xxx;
这样开发调试难,用也麻烦,而且有的控件还是不能
扩大比较好,例如label.
建议
利用panel的altop,client,left等
决定界面分布(确定每一个控件的‘领域’)
然后放置控件,这样就能得到自适应的界面了。

9楼: 这样的问题 我常遇到谈谈我的看法:
学会窗体布局:
你可以用有容器功能的控件,panel,groupbox,bevel等等
然后用它们设置窗体的框架
要了解align的几个属性

10楼: 是否显示器分辨率问题?设置1024*768.

11楼: 楼主试一下这段代码,应该可以解决你的问题,最大和恢复窗体时,控件大小会按比例变化

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
private
procedure OnMaximize(var message: TMessage); message WM_SYSCOMMAND;
public
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.OnMaximize(var message: TMessage);
const
FormWidth = 696; //窗体原始宽度
begin
case message.WParam of
SC_MAXIMIZE:
begin
ScaleBy(Screen.Width, FormWidth);
Inherited;
end;
SC_RESTORE:
begin
ScaleBy(FormWidth, Screen.Width);
Inherited;


end;
else Inherited;
end;
end;

end.

12楼: 一般情况下我会在窗口变化的事件中重画控件,比例固定,无非是确定width,left,top,height这些与位置有关的项阿 如erp软件是什么

13楼: 这个要慢慢调的哟!

库存管理软件版14楼: 周海涛和baiduan
我同意

15楼: 很多的时候,
我都是用panel来做的,
但是控件是比较难控制它们在窗口变大之后的大小以及它们的位置.

16楼: 使用:在需要的容器的OnResize中 ReSizer1(WinControl)
比如ReSizer1(Self);



{*
* NO THIS IS NOT PERFECT. IF YOU DON''T LIKE IT, DON''T USE IT!
*
* This is a simple VC that resizes all the controls on a form.
*
* All you have to do is place the RESIZER component on your form,
* set the ''OnSized'' event for the form to a function and then call
* ''ReSize(Sender)'' from within that function.
*
* It is a GOOD IDEA in your ''OnSized'' event for the form to watch
* for resizing that is too small. If you resize the form too small
* you can cause this Resizer to crash your program. All you have to
* do is check the bounds of the form being resized, if they are less
* than a certain amount, set the bounds to the certain amount.
*
* See the example program for help or you can mail me:
* mental@murdrum.nmsu.edu
*
* Obvious extensions are adding support to any container controls I
* may have missed. You can tell if something is a container control
* by placing another control on it and then try to move the control
* outside of it. If you cannot move the inner control outside, it
* IS a container control.
* I have NOT figured out how controls are stored on a TTabbedNotebook,
* (but honently I have not looked very hard, yet) so while the
* TTabbedNotebook will resize itself, the obejcts on the pages will
* not size themselvess.
*}

unit Resizer;

interface

uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, TabNotBk;

type
pControlInfo = ^tControlInfo;
tControlInfo = record
{ This record holds information about a component on the form}
{ or about a component inside a container object}
Obj:TControl;
ClassName:String;
lRatio,tRatio,wRatio,hRatio:Real;
Contains:pControlInfo;
Next:pControlInfo;
End;
TResizer = class(TComponent)
private
{ These variables and functions should not be needed by the user, }
{ only by the RESIZER component.}
ResizerInitialized:Boolean;
Function GetClientControlCount(Sender:TObject):LongInt;
procedure GetNewWidthHeight(Sender:TObject;Var NewW,NewH:LongInt);
Procedure PerformResize(CurCont:pControlInfo;CWidth,CHeight:LongInt);
Function GetClientControlObject(Sender:TObject;Index:LongInt):TControl;
Function Initialize(Sender:TObject;CWidth,CHeight:LongInt):pControlInfo;
Procedure DeleteControlList(CurCont:pControlInfo);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{ These are useful to the programmer. I currently dont use NewShapshot, but}
{ somebody out there might.... especially if you are using DYNAMICALLY}
{ created components on your form.}
procedure ReSize(ParentForm:TObject);
procedure NewSnapshot(ParentForm:TObject);
end;

procedure Register;

implementation

Var ControlList:pControlInfo;

constructor TResizer.Create(AOwner: TComponent);
Var Count:LongInt;
Begin
inherited Create(AOwner);
{ Do my init stuff}
ResizerInitialized:=False;
ControlList:=nil;
End;

destructor TResizer.Destroy;
Begin
{ Destroy the existing ControlList }
DeleteControlList(ControlList);
ResizerInitialized:=False;
ControlList:=nil;
inherited Destroy;
End;

{ Recursively setup throw the control list and all containers}
{ and delete all the dynamically allocated objects}
Procedure TResizer.DeleteControlList(CurCont:pControlInfo);
Var NextCont:pControlInfo;
Begin
While(CurCont<>nil) Do
Begin
If((CurCont^.Contains)<>nil) Then
DeleteControlList(CurCont^.Contains);
NextCont:=CurCont^.Next;
FreeMem(CurCont,SizeOf(tControlInfo));
CurCont:=NextCont;
End;
End;

procedure TResizer.GetNewWidthHeight(Sender:TObject;Var NewW,NewH:LongInt);
Begin
{ Determine the type of container component we have then get its}
{ width and height and tag number}
If(Sender is TForm) Then
With TForm(Sender) Do
Begin
{ Since this is a TForm, we want ClientWidth and ClientHeight}
NewW:=ClientWidth;
NewH:=ClientHeight;
End
Else
If(Sender is TPanel) Then
With TPanel(Sender) Do
Begin
NewW:=Width;
NewH:=Height;
End
Else
If(Sender is TGroupBox) Then
With TGroupBox(Sender) Do
Begin
NewW:=Width;
NewH:=Height;
End
Else
{The TTabbedNotebook stuff doesn''t work right... Components inside}


{the tabbed notebook won''t resize as of yet}
If(Sender is TTabbedNotebook) Then
With TTabbedNotebook(Sender) Do
Begin
NewW:=Width;
NewH:=Height;
End
Else
Begin
{ We don''t recognize the container, so supply 0 values}
NewW:=0;
NewH:=0;
End;
End;

Function TResizer.GetClientControlCount(Sender:TObject):LongInt;
Begin
{ Determine the type of container component we have then}
{ return the number of controls on that container}
If(Sender is TForm) Then
Result:=TForm(Sender).ControlCount
Else
If(Sender is TPanel) Then
Result:=TPanel(Sender).ControlCount
Else
If(Sender is TGroupBox) Then
Result:=TGroupBox(Sender).ControlCount
Else
{The TTabbedNotebook stuff doesn''t work right... Components inside}
{the tabbed notebook won''t resize as of yet}
If(Sender is TTabbedNotebook) Then
Result:=TTabbedNotebook(Sender).ControlCount
Else
{ We don''t recognize the container, so supply a 0 value}
Result:=0;
End;


Function TResizer.GetClientControlObject(Sender:TObject;Index:LongInt):TControl;
Begin
If(Sender is TForm) Then
Result:=TForm(Sender).Controls[Index]
Else
If(Sender is TPanel) Then
Result:=TPanel(Sender).Controls[Index]
Else
If(Sender is TGroupBox) Then
Result:=TGroupBox(Sender).Controls[Index]
Else
{The TTabbedNotebook stuff doesn''t work right... Components inside}
{the tabbed notebook won''t resize as of yet}
If(Sender is TTabbedNotebook) Then
Result:=TTabbedNotebook(Sender).Controls[Index]
Else
Result:=nil;
End;

Function TResizer.Initialize(Sender:TObject;CWidth,CHeight:LongInt):pControlInfo;
Var Temp:pControlInfo;
Count:Integer;
Begin
Result:=nil;
For Count:=0 to (GetClientControlCount(Sender)-1) Do
Begin
GetMem(Temp,SizeOf(tControlInfo));
Temp^.Obj:=GetClientControlObject(Sender,Count);
With(Temp^) Do
Begin
lRatio:=(Obj.Left) / CWidth;
tRatio:=(Obj.Top) / CHeight;
wRatio:=(Obj.Width) / CWidth;
hRatio:=(Obj.Height) / CHeight;
Contains:=nil;
Next:=Result;
End;
Result:=Temp;
{The TTabbedNotebook stuff doesn''t work right... Components inside}
{the tabbed notebook won''t resize as of yet}
If((Temp^.Obj is TForm) or
(Temp^.Obj is TPanel) or
(Temp^.Obj is TGroupBox) or
(Temp^.Obj is TTabbedNotebook)) Then
With(Temp^) Do
Contains:=Initialize(Obj,Obj.Width,Obj.Height);
End;
End;

Procedure TResizer.PerformResize(CurCont:pControlInfo;CWidth,CHeight:LongInt);
Begin
While(CurCont<>nil) Do
Begin
With(CurCont^) Do
Begin
With(Obj) Do
SetBounds(Round(lRatio*CWidth),Round(tRatio*CHeight),
Round(wRatio*CWidth),Round(hRatio*CHeight));
If(Contains<>nil) Then
PerformResize(Contains,Obj.Width,Obj.Height);
End;
CurCont:=CurCont^.Next;
End;
End;

procedure TResizer.NewSnapshot(ParentForm:TObject);
Var NewClientWidth,NewClientHeight:LongInt;
Begin
GetNewWidthHeight(ParentForm,NewClientWidth,NewClientHeight);
{ Delete the existing ControlList for this form}
DeleteControlList(ControlList);
ControlList:=nil;
ResizerInitialized:=False;
{ Initialize the ControlList for this form}
ControlList:=Initialize(ParentForm,NewClientWidth,NewClientHeight);
If(ControlList<>nil) Then
{ The control list HAS been initialized!}
ResizerInitialized:=True;
End;

{ This should be called everytime the form is resized (ie in the OnSized}
{ event). Pass OnSized "Sender" parameter to this procedure}
procedure TResizer.ReSize(ParentForm:TObject);
Var NewClientWidth,NewClientHeight:LongInt;

Count:Integer;
Left,Top,Width,Height:LongInt;
Begin
GetNewWidthHeight(ParentForm,NewClientWidth,NewClientHeight);
If(ResizerInitialized) Then
{ The ControlList already exists, resize the form and its controls}
PerformResize(ControlList,NewClientWidth,NewClientHeight)
Else
{ No ControlList exists. Let''s create one}
NewSnapshot(ParentForm);
End;

{ This should be called only if you want to take a NEW shapshot of the}
{ relative positions and sizes of the controls on the form. The paramter}
{ should be the form on which the object resides}
procedure Register;
begin
{ Register the RESIZER component}
RegisterComponents(''Custom'', [TResizer]);
end;

end.

17楼: 多人接受答案了。