Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Move statusbar from mdi child to main mdi form

Posted on 2001-07-17
6
Medium Priority
?
516 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
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.

 

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 800 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

Hire Technology Freelancers with Gigs

Work with 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.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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