From afce8e03c9a083f4ffa86dc223ea7bdf81f520bb Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 29 Dec 2023 14:29:03 +1100 Subject: Avoid casts and warnings for clipboard format registration. --- win32/ScintillaWin.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'win32') 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( - ::RegisterClipboardFormat(TEXT("MSDEVColumnSelect"))); - cfBorlandIDEBlockType = static_cast( - ::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( - ::RegisterClipboardFormat(TEXT("MSDEVLineSelect"))); - cfVSLineTag = static_cast( - ::RegisterClipboardFormat(TEXT("VisualStudioEditorOperationsLineCutCopyClipboardTag"))); + cfLineSelect = RegisterClipboardType(L"MSDEVLineSelect"); + cfVSLineTag = RegisterClipboardType(L"VisualStudioEditorOperationsLineCutCopyClipboardTag"); hrOle = E_FAIL; wMain = hwnd; -- cgit v1.2.3