TCoolTextWnd::SetDragData doesn't consider sizeof(tchar)
Borland's Object Windows Library for the modern age
Brought to you by:
jogybl,
sebas_ledesma
Solved in commit [r5725]
Related
Commit: [r5725]
Hi Sebastian, you're doing great review of the CoolPrj code. Nice work!
By the way, the logic in TCoolTextWnd::SetDragData seems unnecessary complex for the job, i.e. simply putting CF_TEXT and CF_UNICODETEXT on the clipboard. I'm sure it can be much simplified.
However, putting both formats on the clipboard isn't needed at all. Windows will provide conversions automatically:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclipboarddata
https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats#synthesized-clipboard-formats
So you only need to retain code for the active build mode text format, and you can remove all the ugly preprocessor use.
Also note [feature-requests:#164] "TClipboard enhancements", which makes very easy to copy text to the clipboard. Since you are targeting 7.1 for this bug fix, you may be able to utilise this new feature in your CoolPrj overhaul.
Related
Feature Requests: #164
Regarding [r5725], this part is wrong:
Both of these statements evaluate to the same thing, whatever the build mode is, since if it is not a UNICODE build then sizeof(_TCHAR) == 1, so the second statement is equivalent to the first.
What you want is to allocate wide chars in ANSI build mode here. Since _TCHAR is char in ANSI build mode, you need to explicitly use wchar_t in your calculation:
Similarly, this part is wrong:
Note that you want wide chars in ANSI build mode here. Since _TCHAR is char in ANSI build mode, you need to explicitly use wchar_t in your calculation:
Related
Commit: [r5725]
Last edit: Vidar Hasfjord 2022-01-12
You are right.
It should be:
and later:
Explanation:
In UNICODE build it will create also a CF_TEXT (ANSI) export, in ANSI it will create a CF_UNICODETEXT.
Corrected in [r5726] .
Moderator: Corrected revision reference.
Related
Commit: [r5726]
Last edit: Vidar Hasfjord 2022-01-12
Diff:
TCoolTextWnd::SetDragData and other copy-and-paste functionality has been mostly rewritten in modern style in [r6548] as part of fixing [bugs:#551]. See CoolPrj code log for recent changes.
Related
Bugs: #551
Commit: [r6548]