Solved

Move statusbar from mdi child to main mdi form

Posted on 2001-07-17
6
506 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
[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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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