aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-04-30 09:52:22 +1000
committerNeil <nyamatongwe@gmail.com>2018-04-30 09:52:22 +1000
commitff4df3c1fdd728ce6d3b43c607c743814dd974e1 (patch)
tree61e378eb87766e938d041478f03c32ab6e197bad
parent3385ec0a828806e7711eb277ac6b3a1a8ed70f6b (diff)
downloadscintilla-mirror-ff4df3c1fdd728ce6d3b43c607c743814dd974e1.tar.gz
Backport: Use message parameter access macros provided by Windows instead of casting.
Backport of changeset 6762:addd3229350b.
-rw-r--r--win32/PlatWin.cxx8
-rw-r--r--win32/ScintillaWin.cxx38
2 files changed, 11 insertions, 35 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 3e6b02438..e1acdb125 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -688,9 +688,8 @@ void SurfaceGDI::BrushColor(ColourDesired back) {
// Only ever want pure, non-dithered brushes
const ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsLong()));
brush = ::CreateSolidBrush(colourNearest.AsLong());
- brushOld = static_cast<HBRUSH>(::SelectObject(hdc, brush));
+ brushOld = SelectBrush(hdc, brush);
}
-
void SurfaceGDI::SetFont(Font &font_) {
if (font_.GetID() != font) {
const FormatAndMetrics *pfm = FamFromFontID(font_.GetID());
@@ -2725,7 +2724,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
reinterpret_cast<HMENU>(static_cast<ptrdiff_t>(ctrlID)),
hinstanceParent,
0);
- WNDPROC prevWndProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(lb, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ControlWndProc)));
+ WNDPROC prevWndProc = SubclassWindow(lb, ControlWndProc);
::SetWindowLongPtr(lb, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(prevWndProc));
}
break;
@@ -2808,9 +2807,8 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
::ReleaseCapture();
}
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
-
case WM_MOUSEWHEEL:
- wheelDelta -= static_cast<short>(HIWORD(wParam));
+ wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
if (abs(wheelDelta) >= WHEEL_DELTA) {
const int nRows = GetVisibleRows();
int linesToScroll = 1;
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index aa28d7439..570cb02be 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -155,11 +155,9 @@ static void SetWindowID(HWND hWnd, int identifier) {
static Point PointFromPOINT(POINT pt) {
return Point::FromInts(pt.x, pt.y);
}
-
static Point PointFromLParam(sptr_t lpoint) {
- return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint)));
+ return Point::FromInts(GET_X_LPARAM(lpoint), GET_Y_LPARAM(lpoint));
}
-
static bool KeyboardIsKeyDown(int key) {
return (::GetKeyState(key) & 0x80000000) != 0;
}
@@ -643,16 +641,6 @@ int ScintillaWin::MouseModifiers(uptr_t wParam) {
(wParam & MK_CONTROL) != 0,
KeyboardIsKeyDown(VK_MENU));
}
-
-// Avoid warnings everywhere for old style casts by concentrating them here
-static WORD LoWord(uptr_t l) {
- return LOWORD(l);
-}
-
-static WORD HiWord(uptr_t l) {
- return HIWORD(l);
-}
-
static int InputCodePage() {
HKL inputLocale = ::GetKeyboardLayout(0);
LANGID inputLang = LOWORD(inputLocale);
@@ -1252,11 +1240,9 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
GetIntelliMouseParameters();
::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt));
break;
-
case WM_COMMAND:
- Command(LoWord(wParam));
+ Command(LOWORD(wParam));
break;
-
case WM_PAINT:
return WndPaint(wParam);
@@ -1285,7 +1271,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
renderTargetValid = false;
}
#endif
- //Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LoWord(lParam), HiWord(lParam));
+ //Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LOWORD(lParam), HIWORD(lParam));
ChangeSize();
}
break;
@@ -1317,9 +1303,8 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
if (wParam & MK_SHIFT) {
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
-
// Either SCROLL or ZOOM. We handle the wheel steppings calculation
- wheelDelta -= static_cast<short>(HiWord(wParam));
+ wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
if (abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) {
Sci::Line linesToScroll = linesPerScroll;
if (linesPerScroll == WHEEL_PAGESCROLL)
@@ -1438,9 +1423,8 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
RightButtonDownWithModifiers(pt, ::GetMessageTime(), MouseModifiers(wParam));
}
break;
-
case WM_SETCURSOR:
- if (LoWord(lParam) == HTCLIENT) {
+ if (LOWORD(lParam) == HTCLIENT) {
if (inDragDrop == ddDragging) {
DisplayCursor(Window::cursorUp);
} else {
@@ -1602,11 +1586,8 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
}
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
-
case WM_INPUTLANGCHANGE:
- //::SetThreadLocale(LOWORD(lParam));
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
-
case WM_INPUTLANGCHANGEREQUEST:
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
@@ -2846,9 +2827,8 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) {
//Platform::DebugPrintf("ScrollInfo %d mask=%x min=%d max=%d page=%d pos=%d track=%d\n", b,sci.fMask,
//sci.nMin, sci.nMax, sci.nPage, sci.nPos, sci.nTrackPos);
-
Sci::Line topLineNew = topLine;
- switch (LoWord(wParam)) {
+ switch (LOWORD(wParam)) {
case SB_LINEUP:
topLineNew -= 1;
break;
@@ -2870,7 +2850,7 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
int xPos = xOffset;
const PRectangle rcText = GetTextRectangle();
const int pageWidth = static_cast<int>(rcText.Width() * 2 / 3);
- switch (LoWord(wParam)) {
+ switch (LOWORD(wParam)) {
case SB_LINEUP:
xPos -= 20;
break;
@@ -3351,9 +3331,7 @@ LRESULT PASCAL ScintillaWin::CTWndProc(
::EndPaint(hWnd, &ps);
return 0;
} else if ((iMessage == WM_NCLBUTTONDOWN) || (iMessage == WM_NCLBUTTONDBLCLK)) {
- POINT pt;
- pt.x = static_cast<short>(LOWORD(lParam));
- pt.y = static_cast<short>(HIWORD(lParam));
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
ScreenToClient(hWnd, &pt);
sciThis->ct.MouseClick(PointFromPOINT(pt));
sciThis->CallTipClick();