Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 323
Magic Software info 18 139
how can i search if string exist in array ? 3 63
How to build JSON File in Delphi 6 3 46
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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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