?
Solved

Hiding and unHiding toolbar

Posted on 2006-05-25
7
Medium Priority
?
270 Views
Last Modified: 2010-04-05
Hi I am using a toolbar and i want to give the user the possibility to make it hidden and un hidden, it should be easy but i am using this code but it's not working:

toolbar.visible:= not toolbar.visible

it's making it unvisible but i cann't make it visible again why i don't know

thanks a lot
0
Comment
Question by:ibrobar
  • 3
  • 2
  • 2
7 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16759906
What are you clicking to make it visible again?

I would usually use a checkbox of some sort on the screen

toolbar.visible := checkbox1.checked;

This will then work for both scenarios.
0
 
LVL 5

Accepted Solution

by:
Scay7 earned 500 total points
ID: 16764888
just to clear up mike's code :P

begin
if checkbox1.checked = true then toolbar1.visible := true
                                         else toolbar1.visible := false;
end;

so now if the checkbox is checked then the toolbar is vis else not vis...

Peace Scay7
0
 

Author Comment

by:ibrobar
ID: 16767165
Hi scay7

I tried your code before but it didn't work , i don't know why? is it possible cause under this toolbar i am using a listview in the form and when i am hiding the toolbar the listview is coming over it's place and then when i am clicking on the checkbox again to make it visible nothing is happing

Mike

i still didn't try your code , i will do it today

regards
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:ibrobar
ID: 16768483
Hi i tried Mike solution as well but it didn't work i think the problem is the listview item i am using in the same form.
by the way the align for the listview is none

regards
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16768553
Scay7, you shouldnt need to do so much code, the one line should handle both issues.
If the checkbox is checked then the result is true, therefore the visible option will be true.
If it isnt check it will result in checkbox.checked being false and thus get rid of the toolbar.

ibrobar have a look at this example
Ive done it 2 ways, one by checkbox, and one via the menu.

// --------- UNIT

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ToolWin, ComCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    ToolBar1: TToolBar;
    File1: TMenuItem;
    oolbar1: TMenuItem;
    Visible1: TMenuItem;
    invisible1: TMenuItem;
    GroupBox1: TGroupBox;
    ListView1: TListView;
    CheckBox1: TCheckBox;
    procedure Visible1Click(Sender: TObject);
    procedure invisible1Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Visible1Click(Sender: TObject);
begin
  ToolBar1.Visible := True;
end;

procedure TForm1.invisible1Click(Sender: TObject);
begin
  ToolBar1.Visible := False;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  ToolBar1.Visible := CheckBox1.Checked;
end;

end.

// ---------------

// ------- FORM

object Form1: TForm1
  Left = 290
  Top = 145
  Width = 870
  Height = 640
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ToolBar1: TToolBar
    Left = 0
    Top = 0
    Width = 862
    Height = 57
    Caption = 'ToolBar1'
    TabOrder = 0
  end
  object GroupBox1: TGroupBox
    Left = 0
    Top = 57
    Width = 862
    Height = 529
    Align = alClient
    TabOrder = 1
    object ListView1: TListView
      Left = 2
      Top = 15
      Width = 858
      Height = 512
      Align = alClient
      Columns = <>
      TabOrder = 0
    end
    object CheckBox1: TCheckBox
      Left = 8
      Top = 0
      Width = 97
      Height = 17
      Caption = 'Toolbar visible?'
      Checked = True
      State = cbChecked
      TabOrder = 1
      OnClick = CheckBox1Click
    end
  end
  object MainMenu1: TMainMenu
    Left = 128
    Top = 80
    object File1: TMenuItem
      Caption = 'File'
    end
    object oolbar1: TMenuItem
      Caption = 'Toolbar'
      object Visible1: TMenuItem
        Caption = 'Visible'
        OnClick = Visible1Click
      end
      object invisible1: TMenuItem
        Caption = 'Invisible'
        OnClick = invisible1Click
      end
    end
  end
end

// -----------
0
 
LVL 5

Expert Comment

by:Scay7
ID: 16770983
Mike ye i know but it tends to click in peoples mind as what they need to get it right...
Well for one that how i taught my self... so as time went on i simplified the code making it
shorter but i started doing it the long way...

Peace Scay7

P.S. its just advice nothing serious. I may be wrong, but i can also be right... :P
0
 

Author Comment

by:ibrobar
ID: 16774372
Hi thanks all

it was an easy problem but as i told you the problem wasn't from the code it was from the listview i am using within the form

regards
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

862 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