Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1499
  • Last Modified:

Anchors and wsMaximized ...

Here is how you can reproduce the problem

1) Open new project with empty form
2) Put a TPanel component and set its Align property to alRight.
3) Now drop a TButton over the Panel in the lower right corner and set it Right and Botton anchors = True. Top and Left should be False
4) Set the Form's WindowState property to wsMaximized
5) Run the project

Your button don't behave as it should... This is disgusting, especially when I use it in MDI Child forms. Anyone have a solution for this?
0
Ivanov_G
Asked:
Ivanov_G
  • 4
  • 3
  • 3
  • +1
2 Solutions
 
Ivanov_GAuthor Commented:
second issue:

procedure TForm1.FormCreate(Sender: TObject);
begin
  LockWindowUpdate(Self.Handle);
  Self.WindowState := wsMaximized;
  LockWindowUpdate(0);
end;

Putting this WORKS fine if the form is fsNormal. But if I use it with MDI Application, it depends, whether the parent MDIForm container is maximized or not...
0
 
vadim_tiCommented:
object Form1: TForm1
  Left = 192
  Top = 133
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  WindowState = wsMaximized
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 503
    Top = 0
    Width = 185
    Height = 453
    Align = alRight
    Caption = 'Panel1'
    TabOrder = 0
    object Panel2: TPanel
      Left = 1
      Top = 411
      Width = 183
      Height = 41
      Align = alBottom
      BevelOuter = bvNone
      Caption = 'Panel2'
      TabOrder = 0
      DesignSize = (
        183
        41)
      object Button1: TButton
        Left = 64
        Top = 8
        Width = 75
        Height = 25
        Anchors = []
        Caption = 'Button1'
        TabOrder = 0
      end
    end
  end
end
0
 
vadim_tiCommented:
i am not sure what you want to get with second issue, but check this

procedure TMain.FormActivate(Sender: TObject);
begin
  Form1 := TForm1.Create(Self);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  LockWindowUpdate(Self.Handle);
  (Owner as TForm).WindowState := wsMaximized;
  LockWindowUpdate(0);
  Self.WindowState := wsMaximized;
end;

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
kretzschmarCommented:
>Anyone have a solution for this?

as simple:
don't align at designtime, do the align at runtime
0
 
Ivanov_GAuthor Commented:
> don't align at designtime, do the align at runtime

Is there something I miss here. I don't want to align 10 panels manually for each form:
  Panel1.Align := alLeft;
  Panel2.Align := alClient;
  .....

Can I make it automatically for all the components on the form?
0
 
kretzschmarCommented:
usual i run into same problems using tframes
see
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10336365.html

i guess you could use the formcreate-event for the alignment (not tested)

meikl ;-)
0
 
ZhaawZSoftware DeveloperCommented:
Just set WindowState to wsMaximized in onCreate event of the form (don't change WindowState at design-time). It does work fine, doesn't it?
0
 
kretzschmarCommented:
>Just set WindowState to wsMaximized in onCreate event of the form
good idea too ;-))
0
 
Ivanov_GAuthor Commented:
ZhaawZ,
Setting wsMaximized in OnCreate work fine ... but for a single Form.

My Real problem is when the form with Panel and Button is MDIChild. There setting WindowState in OnCreate doesn't work fine... In MDIChild form alligning controls to Bottom is NOT working as it should ...
0
 
ZhaawZSoftware DeveloperCommented:
OK. Let's try it another way.
Leave FormStyle fields as they are at design-time (fsNormal), same with WindowState (wsNormal). Change these settings at runtime, when the second form is created.

procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.FormStyle := fsMDIForm;
Form1.Show;
Form2.FormStyle := fsMDIChild;
Form2.WindowState := wsMaximized;
end;

Is this OK for you?
0
 
ZhaawZSoftware DeveloperCommented:
You may also try to set main form's FormStyle to fsMDIForm at design time.
Then just change MDI Form's FormStyle and WindowState in their onCreate events.
0
 
Ivanov_GAuthor Commented:
Excellent ! Now it works perfect
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now