Solved

Move statusbar from mdi child to main mdi form

Posted on 2001-07-17
6
502 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Internet Explorer View Settings Question 15 111
Run video youtube webbrowse 10 61
Convert GUI app into console app for Win32 Env 5 100
how to update exe applicatio from internet ? 6 77
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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