From c06e1e893caa023d5de09ac2364e565fad2f6139 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 9 Jun 2002 02:58:47 +0000 Subject: Compatibility with 64 bit systems. --- win32/PlatWin.cxx | 11 ++++++++--- win32/ScintillaWin.cxx | 31 ++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 10 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 709e6e480..be6c2305a 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "Platform.h" #include "PlatformRes.h" @@ -769,8 +770,7 @@ ListBox::~ListBox() { } void ListBox::Create(Window &parent, int ctrlID) { - HINSTANCE hinstanceParent = reinterpret_cast( - ::GetWindowLong(reinterpret_cast(parent.GetID()),GWL_HINSTANCE)); + HINSTANCE hinstanceParent = GetWindowInstance(reinterpret_cast(parent.GetID())); id = ::CreateWindowEx( WS_EX_WINDOWEDGE, "listbox", "", WS_CHILD | WS_THICKFRAME | WS_VSCROLL | LBS_NOTIFY, @@ -816,7 +816,7 @@ void ListBox::Clear() { void ListBox::Append(char *s) { Window_SendMessage(this, LB_ADDSTRING, 0, reinterpret_cast(s)); - size_t len = strlen(s); + unsigned int len = static_cast(strlen(s)); if (maxItemCharacters < len) maxItemCharacters = len; } @@ -959,6 +959,11 @@ long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, return ::SendMessage(reinterpret_cast(w), msg, wParam, lParam); } +long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) { + return ::SendMessage(reinterpret_cast(w), msg, wParam, + reinterpret_cast(lParam)); +} + bool Platform::IsDBCSLeadByte(int codePage, char ch) { return ::IsDBCSLeadByteEx(codePage, ch) != 0; } diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index bad4758fe..e93d6ef4b 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "Platform.h" @@ -1060,7 +1061,7 @@ void ScintillaWin::CreateCallTipWindow(PRectangle) { ct.wCallTip = ::CreateWindow(callClassName, "ACallTip", WS_VISIBLE | WS_CHILD, 100, 100, 150, 20, MainHWND(), reinterpret_cast(idCallTip), - reinterpret_cast(::GetWindowLong(MainHWND(),GWL_HINSTANCE)), + GetWindowInstance(MainHWND()), &ct); ct.wDraw = ct.wCallTip; #endif @@ -1461,7 +1462,7 @@ void ScintillaWin::AddCharBytes(char b0, char b1) { dbcsChars[0] = b0; dbcsChars[1] = b1; dbcsChars[2] = '\0'; - AddCharUTF(dbcsChars, strlen(dbcsChars), true); + AddCharUTF(dbcsChars, 2, true); } else { AddChar(b0); } @@ -1877,18 +1878,34 @@ bool ScintillaWin::Unregister() { return result; } +// Take care of 32/64 bit pointers +#ifdef GetWindowLongPtr +static void *PointerFromWindow(HWND hWnd) { + return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); +} +static void SetWindowPointer(HWND hWnd, void *ptr) { + ::SetWindowLongPtr(hWnd, 0, reinterpret_cast(ptr)); +} +#else +static void *PointerFromWindow(HWND hWnd) { + return reinterpret_cast(::GetWindowLong(hWnd, 0)); +} +static void SetWindowPointer(HWND hWnd, void *ptr) { + ::SetWindowLong(hWnd, 0, reinterpret_cast(ptr)); +} +#endif + sptr_t PASCAL ScintillaWin::CTWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, sptr_t lParam) { // Find C++ object associated with window. - CallTip *ctp = reinterpret_cast(GetWindowLong(hWnd, 0)); + CallTip *ctp = reinterpret_cast(PointerFromWindow(hWnd)); // ctp will be zero if WM_CREATE not seen yet if (ctp == 0) { if (iMessage == WM_CREATE) { // Associate CallTip object with window CREATESTRUCT *pCreate = reinterpret_cast(lParam); - ::SetWindowLong(hWnd, 0, - reinterpret_cast(pCreate->lpCreateParams)); + SetWindowPointer(hWnd, pCreate->lpCreateParams); return 0; } else { return ::DefWindowProc(hWnd, iMessage, wParam, lParam); @@ -1923,13 +1940,13 @@ sptr_t PASCAL ScintillaWin::SWndProc( //Platform::DebugPrintf("S W:%x M:%x WP:%x L:%x\n", hWnd, iMessage, wParam, lParam); // Find C++ object associated with window. - ScintillaWin *sci = reinterpret_cast(::GetWindowLong(hWnd, 0)); + ScintillaWin *sci = reinterpret_cast(PointerFromWindow(hWnd)); // sci will be zero if WM_CREATE not seen yet if (sci == 0) { if (iMessage == WM_CREATE) { // Create C++ object associated with window sci = new ScintillaWin(hWnd); - ::SetWindowLong(hWnd, 0, reinterpret_cast(sci)); + SetWindowPointer(hWnd, sci); return sci->WndProc(iMessage, wParam, lParam); } else { return ::DefWindowProc(hWnd, iMessage, wParam, lParam); -- cgit v1.2.3