Neil Hodgson wrote:
Joseph Galbraith:

+ Disable warning about standard c runtime library
   functions that Microsoft doesn't like.

   Adding a long define on the command line is a little ugly. It could
be placed in Platform.h

I did try Platform.h... it isn't included soon enough.
Platform would need to be included before any of the
deprecated functions are included.

The only other thing I can think of is to introduce
a private header that is included first by every
cxx file.

although that may be included by clients that
want to move to the new safe runtime functions.

I don't think that the #define precludes the functions
from being used, it just suppresses the warning.

Scintilla can't move
to the safe runtime functions as they are not available on most
supported platforms. I don't even know if / when GCC will support
them.

Eventually I'd hope there could be a compatibility wrapper
that implemented these in the case were the system c runtime
didn't provide them.

But I certainly haven't had time to do it...

+#ifndef GWLP_USERDATA
+#define GWLP_USERDATA GWL_USERDATA
+#define GWLP_WNDPROC GWL_WNDPROC
 #endif
...

   OK. We may see some issues with particular versions of headers
defining some but not all of the symbols. With Mingw and DMC, not all
of the PSDK symbols are defined and sometimes they are added in odd
orders as they are needed. DMC isn't really supported but I have
accepted patches to allow it to work.

All right, I'll fix those.  I'll also fix the NMHDR thing since
you figured it out :-)

In fact, here it is:

**
+ Disable warning about standard c runtime library
  functions that Microsoft doesn't like.

+ Make definition of Edit::NotifyMacroRecord() match it's
  declaration.

+ Fix declaration of ListBoxX::StaticWndProc to match PSDK
  for a WNDPROC.

+ Use {Set,Get}WindowLongPtr instead of {Set,Get}WindowLong and
  new GWLP_USERDATA and GWLP_WNDPROC instead of old GWL_USERDATA
  and GWL_WNDPROC where needed.

+ Add wrapper implemenation for {Set,Get}WindowLongPtr that
  passes it off to {Set,Get}WindowLong for MSVC 6.0 builds.

+ Fix NotifyHeader::idFrom to be a pointer type as defined
  in the PSDK.  In order not to break already existing
  64-bit clients, only do so for _WIN32.
**

Thanks,

Joseph
Index: scintilla/include/Scintilla.h
===================================================================
--- scintilla/include/Scintilla.h       (revision 898)
+++ scintilla/include/Scintilla.h       (working copy)
@@ -718,7 +718,11 @@
        // but most clients of Scintilla.h do not have this type visible.
        //WindowID hwndFrom;
        void *hwndFrom;
+#ifdef _WIN32
+       uptr_t idFrom;
+#else
        unsigned int idFrom;
+#endif
        unsigned int code;
 };
 
Index: scintilla/win32/PlatWin.cxx
===================================================================
--- scintilla/win32/PlatWin.cxx (revision 898)
+++ scintilla/win32/PlatWin.cxx (working copy)
@@ -42,8 +42,28 @@
 static void SetWindowPointer(HWND hWnd, void *ptr) {
        ::SetWindowLong(hWnd, 0, reinterpret_cast<LONG>(ptr));
 }
+
+#ifndef GWLP_USERDATA
+#define GWLP_USERDATA GWL_USERDATA
 #endif
 
+#ifndef GWLP_WNDPROC
+#define GWLP_WNDPROC GWL_WNDPROC
+#endif
+
+#ifndef LONG_PTR
+#define LONG_PTR LONG
+#endif
+
+static LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLong) {
+       return ::SetWindowLong(hWnd, nIndex, dwNewLong);
+}
+
+static LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex) {
+       return ::GetWindowLong(hWnd, nIndex);
+}
+#endif
+
 static CRITICAL_SECTION crPlatformLock;
 static HINSTANCE hinstPlatformRes = 0;
 static bool onNT = false;
@@ -1015,7 +1035,7 @@
        void CentreItem(int);
        void Paint(HDC);
        void Erase(HDC);
-       static long PASCAL ControlWndProc(HWND hWnd, UINT iMessage, WPARAM 
wParam, LPARAM lParam);
+       static LRESULT PASCAL ControlWndProc(HWND hWnd, UINT iMessage, WPARAM 
wParam, LPARAM lParam);
 
        static const Point ItemInset;   // Padding around whole item
        static const Point TextInset;   // Padding around text
@@ -1055,8 +1075,8 @@
        }
        virtual void SetList(const char *list, char separator, char typesep);
        void Draw(DRAWITEMSTRUCT *pDrawItem);
-       long WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
-       static long PASCAL StaticWndProc(HWND hWnd, UINT iMessage, WPARAM 
wParam, LPARAM lParam);
+       LRESULT WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
+       static LRESULT PASCAL StaticWndProc(HWND hWnd, UINT iMessage, WPARAM 
wParam, LPARAM lParam);
 };
 
 const Point ListBoxX::ItemInset(0, 0);
@@ -1560,7 +1580,7 @@
        ::DeleteObject(hBitmap);
 }
 
-long PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, 
LPARAM lParam) {
+LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, 
LPARAM lParam) {
        switch (uMsg) {
        case WM_ERASEBKGND:
                return TRUE;
@@ -1602,7 +1622,7 @@
                return 0;
        }
 
-       WNDPROC prevWndProc = reinterpret_cast<WNDPROC>(GetWindowLong(hWnd, 
GWL_USERDATA));
+       WNDPROC prevWndProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hWnd, 
GWLP_USERDATA));
        if (prevWndProc) {
                return ::CallWindowProc(prevWndProc, hWnd, uMsg, wParam, 
lParam);
        } else {
@@ -1610,7 +1630,7 @@
        }
 }
 
-long ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) 
{
+LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM 
lParam) {
        switch (iMessage) {
        case WM_CREATE: {
                        HINSTANCE hinstanceParent = 
GetWindowInstance(reinterpret_cast<HWND>(parent->GetID()));
@@ -1624,8 +1644,8 @@
                                reinterpret_cast<HMENU>(ctrlID),
                                hinstanceParent,
                                0);
-                       WNDPROC prevWndProc = 
reinterpret_cast<WNDPROC>(::SetWindowLong(lb, GWL_WNDPROC, 
reinterpret_cast<LONG>(ControlWndProc)));
-                       ::SetWindowLong(lb, GWL_USERDATA, 
reinterpret_cast<LONG>(prevWndProc));
+                       WNDPROC prevWndProc = 
reinterpret_cast<WNDPROC>(::SetWindowLongPtr(lb, GWLP_WNDPROC, 
reinterpret_cast<LONG_PTR>(ControlWndProc)));
+                       ::SetWindowLongPtr(lb, GWLP_USERDATA, 
reinterpret_cast<LONG_PTR>(prevWndProc));
                }
                break;
 
@@ -1715,7 +1735,7 @@
        return 0;
 }
 
-long PASCAL ListBoxX::StaticWndProc(
+LRESULT PASCAL ListBoxX::StaticWndProc(
     HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
        if (iMessage == WM_CREATE) {
                CREATESTRUCT *pCreate = reinterpret_cast<CREATESTRUCT 
*>(lParam);
Index: scintilla/win32/scintilla.mak
===================================================================
--- scintilla/win32/scintilla.mak       (revision 898)
+++ scintilla/win32/scintilla.mak       (working copy)
@@ -35,7 +35,7 @@
 RC=rc
 LD=link
 
-CXXFLAGS=-Zi -TP -W4 -Zc:forScope -Zc:wchar_t
+CXXFLAGS=-Zi -TP -W4 -Zc:forScope -Zc:wchar_t -D_CRT_SECURE_NO_DEPRECATE=1
 # For something scary:-Wp64
 CXXDEBUG=-Od -MTd -DDEBUG
 CXXNDEBUG=-O1 -MT -DNDEBUG -GL
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to