setting the charset on a TrzRichEdit at runtime

Home Forums Konopka Signature VCL Controls (formerly Raize Components) setting the charset on a TrzRichEdit at runtime

Viewing 1 reply thread
  • Author
    Posts
    • #3670
      Steve Black
      Participant

        Delphi 7.0 / Win 10 / Raise 5.51
        I need to change the character set on some controls from the default into chinese at runtime.  I use the following proc to do it:

        procedure UT_Set_Charset(TheCtrl: TObject);
        // *****************************************************************************
        // this proc will set the correct charset based on users lcid
        // *****************************************************************************
        var DecVal: Integer; // LCID decimal value as integer
        HexVal: String; // LCID hex value as string
        begin
        
        DecVal := GetSystemDefaultLCID; // get LCID as decimal
        HexVal := IntToHex(DecVal,4); // save LCID as hex
        
        if HexVal = '0404' then // if taiwan chinese
        begin
        if (TheCtrl is TEdit) then // if a edit
        with (TheCtrl as TEdit) do begin
        SelectAll;
        Font.Charset := CHINESEBIG5_CHARSET;
        exit;
        end;
        if (TheCtrl is TRzEdit) then // if a rzedit
        with (TheCtrl as TRzEdit) do begin
        SelectAll;
        Font.Charset := CHINESEBIG5_CHARSET;
        exit;
        end;
        if (TheCtrl is TMemo) then // if a memo
        with (TheCtrl as TMemo) do begin
        SelectAll;
        Font.Charset := CHINESEBIG5_CHARSET;
        exit;
        end;
        if (TheCtrl is TRzMemo) then // if a rzmemo
        with (TheCtrl as TRzMemo) do begin
        SelectAll;
        Font.Charset := CHINESEBIG5_CHARSET;
        exit;
        end;
        if (TheCtrl is TRichEdit) then // if a RichEdit
        with (TheCtrl as TRichEdit) do begin
        SelectAll;
        Font.Charset := CHINESEBIG5_CHARSET;
        SelAttributes.Charset := CHINESEBIG5_CHARSET;
        exit;
        end;
        if (TheCtrl is TRzRichEdit) then // if a rzRichEdit
        with (TheCtrl as TRzRichEdit) do begin
        SelectAll;
        Font.Charset := CHINESEBIG5_CHARSET;
        SelAttributes.Charset := CHINESEBIG5_CHARSET;
        exit;
        end;
        end;
        
        end; // of UT_Set_Charset

        This works for the edits and the memos but not for the RichEdits. I had to do this because while other controls like stringgrids seem to automatically know to use the CHINESEBIG5_CHARSET if the LCID is 0404.

        I know this is not a Raize problem because the base delphi 7 RichEdit has the same issue.

        Any idea what I am doing wrong.

        Steve…

        • This topic was modified 10 months ago by Steve Black.
      • #3676
        Ray Konopka
        Keymaster

          Hi Steve,

          Oh wow. I haven’t really had to think about charsets in quite some time–at least not since Delphi shifted to Unicode support in Delphi 2009. As you noted, the root cause of the issue is in the TRichEdit base control (and perhaps in the underlying Windows Rich Edit control). As such, I would suggest posting a question about this in the Delphi Developer Facebook Group. Perhaps someone there will have some better insight into this.

          Ray

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.