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?
LVL 12
Ivanov_GAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ivanov_GAuthor Commented:
Excellent ! Now it works perfect
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.