CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2005
    Posts
    57

    Question font size RTB control

    I am working with an RTB control,

    Does anyone know how to get the current font size using an API? or a means other than rtb.selfontsize?

    rtb.selfontsize only contains font size AFTER the character was typed or cursor moved. I need to know the fontsize BEFORE the user types, so if the fontsize changes, before the user types a character...i want to know what the font size is.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: font size RTB control

    What are you trying to do? RTB's have a default font, if there's nothing in it. Each character can be different, so how would you know what one was before it was set?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Nov 2005
    Posts
    57

    Talking Re: font size RTB control

    DG: i already explained what i wanted to do in the first post. And since i mentioned using .selfontsize, that should of been your hint that i alreadly knew any character could have its own height AND that i was not trying to get the default font since that is an entirely different property.

    Anyway...

    in case anyone wants to know...its em_getcharformat, yHeight
    Last edited by vb_lover; January 15th, 2008 at 02:32 AM.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: font size RTB control

    You mean sendmessage? I was thinking that, but what is the fontsize of an empty rtb?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: font size RTB control

    AFAIK, the current font size is represented by the SelFontSize property. i think his referring to the character/font height in pixel which is different since SelFontSize is in Points.
    Busy

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: font size RTB control

    Lovely SendMessage()

    @vb_lover: Could you post the complete call required here?

  7. #7
    Join Date
    Nov 2005
    Posts
    57

    Arrow Re: font size RTB control

    DG: i never said i had an empty RTB, not sure why you thought this. But BTW, an empty RTB can have a fontsize set of the next character that is going to be typed! There can be conditions in an RTB that when a font changes the .selfontsize property does not reflect the fontsize of the character that is going to be typed. The .selfontsize only shows the current current font size after the character was typed, or the cursor was moved over another character.


    The call is sendmessage(rtb.hwnd, em_getcharformat2, scf_selection)

    its simple to convert to points: yHeight \ 20
    Last edited by vb_lover; January 15th, 2008 at 03:24 PM.

  8. #8
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: font size RTB control

    Sorry, I don't quite understand.
    What is the fourth parameter, because Sendmessage() always takes four, and where is the result goin' ta come out? What is scf_selection?

  9. #9
    Join Date
    Nov 2005
    Posts
    57

    Talking Re: font size RTB control

    corrected: sendmessage(rtb.hwnd, em_getcharformat, scf_selection,cf2)

  10. #10
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: font size RTB control

    Ok, SCF_SELECTION tells to get the format of the current selection.
    And what is cf2? What data type is the result?
    Sorry for asking. Pure curiousity.

  11. #11
    Join Date
    Nov 2005
    Posts
    57

    Arrow Re: font size RTB control

    cf2 is a type structure as CHARFORMAT2
    and the results of the sendmessage are returned within the structure.
    In this case yHeight.

  12. #12
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: font size RTB control

    I see. Thanks for the info.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured