Solved

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

Posted on 2004-10-05
5
830 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now