I have next code for that. I click on a type TSpeedButton to launch the procedure and all is well
const
{ Parameters for ApplyStyleConversion }
TEXT_BOLD = 1;
TEXT_ITALIC = 2;
TEXT_UNDERLINE = 3;
{ bold, italic, underline }
procedure TSDIAppForm.btnEstiloFuenteClick(Sender: TObject);
var
button: TSpeedButton;
begin
button := Sender as TSpeedButton;
{ constants TEXT_BOLD, TEXT_ITALIC and TEXT_UNDERLINE are
assigned to the tags of corresponding buttons }
EditorNotas.ApplyStyleConversion(Button.Tag);
end;
I need to do the same with the right mouse button from the tdbrichviewedit popup menu. What would be the necessary code
Thank in advance.
Switch selected information in tdbrichviewdit to bold/normal
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you want to implement the same command executed by several controls (a button and a menu item), the best way is using actions.
1) Place TActionList component on the form. In this action list, using "New Action" command, add 3 actions. Rename them to actBold, actItalic, actUnderline
2) Assign their tags equal to TEXT_* constants, i,e. actBold.Tag=1, actItalic.Tag=2, actUnderline.Tag=3.
3) Assign OnExecute event for all these actions:
4) In OnCurTextStyleChanged, change
to
5) In OnStyleConversion, change
to
The same for Italic and Underline
7) Delete btnEstiloFuenteClick
6) Assign the actions for menu items and buttons.
1) Place TActionList component on the form. In this action list, using "New Action" command, add 3 actions. Rename them to actBold, actItalic, actUnderline
2) Assign their tags equal to TEXT_* constants, i,e. actBold.Tag=1, actItalic.Tag=2, actUnderline.Tag=3.
3) Assign OnExecute event for all these actions:
Code: Select all
procedure TForm1.ActionTextStyleExecute(Sender: TObject);
var Action: TAction;
begin
Action := Sender as TAction;
Action.Checked := not Action.Checked;
ActiveEditor.ApplyStyleConversion(Action.Tag);
end;
Code: Select all
btnBold.Down := fsBold in fi.Style;
btnItalic.Down := fsItalic in fi.Style;
btnUnderline.Down := fsUnderline in fi.Style;
Code: Select all
actBold.Checked := fsBold in fi.Style;
actItalic.Checked := fsItalic in fi.Style;
actUnderline.Checked := fsUnderline in fi.Style;
Code: Select all
if btnBold.Down then
Code: Select all
if actBold.Checked then
7) Delete btnEstiloFuenteClick
6) Assign the actions for menu items and buttons.
Switch selected information in tdbrichviewdit to bold/normal
Hello
Your solution works perfectly
Thank you very much for your time and your attention
Your solution works perfectly
Thank you very much for your time and your attention