dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: MSDN documentation

  1. #1
    Join Date
    Aug 2002
    Posts
    697

    MSDN documentation

    Hi, ALL,
    First a rhetorical question:

    Why MS declared a COLOR variable as BYTE in here for bUnderlineColor?

    Now on the more serious note:

    Are the values for this BYTE variable documented somewhere?
    I found this, but my preference is to have an official source.

    In addition - this variable is documented for rich edit version 0x0800.
    But when I start MS Word 2010 here in my Windows 7, type something, then do "Right click -> Font...", then select the underline type and color, it will use this color without any issues.
    Does this mean it just not available to public as of yet and implemented internally inside MS Office/Word?

    Is there a way to do that?
    Thank you in advance!
    Last edited by OneEyeMan; June 24th, 2019 at 06:58 PM.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,008

    Re: MSDN documentation

    Have you looked in the office sdk to see if you can find header files where the color values are declared?

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,728

    Re: MSDN documentation

    Why MS declared a COLOR variable as BYTE in here for bUnderlineColor?
    Probably because BYTE is an unsigned type and CHAR, by default, is signed.

    The structure CHARFORMAT2A is defined in the file richedit.h. This also defines constants for some of the structure elements (ie for underline type). However, it doesn't define values for bUnderlineColor.

    The underline colours are documented at http://answers.candoerz.com/question...ol-win32c.aspx

    Note that to use this feature, you need the SDK with at least version 8 of the rich edit control (_RICHEDIT_VER >= 0x0800)
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.1.6)

  4. #4
    Join Date
    Aug 2002
    Posts
    697

    Re: MSDN documentation

    Hi,
    Quote Originally Posted by 2kaud View Post
    Probably because BYTE is an unsigned type and CHAR, by default, is signed.
    But it is a color and not some arbitrary value.
    But OK - its their decision, however it is.

    Quote Originally Posted by 2kaud View Post
    The structure CHARFORMAT2A is defined in the file richedit.h. This also defines constants for some of the structure elements (ie for underline type). However, it doesn't define values for bUnderlineColor.

    The underline colours are documented at http://answers.candoerz.com/question...ol-win32c.aspx
    Well quoting from that link:

    The remaining trick is the color BYTE values. They're not yet documented, but there are 16 colors:
    which looks exactly as the SO link I posted in the OP.

    However, I would guess that MS will document the colors and people will rely on the official sources (MSDN), rather some external/public websites.

    Thank you.

  5. #5
    Join Date
    Aug 2002
    Posts
    697

    Re: MSDN documentation

    Hi,
    Quote Originally Posted by Arjay View Post
    H
    ave you looked in the office sdk to see if you can find header files where the color values are declared?
    They are not color values, but rather some arbitrary BITE ones, that do not connect to anything.

    Thank you.

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,728

    Re: MSDN documentation

    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.1.6)

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,008

    Re: MSDN documentation

    Quote Originally Posted by OneEyeMan View Post
    Hi,

    They are not color values, but rather some arbitrary BITE ones, that do not connect to anything.

    Thank you.
    Let's think about when these values were defined. I'd guess late 80's or early 90's so back then there wasn't anything to 'connect' to. Even if the OS had definitions, Office would have been a different team at Microsoft and they wouldn't have thought to follow what the Windows team was doing. Heck, this was even Windows 3.1 or before and NT (ancestor of Win 10) hadn't yet made the scene. It's hard enough for architecture to get consistency within a single team today let alone trying to do it across teams 30 years ago.

  8. #8
    Join Date
    Aug 2002
    Posts
    697

    Re: MSDN documentation

    Hi,
    Quote Originally Posted by 2kaud View Post
    I presume in order to make it work for older Rich Edit control I need to use ITextDocument2::SetEffectColor()?

    Is there a way to retrieve this interface? Is it part of a standard Windows SDK or Office SDK?

    Is there an example of how to do it - provided it is part of a standard Windows SDK? I would very much prefer to have it working with older version of the library/SDK?

    Thank you.

  9. #9
    Join Date
    Aug 2002
    Posts
    697

    Re: MSDN documentation

    Hi,
    The only reason I'm asking is because first link in the 2kaud answer says that this was working for a long time prior to introducing this extra field. And I don my development on Windows 7 where this field is not available.

    Can someone please give a hint on how to implement it for older version of rich edit library reliably?

    Thank you.

  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,728

    Re: MSDN documentation

    From that link:

    I’ve found some code that says to use the lower nibble for the underline type (CFU_UNDERLINEWAVE) and the upper one for color. So I’ve tried :
    format.bUnderlineType = CFU_UNDERLINEWAVE | 0x50; But that doesn't work.

    UPDATE

    I've tested this code with version 3.0 (Riched20.dll) and it's working. So the problem lies in 4.1. Was the feature removed or moved elsewhere ? It's not working in version 6 (the dll used by office 2007) also.
    The member bUnderlineColor is only defined for a rich edit control version >= 0x0800 (as per the richedit.h include file). Prior to that version, the struct contained the place holder name bReserved1. As was reported, using the upper nibble of bUnderlineType for the colour value works with some older versions of Rich Edit and not in newer ones. This defiantly comes under the category of 'undocumented' and is typical of 'Microsoft undocumented' behaviour. According to that link, the nibble trick seems to work with Rich Edit Control 3.0, but not in 4.1 or 6. So I guess this 'feature' was originally added for the benefit of the Office team - like a lot of other stuff was around that time - but was never officially documented - and was altered to suit them! Back then, this is why there were a lot of mumblings about Office having an unfair advantage other competitors as it used 'insider' knowledge to produce effects that others couldn't - or could only by using undocumented discovered behaviour.

    Good luck trying to get this to work reliably with a Rich Edit control earlier than 8!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.1.6)

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




On-Demand Webinars (sponsored)