View Issue Details

IDProjectCategoryView StatusLast Update
0006611JEDI VCL00 JVCL Componentspublic2020-05-19 10:35
ReportermarcowobbenAssigned To 
Status acknowledgedResolutionopen 
Product VersionDaily / GIT 
Target VersionFixed in Version 
Summary0006611: Incorrect result in TJvTextAttributes.ConsistentAttributes
DescriptionRequesting TJvRichEdit.SelAttributes.ConsistentAttributes always returns the valid available attributes, not the actual consistent attributes themselves.
Additional InformationThe function uses "dwMask" instead of "dwEffects":

function TJvTextAttributes.GetConsistentAttributes: TJvConsistentAttributes;

A fix would be:

function TJvTextAttributes.GetConsistentAttributes: TJvConsistentAttributes;
  Format: TCharFormat2;
  Result := [];
  if FRichEdit.HandleAllocated and (FType <> atDefaultText) then
    SendMessage(FRichEdit.Handle, EM_GETCHARFORMAT,
      AttrFlags[FType], LParam(@Format));
    with Format do
      if (dwEffects and CFM_BOLD) <> 0 then
        Include(Result, caBold);
      if (dwEffects and CFM_COLOR) <> 0 then
        Include(Result, caColor);
      if (dwEffects and CFM_FACE) <> 0 then
        Include(Result, caFace);
      if (dwEffects and CFM_ITALIC) <> 0 then
        Include(Result, caItalic);
      if (dwEffects and CFM_SIZE) <> 0 then
        Include(Result, caSize);
      if (dwEffects and CFM_STRIKEOUT) <> 0 then
        Include(Result, caStrikeOut);
      if (dwEffects and CFM_UNDERLINE) <> 0 then
        Include(Result, caUnderline);
      if (dwEffects and CFM_PROTECTED) <> 0 then
        Include(Result, caProtected);
      if (dwEffects and CFM_OFFSET) <> 0 then
        Include(Result, caOffset);
      if (dwEffects and CFM_HIDDEN) <> 0 then
        Include(Result, caHidden);
      if (dwEffects and CFM_CHARSET) <> 0 then
        Include(Result, caCharset);
      if RichEditVersion >= 2 then
        if (dwEffects and CFM_LINK) <> 0 then
          Include(Result, caLink);
        if (dwEffects and CFM_BACKCOLOR) <> 0 then
          Include(Result, caBackColor);
        if (dwEffects and CFM_DISABLED) <> 0 then
          Include(Result, caDisabled);
        if (dwEffects and CFM_WEIGHT) <> 0 then
          Include(Result, caWeight);
        if (dwEffects and CFM_SUBSCRIPT) <> 0 then
          Include(Result, caSubscript);
        if (dwEffects and CFM_REVAUTHOR) <> 0 then
          Include(Result, caRevAuthor);

TagsNo tags attached.



2018-07-18 16:04

administrator   ~0021545

Could you check if the issue is still present in the latest GIT content? If yes, please provide the zipped sources of an application showing this.


2019-04-27 14:14

reporter   ~0021762

Made a pull request out of the proposed fix:


2019-04-30 15:59

administrator   ~0021778

I disagree with this change, the documentation says this:

The dwMask member specifies which attributes are consistent throughout the entire selection

So clearly, a "GetConsistent" method should use the dwMask member.

See here:


2019-05-01 09:47

reporter   ~0021783

After reading the MSDN documentation you linked to (I should have read it upfront) I'd agree with you. If the original creator of this issue doesn't provide more information about why he thinks the method is wrong we should close this issue as "won't do" or "no change required" -> test case error.

So could marcowobben please shed more light on why he thinks this method is implemented the wrong way?


2019-05-04 22:49

reporter   ~0021809

The documentation indeed states it returns the consistent attributes of the selection. However, in the my test case it doesn't work as documented.

Reading onward to the difference in dwMask and dwEffect, it clearly states the dwMask only specifies if the flags in dwEffect are valid. In other words the actual values are not found in dwMask but in dwEffect.

I'll attach a test case later this week.

2019-05-05 12:12 (51,268 bytes)


2019-05-05 12:16

reporter   ~0021815

My initially siggested fix is not even completed. While reading back on the online microsoft documentation, building a test application, it showed that even my fix was incomplete.

I've uploaded the test application which contains the routines for:

- SelAttributes (returns the attributes at the caret)
- SelAttribute.ConsistentAttributes (appears to be unusable ...)
- SelAttributes.FixConsistentAttributes (which returns a true consistent set)

Issue History

Date Modified Username Field Change
2018-01-21 15:17 marcowobben New Issue
2018-07-18 16:04 obones Note Added: 0021545
2018-07-18 16:04 obones Status new => feedback
2019-04-27 14:14 mh Note Added: 0021762
2019-04-30 15:59 obones Note Added: 0021778
2019-05-01 09:47 mh Note Added: 0021783
2019-05-04 22:49 marcowobben Note Added: 0021809
2019-05-05 12:12 marcowobben File Added:
2019-05-05 12:16 marcowobben Note Added: 0021815
2020-05-19 10:30 obones Assigned To => obones
2020-05-19 10:30 obones Status feedback => acknowledged
2020-05-19 10:35 obones Assigned To obones =>