mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-28 23:16:14 +02:00
MG: fixed example
git-svn-id: trunk@3582 -
This commit is contained in:
parent
865f0767aa
commit
e5283fc1bb
@ -25,7 +25,7 @@ unit notebku;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses Classes, SysUtils, Controls, Forms, ExtCtrls, Buttons{, TabNotBk};
|
uses Classes, SysUtils, Controls, Forms, ExtCtrls, Buttons;
|
||||||
|
|
||||||
type
|
type
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
@ -213,7 +213,7 @@ end;
|
|||||||
procedure TForm1.Button3Click(Sender: TObject);
|
procedure TForm1.Button3Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//writeln('Close Button Clicked');
|
//writeln('Close Button Clicked');
|
||||||
Free;
|
Close;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.Button4Click(Sender: TObject);
|
procedure TForm1.Button4Click(Sender: TObject);
|
||||||
@ -264,6 +264,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.5 2002/10/30 13:23:48 lazarus
|
||||||
|
MG: fixed example
|
||||||
|
|
||||||
Revision 1.4 2002/09/10 14:08:54 lazarus
|
Revision 1.4 2002/09/10 14:08:54 lazarus
|
||||||
MG: fixed compiling examples
|
MG: fixed compiling examples
|
||||||
|
|
||||||
|
@ -52,12 +52,10 @@ type
|
|||||||
Button5: TButton;
|
Button5: TButton;
|
||||||
Button6: TButton;
|
Button6: TButton;
|
||||||
Button7: TButton;
|
Button7: TButton;
|
||||||
mnuBarMain: TMenuBar;
|
mnuFile: TMainMenu;
|
||||||
mnuFile: TMenu;
|
|
||||||
itmFileQuit: TMenuItem;
|
itmFileQuit: TMenuItem;
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure LoadMainMenu;
|
procedure LoadMainMenu;
|
||||||
Procedure FormKill(Sender : TObject);
|
|
||||||
procedure mnuQuitClicked(Sender : TObject);
|
procedure mnuQuitClicked(Sender : TObject);
|
||||||
protected
|
protected
|
||||||
procedure Button1CLick(Sender : TObject);
|
procedure Button1CLick(Sender : TObject);
|
||||||
@ -152,19 +150,11 @@ Begin
|
|||||||
then Progre1.Position := Progre1.min;
|
then Progre1.Position := Progre1.min;
|
||||||
end;
|
end;
|
||||||
End;
|
End;
|
||||||
{------------------------------------------------------------------------------}
|
|
||||||
|
|
||||||
procedure TForm1.FormKill(Sender : TObject);
|
|
||||||
Begin
|
|
||||||
Application.terminate;
|
|
||||||
End;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
procedure TForm1.LoadMainMenu;
|
procedure TForm1.LoadMainMenu;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
OnDestroy := @FormKill;
|
|
||||||
|
|
||||||
{ set the height and width }
|
{ set the height and width }
|
||||||
Height := 350;
|
Height := 350;
|
||||||
Width := 700;
|
Width := 700;
|
||||||
@ -264,23 +254,15 @@ begin
|
|||||||
Button7.OnClick := @Button7Click;
|
Button7.OnClick := @Button7Click;
|
||||||
|
|
||||||
{ create a menubar }
|
{ create a menubar }
|
||||||
mnuFile := TMenu.Create(nil);
|
mnuFile := TMainMenu.Create(Self);
|
||||||
|
mnuFile.Name:='mnuFile';
|
||||||
|
Menu := mnuFile;
|
||||||
|
|
||||||
itmFileQuit := TMenuItem.Create(nil);
|
itmFileQuit := TMenuItem.Create(Self);
|
||||||
itmFileQuit.Caption := 'Quit';
|
itmFileQuit.Caption := 'Quit';
|
||||||
itmFileQuit.OnClick := @mnuQuitClicked;
|
itmFileQuit.OnClick := @mnuQuitClicked;
|
||||||
// itmFileQuit.Show;
|
mnuFile.Items.Add(itmFileQuit);
|
||||||
|
|
||||||
// mnuFile.AddMenuItem(itmFileQuit);
|
|
||||||
|
|
||||||
mnuBarMain := TMenuBar.Create(self);
|
|
||||||
{ mnuBarMain.Height := 25;
|
|
||||||
mnuBarMain.Width := Width;
|
|
||||||
mnuBarMain.Top := 0;
|
|
||||||
mnuBarMain.Left := 0;
|
|
||||||
} mnuBarMain.Show;
|
|
||||||
|
|
||||||
mnuBarMain.AddMenu('File',mnuFile);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
|
@ -38,70 +38,71 @@ uses
|
|||||||
SysUtils, ExtCtrls, Controls;
|
SysUtils, ExtCtrls, Controls;
|
||||||
|
|
||||||
type
|
type
|
||||||
TForm1 = class(TFORM)
|
TForm1 = class(TFORM)
|
||||||
public
|
public
|
||||||
Toolbar1 : TToolbar;
|
Toolbar1 : TToolbar;
|
||||||
Toolbutton1 : TToolbutton;
|
Toolbutton1 : TToolbutton;
|
||||||
Toolbutton2 : TToolbutton;
|
Toolbutton2 : TToolbutton;
|
||||||
Toolbutton3 : TToolbutton;
|
Toolbutton3 : TToolbutton;
|
||||||
ComboBox1 : TComboBox;
|
ComboBox1 : TComboBox;
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
Procedure FormKill(Sender : TObject);
|
protected
|
||||||
protected
|
|
||||||
Procedure Button1Click(Sender : TObject);
|
Procedure Button1Click(Sender : TObject);
|
||||||
Procedure Button2Click(Sender : TObject);
|
Procedure Button2Click(Sender : TObject);
|
||||||
Procedure Button3Click(Sender : TObject);
|
Procedure Button3Click(Sender : TObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Form1 : TForm1;
|
Form1 : TForm1;
|
||||||
|
|
||||||
constructor TForm1.Create(AOwner: TComponent);
|
constructor TForm1.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
Name:='Form1';
|
||||||
Caption := 'Toolbar Demo v0.1';
|
Caption := 'Toolbar Demo v0.1';
|
||||||
OnDestroy := @FormKill;
|
{ set the height and width }
|
||||||
|
Height := 350;
|
||||||
{ set the height and width }
|
Width := 700;
|
||||||
Height := 350;
|
|
||||||
Width := 700;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ToolBar1 := TToolbar.Create(Self);
|
ToolBar1 := TToolbar.Create(Self);
|
||||||
with Toolbar1 do
|
with Toolbar1 do
|
||||||
begin
|
begin
|
||||||
|
Name:='ToolBar1';
|
||||||
Parent := Self;
|
Parent := Self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Toolbutton1 := TToolButton.Create(Toolbar1);
|
Toolbutton1 := TToolButton.Create(Toolbar1);
|
||||||
with ToolButton1 do
|
with ToolButton1 do
|
||||||
Begin
|
Begin
|
||||||
Writeln('SETTING PARENT');
|
Name:='Toolbutton1';
|
||||||
Parent := Toolbar1;
|
Parent := Toolbar1;
|
||||||
Caption := '1';
|
Caption := '1';
|
||||||
Style := tbsButton;
|
Style := tbsButton;
|
||||||
OnClick := @Button1Click;
|
OnClick := @Button1Click;
|
||||||
Show;
|
Show;
|
||||||
end;
|
end;
|
||||||
|
writeln('AAA1');
|
||||||
Toolbutton2 := TToolButton.Create(Toolbar1);
|
Toolbutton2 := TToolButton.Create(Toolbar1);
|
||||||
with ToolButton2 do
|
with ToolButton2 do
|
||||||
Begin
|
Begin
|
||||||
Writeln('SETTING PARENT');
|
Name:='Toolbutton2';
|
||||||
|
writeln('AAA2');
|
||||||
Parent := Toolbar1;
|
Parent := Toolbar1;
|
||||||
Caption := '2';
|
writeln('AAA3');
|
||||||
|
Caption := '2';
|
||||||
|
writeln('AAA3');
|
||||||
Style := tbsButton;
|
Style := tbsButton;
|
||||||
|
writeln('AAA4');
|
||||||
OnClick := @Button2Click;
|
OnClick := @Button2Click;
|
||||||
|
writeln('AAA5');
|
||||||
Show;
|
Show;
|
||||||
end;
|
end;
|
||||||
|
writeln('AAA2');
|
||||||
Toolbutton3 := TToolButton.Create(Toolbar1);
|
Toolbutton3 := TToolButton.Create(Toolbar1);
|
||||||
with ToolButton3 do
|
with ToolButton3 do
|
||||||
Begin
|
Begin
|
||||||
Writeln('SETTING PARENT');
|
|
||||||
Parent := Toolbar1;
|
Parent := Toolbar1;
|
||||||
Caption := '3';
|
Caption := '3';
|
||||||
Style := tbsButton;
|
Style := tbsButton;
|
||||||
OnClick := @Button3Click;
|
OnClick := @Button3Click;
|
||||||
Show;
|
Show;
|
||||||
@ -111,7 +112,6 @@ with ToolButton3 do
|
|||||||
ComboBox1 := TComboBox.Create(Self);
|
ComboBox1 := TComboBox.Create(Self);
|
||||||
with ComboBox1 do
|
with ComboBox1 do
|
||||||
Begin
|
Begin
|
||||||
Writeln('SETTING PARENT');
|
|
||||||
Parent := Toolbar1;
|
Parent := Toolbar1;
|
||||||
Items.Add('Item1');
|
Items.Add('Item1');
|
||||||
Items.Add('Item2');
|
Items.Add('Item2');
|
||||||
@ -139,14 +139,14 @@ Writeln('Toolbar button 1 clicked!');
|
|||||||
Writeln('******************');
|
Writeln('******************');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TFORM1.Button2Click(Sender : TObject);
|
Procedure TFORM1.Button2Click(Sender : TObject);
|
||||||
Begin
|
Begin
|
||||||
Writeln('******************');
|
Writeln('******************');
|
||||||
Writeln('Toolbar button 2 clicked!');
|
Writeln('Toolbar button 2 clicked!');
|
||||||
Writeln('******************');
|
Writeln('******************');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TFORM1.Button3Click(Sender : TObject);
|
Procedure TFORM1.Button3Click(Sender : TObject);
|
||||||
Begin
|
Begin
|
||||||
Writeln('******************');
|
Writeln('******************');
|
||||||
Writeln('Toolbar button 3 clicked!');
|
Writeln('Toolbar button 3 clicked!');
|
||||||
@ -154,11 +154,6 @@ Writeln('******************');
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TForm1.FormKill(Sender : TObject);
|
|
||||||
Begin
|
|
||||||
Application.terminate;
|
|
||||||
End;
|
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Application.Initialize; { calls InitProcedure which starts up GTK }
|
Application.Initialize; { calls InitProcedure which starts up GTK }
|
||||||
|
@ -38,9 +38,9 @@ unit ComCtrls;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, Classes, Controls, Forms, LclLinux, LCLType, StdCtrls, ExtCtrls,
|
SysUtils, Classes, Controls, Forms, LclLinux, LCLType, LCLProc, StdCtrls,
|
||||||
vclGlobals, lMessages, Menus, ImgList, GraphType, Graphics, ToolWin, CommCtrl,
|
ExtCtrls, vclGlobals, lMessages, Menus, ImgList, GraphType, Graphics, ToolWin,
|
||||||
Buttons;
|
CommCtrl, Buttons;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -1698,6 +1698,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.57 2002/10/30 13:20:10 lazarus
|
||||||
|
MG: fixed example
|
||||||
|
|
||||||
Revision 1.56 2002/10/26 11:20:29 lazarus
|
Revision 1.56 2002/10/26 11:20:29 lazarus
|
||||||
MG: broke some interfaces.pp circles
|
MG: broke some interfaces.pp circles
|
||||||
|
|
||||||
|
@ -25,13 +25,10 @@
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
constructor TToolbar.Create(AOwner : TComponent);
|
constructor TToolbar.Create(AOwner : TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
|
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
|
||||||
csDoubleClicks, csMenuEvents, csSetCaption];
|
csDoubleClicks, csMenuEvents, csSetCaption];
|
||||||
Left := 1;
|
SetBounds(1,1,150,29);
|
||||||
Top := 1;
|
|
||||||
Width := 150;
|
|
||||||
Height := 29;
|
|
||||||
Align := alTop;
|
Align := alTop;
|
||||||
EdgeBorders := [ebTop];
|
EdgeBorders := [ebTop];
|
||||||
FButtonWidth := 23;
|
FButtonWidth := 23;
|
||||||
@ -55,12 +52,13 @@ destructor TToolBar.Destroy;
|
|||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
FNullBitmap.Free;
|
FreeThenNil(FNullBitmap);
|
||||||
|
|
||||||
for I := 0 to FButtons.Count - 1 do
|
for I := 0 to FButtons.Count - 1 do
|
||||||
if TControl(FButtons[I]) is TToolButton then
|
if TControl(FButtons[I]) is TToolButton then
|
||||||
TToolButton(FButtons[I]).FToolBar := nil;
|
TToolButton(FButtons[I]).FToolBar := nil;
|
||||||
FButtons.Free;
|
|
||||||
|
FreeThenNil(FButtons);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -74,7 +72,9 @@ const
|
|||||||
TransparentStyles: array[Boolean] of DWORD = (0, TBSTYLE_TRANSPARENT);
|
TransparentStyles: array[Boolean] of DWORD = (0, TBSTYLE_TRANSPARENT);
|
||||||
begin
|
begin
|
||||||
FNewStyle := InitCommonControl(ICC_BAR_CLASSES);
|
FNewStyle := InitCommonControl(ICC_BAR_CLASSES);
|
||||||
|
|
||||||
inherited CreateParams(Params);
|
inherited CreateParams(Params);
|
||||||
|
|
||||||
CreateSubClass(Params, TOOLBARCLASSNAME);
|
CreateSubClass(Params, TOOLBARCLASSNAME);
|
||||||
with Params do
|
with Params do
|
||||||
begin
|
begin
|
||||||
@ -82,7 +82,7 @@ begin
|
|||||||
or TransparentStyles[FTransparent];
|
or TransparentStyles[FTransparent];
|
||||||
if ShowCaptions then
|
if ShowCaptions then
|
||||||
Style := Style or TBSTYLE_TRANSPARENT;
|
Style := Style or TBSTYLE_TRANSPARENT;
|
||||||
WindowClass.style := WindowClass.style and
|
WindowClass.style := WindowClass.style and
|
||||||
not Cardinal(CS_HREDRAW or CS_VREDRAW);
|
not Cardinal(CS_HREDRAW or CS_VREDRAW);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -99,8 +99,8 @@ var
|
|||||||
begin
|
begin
|
||||||
inherited CreateWnd;
|
inherited CreateWnd;
|
||||||
|
|
||||||
Perform(TB_SETEXTENDEDSTYLE, 0, Perform(TB_GETEXTENDEDSTYLE, 0, 0) or
|
Perform(TB_SETEXTENDEDSTYLE, 0, Perform(TB_GETEXTENDEDSTYLE, 0, 0) or
|
||||||
TBSTYLE_EX_DRAWDDARROWS);
|
TBSTYLE_EX_DRAWDDARROWS);
|
||||||
FOldHandle := 0;
|
FOldHandle := 0;
|
||||||
StockFont := GetStockObject(SYSTEM_FONT);
|
StockFont := GetStockObject(SYSTEM_FONT);
|
||||||
if StockFont <> 0 then
|
if StockFont <> 0 then
|
||||||
@ -130,9 +130,9 @@ procedure TToolBar.CreateButtons(NewWidth, NewHeight: Integer);
|
|||||||
for I := 0 to FButtons.Count - 1 do
|
for I := 0 to FButtons.Count - 1 do
|
||||||
begin
|
begin
|
||||||
Control := TControl(FButtons[I]);
|
Control := TControl(FButtons[I]);
|
||||||
if (Control is TToolButton) and ((csDesigning in ComponentState) or
|
if (Control is TToolButton)
|
||||||
Control.Visible) and not (TToolButton(Control).Style in
|
and ((csDesigning in ComponentState) or Control.Visible)
|
||||||
[tbsSeparator, tbsDivider]) then
|
and not (TToolButton(Control).Style in [tbsSeparator, tbsDivider]) then
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
Exit;
|
Exit;
|
||||||
@ -145,10 +145,9 @@ var
|
|||||||
ImageWidth, ImageHeight: Integer;
|
ImageWidth, ImageHeight: Integer;
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
Assert(False, 'Trace:IN TTOOLBAR.CREATEBUTTONS');
|
if not HandleAllocated then exit;
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
try
|
try
|
||||||
HandleNeeded;
|
|
||||||
Perform(TB_BUTTONSTRUCTSIZE, SizeOf(TTBButton), 0);
|
Perform(TB_BUTTONSTRUCTSIZE, SizeOf(TTBButton), 0);
|
||||||
Perform(TB_SETINDENT, FIndent, 0);
|
Perform(TB_SETINDENT, FIndent, 0);
|
||||||
if FImages <> nil then
|
if FImages <> nil then
|
||||||
@ -156,13 +155,13 @@ Assert(False, 'Trace:IN TTOOLBAR.CREATEBUTTONS');
|
|||||||
ImageWidth := FImages.Width;
|
ImageWidth := FImages.Width;
|
||||||
ImageHeight := FImages.Height;
|
ImageHeight := FImages.Height;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if FDisabledImages <> nil then
|
if FDisabledImages <> nil then
|
||||||
begin
|
begin
|
||||||
ImageWidth := FDisabledImages.Width;
|
ImageWidth := FDisabledImages.Width;
|
||||||
ImageHeight := FDisabledImages.Height;
|
ImageHeight := FDisabledImages.Height;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if FHotImages <> nil then
|
if FHotImages <> nil then
|
||||||
begin
|
begin
|
||||||
ImageWidth := FHotImages.Width;
|
ImageWidth := FHotImages.Width;
|
||||||
@ -186,10 +185,10 @@ Assert(False, 'Trace:IN TTOOLBAR.CREATEBUTTONS');
|
|||||||
EndUpdate;
|
EndUpdate;
|
||||||
end;
|
end;
|
||||||
Assert(False, Format('Trace:INTERNALBUTTONCOUNT = %d',[INTERNALBUTTONCOUNT]));
|
Assert(False, Format('Trace:INTERNALBUTTONCOUNT = %d',[INTERNALBUTTONCOUNT]));
|
||||||
for I := 0 to InternalButtonCount - 1 do
|
for I := 0 to InternalButtonCount - 1 do
|
||||||
begin
|
begin
|
||||||
Perform(TB_DELETEBUTTON, 0, 0);
|
Perform(TB_DELETEBUTTON, 0, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
UpdateImages;
|
UpdateImages;
|
||||||
@ -204,7 +203,8 @@ var
|
|||||||
AdjustY: Integer;
|
AdjustY: Integer;
|
||||||
begin
|
begin
|
||||||
if (csLoading in ComponentState) or
|
if (csLoading in ComponentState) or
|
||||||
(Perform(TB_GETBUTTON, Index, Longint(@TBButton)) = 0) then
|
(Perform(TB_GETBUTTON, Index, Longint(@TBButton)) = 0)
|
||||||
|
then
|
||||||
Exit;
|
Exit;
|
||||||
if Perform(TB_GETITEMRECT, Index, Longint(@R)) <> 0 then
|
if Perform(TB_GETITEMRECT, Index, Longint(@R)) <> 0 then
|
||||||
begin
|
begin
|
||||||
@ -214,7 +214,8 @@ begin
|
|||||||
if not (Button is TToolButton) then
|
if not (Button is TToolButton) then
|
||||||
with Button do
|
with Button do
|
||||||
begin
|
begin
|
||||||
if Button is TWinControl then HandleNeeded;
|
if HandleAllocated and (Button is TWinControl) then
|
||||||
|
HandleNeeded;
|
||||||
|
|
||||||
BoundsRect := R;
|
BoundsRect := R;
|
||||||
if Height < R.Bottom - R.Top then
|
if Height < R.Bottom - R.Top then
|
||||||
@ -251,9 +252,9 @@ var
|
|||||||
begin
|
begin
|
||||||
if HandleAllocated then
|
if HandleAllocated then
|
||||||
begin
|
begin
|
||||||
LastIndex := Perform(TB_GETBUTTONSIZE, 0, 0);
|
LastIndex := Perform(TB_GETBUTTONSIZE, 0, 0);
|
||||||
AHeight := LastIndex shr 16;
|
AHeight := LastIndex shr 16;
|
||||||
AWidth := LastIndex and $FFFF;
|
AWidth := LastIndex and $FFFF;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -279,7 +280,7 @@ procedure TToolBar.InsertButton(Control: TControl);
|
|||||||
var
|
var
|
||||||
FromIndex, ToIndex: Integer;
|
FromIndex, ToIndex: Integer;
|
||||||
begin
|
begin
|
||||||
if Control is TToolButton then
|
if Control is TToolButton then
|
||||||
Begin
|
Begin
|
||||||
TToolButton(Control).FToolBar := Self;
|
TToolButton(Control).FToolBar := Self;
|
||||||
TToolButton(Control).HandleNeeded;
|
TToolButton(Control).HandleNeeded;
|
||||||
@ -299,7 +300,8 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
ToIndex := FButtons.Add(Control);
|
ToIndex := FButtons.Add(Control);
|
||||||
if TToolbutton(Control).Handle = 0 then TToolButton(Control).HandleNeeded;
|
if HandleAllocated and (Control is TToolButton) then
|
||||||
|
TToolButton(Control).HandleNeeded;
|
||||||
UpdateButton(ToIndex);
|
UpdateButton(ToIndex);
|
||||||
end;
|
end;
|
||||||
if Wrapable then
|
if Wrapable then
|
||||||
@ -357,7 +359,7 @@ begin
|
|||||||
with Button do
|
with Button do
|
||||||
begin
|
begin
|
||||||
fsStyle := ButtonStyles[Style];
|
fsStyle := ButtonStyles[Style];
|
||||||
if AutoSize then
|
if AutoSize then
|
||||||
fsStyle := fsStyle or TBSTYLE_AUTOSIZE;
|
fsStyle := fsStyle or TBSTYLE_AUTOSIZE;
|
||||||
end;
|
end;
|
||||||
Button.fsState := GetButtonState;
|
Button.fsState := GetButtonState;
|
||||||
@ -372,11 +374,11 @@ begin
|
|||||||
captions. If any one button's caption is empty (-1) then none of
|
captions. If any one button's caption is empty (-1) then none of
|
||||||
the buttons' captions will not be displayed. }
|
the buttons' captions will not be displayed. }
|
||||||
CaptionText := ' ';
|
CaptionText := ' ';
|
||||||
|
{ TB_ADDSTRING requires two null terminators }
|
||||||
Buffer:=StrAlloc(length(CaptionText)+2);
|
Buffer:=StrAlloc(length(CaptionText)+2);
|
||||||
try
|
try
|
||||||
StrPCopy(Buffer, CaptionText);
|
StrPCopy(Buffer, CaptionText);
|
||||||
{ TB_ADDSTRING requires two null terminators }
|
Buffer[Length(CaptionText)+1] := #0;
|
||||||
Buffer[Length(CaptionText) + 1] := #0;
|
|
||||||
Button.iString := Self.Perform(TB_ADDSTRING, 0, Longint(@Buffer));
|
Button.iString := Self.Perform(TB_ADDSTRING, 0, Longint(@Buffer));
|
||||||
finally
|
finally
|
||||||
StrDispose(Buffer);
|
StrDispose(Buffer);
|
||||||
@ -445,10 +447,10 @@ begin
|
|||||||
captions. If any one button's caption is empty (-1) then none of
|
captions. If any one button's caption is empty (-1) then none of
|
||||||
the buttons' captions will not be displayed. }
|
the buttons' captions will not be displayed. }
|
||||||
CaptionText := ' ';
|
CaptionText := ' ';
|
||||||
|
{ TB_ADDSTRING requires two null terminators }
|
||||||
Buffer:=StrAlloc(length(CaptionText)+2);
|
Buffer:=StrAlloc(length(CaptionText)+2);
|
||||||
try
|
try
|
||||||
StrPCopy(Buffer, CaptionText);
|
StrPCopy(Buffer, CaptionText);
|
||||||
{ TB_ADDSTRING requires two null terminators }
|
|
||||||
Buffer[Length(CaptionText) + 1] := #0;
|
Buffer[Length(CaptionText) + 1] := #0;
|
||||||
//Button.iString := Self.Perform(TB_ADDSTRING, 0, Longint(@Buffer));
|
//Button.iString := Self.Perform(TB_ADDSTRING, 0, Longint(@Buffer));
|
||||||
finally
|
finally
|
||||||
@ -493,32 +495,34 @@ function TToolBar.RefreshButton(Index: Integer): Boolean;
|
|||||||
var
|
var
|
||||||
Style: Longint;
|
Style: Longint;
|
||||||
begin
|
begin
|
||||||
if not (csLoading in ComponentState) and (FUpdateCount = 0) then
|
Result:=false;
|
||||||
begin
|
if not (csLoading in ComponentState) and (FUpdateCount = 0)
|
||||||
BeginUpdate;
|
or (not HandleAllocated) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
Style := GetWindowLong(Handle, GWL_STYLE);
|
||||||
|
SetWindowLong(Handle, GWL_STYLE, Style and not WS_VISIBLE);
|
||||||
try
|
try
|
||||||
Style := GetWindowLong(Handle, GWL_STYLE);
|
Result := (Index < InternalButtonCount) and
|
||||||
SetWindowLong(Handle, GWL_STYLE, Style and not WS_VISIBLE);
|
UpdateItem(TB_DELETEBUTTON, Index, Index) and
|
||||||
try
|
UpdateItem(TB_INSERTBUTTON, Index, Index);
|
||||||
Result := (Index < InternalButtonCount) and
|
|
||||||
UpdateItem(TB_DELETEBUTTON, Index, Index) and
|
|
||||||
UpdateItem(TB_INSERTBUTTON, Index, Index);
|
|
||||||
finally
|
|
||||||
SetWindowLong(Handle, GWL_STYLE, Style);
|
|
||||||
end;
|
|
||||||
finally
|
finally
|
||||||
EndUpdate;
|
SetWindowLong(Handle, GWL_STYLE, Style);
|
||||||
end;
|
end;
|
||||||
end
|
finally
|
||||||
else
|
EndUpdate;
|
||||||
Result := False;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TToolBar.UpdateButton(Index: Integer);
|
procedure TToolBar.UpdateButton(Index: Integer);
|
||||||
var
|
var
|
||||||
Style: Longint;
|
Style: Longint;
|
||||||
begin
|
begin
|
||||||
if (csLoading in ComponentState) or (FUpdateCount > 0) then Exit;
|
if (csLoading in ComponentState) or (FUpdateCount > 0)
|
||||||
|
or (not HandleAllocated)then Exit;
|
||||||
|
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
try
|
try
|
||||||
HandleNeeded;
|
HandleNeeded;
|
||||||
@ -547,6 +551,8 @@ var
|
|||||||
Style: Longint;
|
Style: Longint;
|
||||||
begin
|
begin
|
||||||
Assert(False, 'Trace:IN TTOOLBAR.UPDATEBUTTONS');
|
Assert(False, 'Trace:IN TTOOLBAR.UPDATEBUTTONS');
|
||||||
|
if not HandleAllocated then exit;
|
||||||
|
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
try
|
try
|
||||||
HandleNeeded;
|
HandleNeeded;
|
||||||
@ -558,7 +564,7 @@ Assert(False, 'Trace:IN TTOOLBAR.UPDATEBUTTONS');
|
|||||||
for I := 0 to FButtons.Count - 1 do
|
for I := 0 to FButtons.Count - 1 do
|
||||||
begin
|
begin
|
||||||
if I < Count then
|
if I < Count then
|
||||||
Begin
|
Begin
|
||||||
Assert(False, Format('Trace:????CALLING UPDATEITEM2??????????? I , Count = %d,%d',[I,Count]));
|
Assert(False, Format('Trace:????CALLING UPDATEITEM2??????????? I , Count = %d,%d',[I,Count]));
|
||||||
UpdateItem2(TB_SETBUTTONINFO, I, I)
|
UpdateItem2(TB_SETBUTTONINFO, I, I)
|
||||||
end
|
end
|
||||||
@ -629,7 +635,8 @@ begin
|
|||||||
if FList <> Value then
|
if FList <> Value then
|
||||||
begin
|
begin
|
||||||
FList := Value;
|
FList := Value;
|
||||||
RecreateWnd;
|
if HandleAllocated then
|
||||||
|
RecreateWnd;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -639,7 +646,8 @@ begin
|
|||||||
if FFlat <> Value then
|
if FFlat <> Value then
|
||||||
begin
|
begin
|
||||||
FFlat := Value;
|
FFlat := Value;
|
||||||
RecreateWnd;
|
if HandleAllocated then
|
||||||
|
RecreateWnd;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -648,7 +656,8 @@ begin
|
|||||||
if FTransparent <> Value then
|
if FTransparent <> Value then
|
||||||
begin
|
begin
|
||||||
FTransparent := Value;
|
FTransparent := Value;
|
||||||
RecreateWnd;
|
if HandleAllocated then
|
||||||
|
RecreateWnd;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -830,19 +839,18 @@ begin
|
|||||||
if FIndent <> Value then
|
if FIndent <> Value then
|
||||||
begin
|
begin
|
||||||
FIndent := Value;
|
FIndent := Value;
|
||||||
RecreateWnd;
|
if HandleAllocated then
|
||||||
|
RecreateWnd;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TToolBar.RecreateButtons;
|
procedure TToolBar.RecreateButtons;
|
||||||
begin
|
begin
|
||||||
if not (csLoading in ComponentState) or HandleAllocated then
|
if not (csLoading in ComponentState) and HandleAllocated then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
CreateButtons(FButtonWidth, FButtonHeight);
|
CreateButtons(FButtonWidth, FButtonHeight);
|
||||||
ResizeButtons;
|
ResizeButtons;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TToolBar.WMKeyDown(var Message: TLMKeyDown);
|
procedure TToolBar.WMKeyDown(var Message: TLMKeyDown);
|
||||||
@ -920,7 +928,8 @@ end;
|
|||||||
function TToolBar.InternalButtonCount: Integer;
|
function TToolBar.InternalButtonCount: Integer;
|
||||||
begin
|
begin
|
||||||
// Result := Perform(TB_BUTTONCOUNT, 0, 0);
|
// Result := Perform(TB_BUTTONCOUNT, 0, 0);
|
||||||
Result := CNSendMessage(LM_TB_BUTTONCOUNT,Self,Nil);
|
if HandleAllocated then
|
||||||
|
Result := CNSendMessage(LM_TB_BUTTONCOUNT,Self,Nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TToolBar.ButtonIndex(OldIndex, ALeft, ATop: Integer): Integer;
|
function TToolBar.ButtonIndex(OldIndex, ALeft, ATop: Integer): Integer;
|
||||||
@ -1246,13 +1255,13 @@ case Message.msg of
|
|||||||
LM_SHOWMODAL : Assert(False, 'Trace:!!!!!!!!!!!!!!!!!!!!!!LM_SHOWMODAL!!!!!!!!!!!!!!!!!!!');
|
LM_SHOWMODAL : Assert(False, 'Trace:!!!!!!!!!!!!!!!!!!!!!!LM_SHOWMODAL!!!!!!!!!!!!!!!!!!!');
|
||||||
end;
|
end;
|
||||||
case Message.msg of
|
case Message.msg of
|
||||||
TB_INSERTBUTTON : Begin
|
TB_INSERTBUTTON :
|
||||||
CNSendMessage(LM_INSERTTOOLBUTTON,TControl(TTBButton(Pointer(Message.lParam)^).dwData),nil);
|
if HandleAllocated then
|
||||||
end;
|
CNSendMessage(LM_INSERTTOOLBUTTON,TControl(TTBButton(Pointer(Message.lParam)^).dwData),nil);
|
||||||
TB_DELETEBUTTON : Begin
|
|
||||||
CNSendMessage(LM_DELETETOOLBUTTON,TControl(FButtons[Message.wparam]),nil);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
TB_DELETEBUTTON :
|
||||||
|
if HandleAllocated then
|
||||||
|
CNSendMessage(LM_DELETETOOLBUTTON,TControl(FButtons[Message.wparam]),nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1274,7 +1283,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ToolMenuGetMsgHook(Code: Integer; WParam: Longint;
|
function ToolMenuGetMsgHook(Code: Integer; WParam: Longint;
|
||||||
var Msg: TMsg): Longint; stdcall;
|
var Msg: TMsg): Longint; stdcall;
|
||||||
Begin
|
Begin
|
||||||
// ToDo
|
// ToDo
|
||||||
@ -1290,7 +1299,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ToolMenuKeyMsgHook(Code: Integer; WParam: Longint;
|
function ToolMenuKeyMsgHook(Code: Integer; WParam: Longint;
|
||||||
var Msg: TMsg): Longint; stdcall;
|
var Msg: TMsg): Longint; stdcall;
|
||||||
begin
|
begin
|
||||||
// ToDo
|
// ToDo
|
||||||
@ -1493,6 +1502,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.7 2002/10/30 13:20:10 lazarus
|
||||||
|
MG: fixed example
|
||||||
|
|
||||||
Revision 1.6 2002/05/10 06:05:55 lazarus
|
Revision 1.6 2002/05/10 06:05:55 lazarus
|
||||||
MG: changed license to LGPL
|
MG: changed license to LGPL
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user