[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

Right mous click to open new dialog box/ or a new window with Memo in which can write and read

From a speedButon with OnMouse dow event i can open a folder open a File folder.

1.Next thing that i wont to do is to can control the color of a Font (nome of the button) with right mouse click: on first click to make it red and on next to make it black.
 And once the button is red i need to have a option to open a dialog box or a new window with Memo object in which i can write short text. And read it and edit it next time i click on this buton again.


2.I well use 100  of this buttons, so what steps should i take?
0
pr2501
Asked:
pr2501
1 Solution
 
SteveBayCommented:
You cannot change the font color of a TButton (Windows owns that property and will not give it up no mater what Delphi says). You can, however, change the color of a TBitBtn.

Use the following code with TBitBtn and you should get the start you need on this.
procedure TForm1.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);
var Btn : TBitBtn;
begin
	if (Button <> mbRight) or (not (Sender is TBitBtn))  then
		exit;
 
	if not (Sender is TBitBtn) then
		exit;
	btn := (Sender As TBitBtn);
	if Btn.Font.Color = clRed then
		Btn.Font.Color := clBlack
	else
		Btn.Font.Color := clRed;
 
end;
 
procedure TForm1.ButtonClick(Sender: TObject);
var Btn : TBitBtn;
begin
	if not (Sender is TBitBtn) then
		exit;
	btn := (Sender As TBitBtn);
	if Btn.Font.Color = clRed then
		begin
		DoOpenMemoDialog(Btn);
		Btn.Font.Color := clBlack;
		end;
end;
 
procedure TForm1.DoOpenMemoDialog(Sender: TObject);
begin
	ShowMessage( TButton(Sender).Caption + ' button was pressed');
end;

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now