Recent

Author Topic: Richmemo Bug Using ComboBox?  (Read 371 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Richmemo Bug Using ComboBox?
« on: July 04, 2020, 05:07:53 pm »
Below is a code execution error when using a ComboBox on the change event

Win32RichmemoProc.pas

Code: Pascal  [Select][+][-]
  1. function VScriptPosToEffects(vpos: TVScriptPos): LongWord;
  2. const
  3.   EffMask : array [TVScriptPos] of LongWord = (0, CFE_SUBSCRIPT, CFE_SUPERSCRIPT);
  4. begin
  5.   Result:=EffMask[vpos];  <--- ERROR IS HERE
  6. end;
  7.  

This is the code in the code event of the comboxbox.
As well, I also tested it on a normal button and the code works fine and changes my font size

Code: Pascal  [Select][+][-]
  1. var
  2.   fnt : TFontParams;
  3. begin
  4.   fnt.Name:='';
  5.   fnt.Style:= []; //[fsBold or Italic];
  6.   fnt.Size:=24;
  7.  
  8.   txtNote1.SetTextAttributes(txtNote1.SelStart, txtNote1.SelLength, fnt);
  9.   txtNote1.SetFocus();

So, something in RichMemo doesn't like the combo change event or my code
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

paweld

  • Full Member
  • ***
  • Posts: 241
Re: Richmemo Bug Using ComboBox?
« Reply #1 on: July 04, 2020, 09:49:33 pm »
you must initialize font params:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.ChangeFontParam(Sender: TObject);
  2. var
  3.   fnt : TFontParams;
  4. begin
  5.   InitFontParams(fnt); //<---
  6.   if ComboBoxFontName.ItemIndex>=0 then
  7.   fnt.Name:=ComboBoxFontName.Text;
  8.   fnt.Style:= [];
  9.   if ComboBoxFontSize.ItemIndex>=0 then
  10.   fnt.Size:=StrToInt(ComboBoxFontSize.Text);
  11.   RichMemo1.SetTextAttributes(RichMemo1.SelStart, RichMemo1.SelLength, fnt);
  12.   RichMemo1.SetFocus();
  13. end;
  14.  
  15. procedure TForm1.FormCreate(Sender: TObject);
  16. begin
  17.   //font name
  18.   ComboBoxFontName.Items.Clear;
  19.   ComboBoxFontName.Items.Add('Arial');
  20.   ComboBoxFontName.Items.Add('Courier New');
  21.   ComboBoxFontName.Items.Add('Times New Roman');
  22.   ComboBoxFontName.Style:=csDropDownList;
  23.   ComboBoxFontName.OnChange:=@ChangeFontParam;
  24.   //fontsize
  25.   ComboBoxFontSize.Items.Clear;
  26.   ComboBoxFontSize.Items.Add('12');
  27.   ComboBoxFontSize.Items.Add('18');
  28.   ComboBoxFontSize.Items.Add('24');
  29.   ComboBoxFontSize.Items.Add('36');
  30.   ComboBoxFontSize.Items.Add('48');
  31.   ComboBoxFontSize.Items.Add('72');
  32.   ComboBoxFontSize.Style:=csDropDownList;
  33.   ComboBoxFontSize.OnChange:=@ChangeFontParam;
  34. end;
Best regards
paweld

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Richmemo Bug Using ComboBox?
« Reply #2 on: July 05, 2020, 11:04:07 am »
thanks, i will give it a try
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

 

TinyPortal © 2005-2018