Solved

Move statusbar from mdi child to main mdi form

Posted on 2001-07-17
6
499 Views
Last Modified: 2010-04-06
I want to move the statusbar from mdi child to main mdi form when maximized and back to child when restored. But it seem like setting the parent will only hide the statusbar not show it on the other window. The status bar is alligned at bottom. Thanks.
0
Comment
Question by:sorinv
6 Comments
 
LVL 21

Expert Comment

by:gemarti
ID: 6291395
Try This:

 if Form2.WindowState = wsMinimized then
    form1.StatusBar1.Panels := Form2.StatusBar1.Panels;
0
 

Author Comment

by:sorinv
ID: 6292597
The main window doesn't have a status bar on it.
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6293201
on the Child's minimize event:

StatusBar1.Parent := MainForm; // I assume that MainForm is the variable name for the MDI parent

and on the restore:

StatusBar1.Parent := Self;
0
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.

 

Author Comment

by:sorinv
ID: 6293222
Thanks, DragonSlayer, but this is just hiding the stasudbar, not moving it from one window to another...
0
 
LVL 4

Expert Comment

by:fva
ID: 6293339
Put a status bar on the main form, keep it in sync with the SB from the active child, hide it when the child is normal-sized, show it when the child is maximized. Hide the child SB when maximized, show it back when normal-sized (reverse of main SB behavior).

F.
0
 
LVL 21

Accepted Solution

by:
gemarti earned 200 total points
ID: 6295395
Here you go: Only thing, I don't have time to work through the Access Violation when you close the application.

As an example
1. create a main form (CMainFrm) that is a MDI Form
2. Create a Child form (CStatusBar) this is a MDI Child

Then insert this code:

unit CStatusBar;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls;

type
  TForm2 = class(TForm)
    StatusBar1: TStatusBar;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
    procedure FormCanResize(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Resize: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses CMainFrm;

{$R *.DFM}

procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if Form2.StatusBar1.ParentWindow <> Form2.Handle then
    begin
     Form1.DefocusControl(Form2.StatusBar1,True);
     Form1.RemoveControl(Form2.StatusBar1);
      Form2.StatusBar1.ParentWindow := Form2.Handle;
      Form1.RemoveControl(Form2.StatusBar1);
      try
      CanClose := True;
      except on EAccessViolation do
        ShowMessage('Method was not cleany terminated');
      end;
    end;
end;

procedure TForm2.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
      Form2.StatusBar1.SimplePanel := true; {Just for Testing}
      Form2.StatusBar1.SimpleText := 'This Works!'; {If it does work
      you'll see it on form1 instead for form2}
      Form2.StatusBar1.Update;
end;

procedure TForm2.FormCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
begin
      Form2.StatusBar1.CreateParented(Form1.Handle);
      Form1.InsertControl(Form2.StatusBar1);
      Form1.UpdateControlState;
end;

end.

++++++++++++++++++++++++

AND

++++++++++++++++++++++++++


unit CMainFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Open1: TMenuItem;
    procedure Open1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses CStatusBar;
{$R *.DFM}

procedure TForm1.Open1Click(Sender: TObject);
begin
  Form2 := TForm2.Create(Self);
end;

end.
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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

863 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

22 Experts available now in Live!

Get 1:1 Help Now