?
Solved

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

Posted on 2004-10-05
5
Medium Priority
?
841 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 720 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 280 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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