Solved

Problem with MDIChild, wsMaximized and inheriting Base form...

Posted on 2004-10-05
5
833 Views
Last Modified: 2010-04-05
Here is the problem. I have one form called TfrmBaseForm, which is inherited in all other forms. It is 500x700, fsMDIChild.

Let's say I have TForm1 = class(TfrmBaseForm). The size of TForm1 is 400x600. I put a button in the bottom right corner of the form and set its Anchors - Bottom and Right = True, Top and Left = False;

When I show the form, the button is not visible, because the form shows with some different size. The same problem is if the form is WindowsState = wsMaximized...

I am using D7.
0
Comment
Question by:Ivanov_G
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12224954
guess you you should set the top/left and anchor-properties at runtime for this case

meikl ;-)
0
 
LVL 2

Accepted Solution

by:
DarkCore_ earned 180 total points
ID: 12225112
I used too this method. I have a class function in base class ( showForm : TForm ) for all forms. In this functions I call a "bringtofront", "Maximize" and a "Show" method ( in this order ) always. And it shows always correct forms.

The TControl inherited components repaint itself  using the anchors properties when recieving some messages. But i noticed the problem you say in other applications ( but i discovered this "order" of functions )

Edu

My function ( in base class ). It limits one form class each time ( you cannot have two childs of the same class )

class function TFrmBase.formShow :  TForm;
var
  F : TForm;
  i : Integer;
begin
  F := nil;
  //Lock mainform's update
  LockWindowUpdate( Application.MainForm.Handle );
 
  (*
     Searching for the form I want to show
   *)
  For i := 0 to Screen.FormCount - 1 do Begin
      if Screen.Forms[i].ClassName = ClassName then Begin
         F := TForm( Screen.Forms[i] );
         Break;
      End;
  End;

  (* if doesn't exists, create it *)
  if F = nil then F := Create( Application.MainForm );
  if F.WindowState <> wsMaximized then F.WindowState := wsMaximized;
  F.BringToFront;
  F.Show;

  (* Unlock mainform's update *)
  LockWindowUpdate( 0 );
  Result := F;

  //Freeing resources
  SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF);
End;
0
 
LVL 12

Author Comment

by:Ivanov_G
ID: 12225440
DarkCore_, I have method similar to yours, but I use Self.MDIChildren, instead of Screen.Forms.

> guess you you should set the top/left and anchor-properties at runtime for this case
I mean to set the Anchors for every button on the form ???
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 12225466
Well, then your method is in your mainform, not in your mdichild form. with this method you can do something like

  TMyChildForm1.showForm;
  TMyChildForm2.showForm;

and you will create the form if it not exists or show it ( and bring to front ) if is already created. Then, try the sequence for showing it ... have you tried it? I've not any kind of problem with _exactly_ this sequence. I got problems ( not only with buttons, too with unresized panels and unresized PageControls ) time ago, but this works perfect for me.

Edu
0
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 70 total points
ID: 12225517
>I mean to set the Anchors for every button on the form ???

you could use a container like tpanel,
there you can set your buttons with the porperties at designtime,
but let be the align of the tpanel to alNone

at runtime (in the formCreate-event) align your container as you need

just a suggestion

meikl ;-)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question