Solved

Move statusbar from mdi child to main mdi form

Posted on 2001-07-17
6
498 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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

9 Experts available now in Live!

Get 1:1 Help Now