Changing the Tool with Speed Buttons

From RAD Studio
Jump to: navigation, search

Go Up to Handling Multiple Drawing Objects in Your Application


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:

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