CRichEditCtrl SetSelectionCharFormat setting very big height issue
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: CRichEditCtrl SetSelectionCharFormat setting very big height issue

  1. #1
    Join Date
    Jun 2011
    Posts
    4

    Question CRichEditCtrl SetSelectionCharFormat setting very big height issue

    Hi;

    i am using CRichEditCtrl in my application.

    Question:-
    ----------------------------------------------------------------
    I need to set the height of the Selection using the method SetSelectionCharFormat.
    if height is too much then its not set properly ?
    But the CHARFORMAT structure taking yHeight as LONG , then why we can't set th LONG height ?


    Example and code snippet:-
    ----------------------------------------------------------------
    here below line of code for better understanding:---

    CHARFORMAT cf;
    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_SIZE;
    cf.yHeight = 634776; //-----> if height is too much
    SetSelectionCharFormat(cf);
    DWORD dwSelMask = GetSelectionCharFormat(cf); //--> here cf.yHeight comes out as 32767


    Thnx

  2. #2
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: CRichEditCtrl SetSelectionCharFormat setting very big height issue

    It's just a guess, but rich edit control evolved from an older 16-bit version, so it may be quite possible that it still uses a 16-bit variable to computer that parameter (32767 is the largest possible value for a signed 16-bit variable. Example: short type.)

  3. #3
    Join Date
    Jun 2011
    Posts
    4

    Re: CRichEditCtrl SetSelectionCharFormat setting very big height issue

    Quote Originally Posted by ahmd View Post
    It's just a guess, but rich edit control evolved from an older 16-bit version, so it may be quite possible that it still uses a 16-bit variable to computer that parameter (32767 is the largest possible value for a signed 16-bit variable. Example: short type.)
    thnx for the reply.
    yes that's the reason.
    But how can i set the LONG value in the height ? any alternative ? I have used CHARFORMAT2 structure also , but no success.

  4. #4
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: CRichEditCtrl SetSelectionCharFormat setting very big height issue

    Quote Originally Posted by asim2011 View Post
    But how can i set the LONG value in the height ? any alternative ?
    I don't think rich edit can handle it. Let me ask, why do you need to set it so high?

  5. #5
    Join Date
    Jun 2011
    Posts
    4

    Re: CRichEditCtrl SetSelectionCharFormat setting very big height issue

    Quote Originally Posted by ahmd View Post
    I don't think rich edit can handle it. Let me ask, why do you need to set it so high?
    My application having the TextEditor (which is CRichEditCtrl) , in which user can select text and update its Height/Color/Bold/Italic/Font Attributes.

    Default TextSize is 0.2 , which i have converted in twips and create the text.

    Suppose user write the text "abc" , now he selects "all text" with CTRL+A . then he make the size in the edit control as (1000) .Then on conversion to twips , it becomes too much size , and SetSelectionCharFormat get failed.

    *i have seen that problem also occuring in the Windows 'Wordpad.exe"
    thnx

  6. #6
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: CRichEditCtrl SetSelectionCharFormat setting very big height issue

    As I posted in one other thread, a rich edit control is hardly used for anything other than a simple output of a long (unformatted) text. Even Microsoft themselves don't use it too much. (The only place I see it used now is mostly to display EULA scripts.) As you might have also noticed the Wordpad is not that popular either.

    From my personal experience, the rich edit control has very many bugs. Besides that it becomes very slow when handling larger files with more formatting if you implement it using available documentation. Also unfortunately most of rich edit functionality is poorly documented as well.

    So my suggestion to you is either write your own control from scratch (quite a time consuming process) or buy an already prepared GUI control. Search the web for Windows GUI controls. Also take a peek at already written (free) text editors at the main page of Codeguru.com and codeproject.com as well.

  7. #7
    Join Date
    Jun 2011
    Posts
    4

    Re: CRichEditCtrl SetSelectionCharFormat setting very big height issue

    Thnx for the support , let me try by codeproject sample.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center