RAD Studio |  |

Changing the Tool with Speed Buttons
See Also
Collapse All

Each drawing tool needs an associated OnClick event handler. Suppose your application had a toolbar button for each of four drawing tools: line, rectangle, ellipse, and rounded rectangle. You would attach the following event handlers to the OnClick events of the four drawing-tool buttons, setting DrawingTool to the appropriate value for each:

Copy Code

    procedure TForm1.LineButtonClick(Sender: TObject);{ LineButton }
    begin
    DrawingTool := dtLine;
    end;
    procedure TForm1.RectangleButtonClick(Sender: TObject);{ RectangleButton }
    begin
    DrawingTool := dtRectangle;
    end;
    procedure TForm1.EllipseButtonClick(Sender: TObject);{ EllipseButton }
    begin
    DrawingTool := dtEllipse;
    end;
    procedure TForm1.RoundedRectButtonClick(Sender: TObject);{ RoundRectButton }
    begin
    DrawingTool := dtRoundRect;
    end;

Copy Code

    void __fastcall TForm1::LineButtonClick(TObject *Sender)  // LineButton
    {
      DrawingTool = dtLine;
    }
    void __fastcall TForm1::RectangleButtonClick(TObject *Sender) // RectangleButton
    {
      DrawingTool = dtRectangle;
    }
    void __fastcall TForm1::EllipseButtonClick(TObject *Sender)  // EllipseButton
    {
      DrawingTool = dtEllipse;
    }
    void __fastcall TForm1::RoundedRectButtonClick(TObject *Sender) // RoundRectBtn
    {
      DrawingTool = dtRoundRect;
    }

See Also

Keeping Track of Which Drawing Tool to Use

Using Drawing Tools

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!