aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-12-29 14:29:03 +1100
committerNeil <nyamatongwe@gmail.com>2023-12-29 14:29:03 +1100
commitafce8e03c9a083f4ffa86dc223ea7bdf81f520bb (patch)
tree4fc054613610d8302b05f3a0b093cd3fdb165a36 /win32
parent93f1b9a2783e96a9f0f9a889f69ea6d1542354e0 (diff)
downloadscintilla-mirror-afce8e03c9a083f4ffa86dc223ea7bdf81f520bb.tar.gz
Avoid casts and warnings for clipboard format registration.
Diffstat (limited to 'win32')
-rw-r--r--win32/ScintillaWin.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 7ff979bbf..f45c4e626 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -319,6 +319,13 @@ struct HorizontalScrollRange {
int documentWidth;
};
+CLIPFORMAT RegisterClipboardType(LPCWSTR lpszFormat) noexcept {
+ // Registered clipboard format values are 0xC000 through 0xFFFF.
+ // RegisterClipboardFormatW returns 32-bit unsigned and CLIPFORMAT is 16-bit
+ // unsigned so choose the low 16-bits with &.
+ return ::RegisterClipboardFormatW(lpszFormat) & 0xFFFF;
+}
+
}
namespace Scintilla::Internal {
@@ -572,16 +579,12 @@ ScintillaWin::ScintillaWin(HWND hwnd) {
// There does not seem to be a real standard for indicating that the clipboard
// contains a rectangular selection, so copy Developer Studio and Borland Delphi.
- cfColumnSelect = static_cast<CLIPFORMAT>(
- ::RegisterClipboardFormat(TEXT("MSDEVColumnSelect")));
- cfBorlandIDEBlockType = static_cast<CLIPFORMAT>(
- ::RegisterClipboardFormat(TEXT("Borland IDE Block Type")));
+ cfColumnSelect = RegisterClipboardType(L"MSDEVColumnSelect");
+ cfBorlandIDEBlockType = RegisterClipboardType(L"Borland IDE Block Type");
// Likewise for line-copy (copies a full line when no text is selected)
- cfLineSelect = static_cast<CLIPFORMAT>(
- ::RegisterClipboardFormat(TEXT("MSDEVLineSelect")));
- cfVSLineTag = static_cast<CLIPFORMAT>(
- ::RegisterClipboardFormat(TEXT("VisualStudioEditorOperationsLineCutCopyClipboardTag")));
+ cfLineSelect = RegisterClipboardType(L"MSDEVLineSelect");
+ cfVSLineTag = RegisterClipboardType(L"VisualStudioEditorOperationsLineCutCopyClipboardTag");
hrOle = E_FAIL;
wMain = hwnd;