Solved

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

Posted on 2004-10-05
5
824 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
Comment Utility
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
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
>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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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