View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006611 | JEDI VCL | 00 JVCL Components | public | 2018-01-21 15:17 | 2020-05-19 10:35 |
Reporter | marcowobben | Assigned To | |||
Priority | normal | Severity | major | Reproducibility | always |
Status | acknowledged | Resolution | open | ||
Product Version | Daily / GIT | ||||
Target Version | Fixed in Version | ||||
Summary | 0006611: Incorrect result in TJvTextAttributes.ConsistentAttributes | ||||
Description | Requesting TJvRichEdit.SelAttributes.ConsistentAttributes always returns the valid available attributes, not the actual consistent attributes themselves. | ||||
Additional Information | The function uses "dwMask" instead of "dwEffects": function TJvTextAttributes.GetConsistentAttributes: TJvConsistentAttributes; A fix would be: [code] function TJvTextAttributes.GetConsistentAttributes: TJvConsistentAttributes; var Format: TCharFormat2; begin Result := []; if FRichEdit.HandleAllocated and (FType <> atDefaultText) then begin InitFormat(Format); SendMessage(FRichEdit.Handle, EM_GETCHARFORMAT, AttrFlags[FType], LParam(@Format)); with Format do begin 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 begin 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); end; end; end; end; [/code] | ||||
Tags | No tags attached. | ||||
|
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. |
|
Made a pull request out of the proposed fix: https://github.com/project-jedi/jvcl/pull/99 |
|
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: https://docs.microsoft.com/en-us/windows/desktop/controls/em-getcharformat |
|
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? |
|
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. https://docs.microsoft.com/en-us/windows/desktop/api/Richedit/ns-richedit-_charformat I'll attach a test case later this week. |
2019-05-05 12:12
|
RichEditTestAndFix.zip (51,268 bytes) |
|
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) |
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: RichEditTestAndFix.zip | |
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 => |