Okay; here is a new version.

I'm still attaching patches cause it is easier while
we are discussing this in email.

When you are happy with what you are seeing in the patches,
I'll send full files along.

This version of the patch is only for scintalla itself;
not for scite.  It doesn't cover the NotificationHeader
stuff pointed out by Florian either.  I'll send separate
patches for both of these once we've got this one nailed
down.

I didn't change PASCAL this time; I've handled the VC++ 6.0
case.  I also covered the functions that the static WNDPROC
was forwarding too.

**
+ 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.
**

Thanks for your review.

Joseph


Neil Hodgson wrote:
Joseph Galbraith:

Ugh... I'm pretty sure VC++ 6.0 can use the more recent Platform
SDK that has this stuff (we do it all the time) but it seems to
be a little bit trickier to get it to do so from the command line.

   Asking people to download a PSDK and hook it up to an existing
compiler will increase support requests.

Adding the following to the makefile CXXFLAGS makes it build:
...

   There are also VC 6 project files. Adding to source code rather
than build files is less work and easier to understand.

But that is probably a little bit gross.  Would there be a
better place to put these defines?  (Defining these in the
case were they aren't defined seems cleaner to me than
cluttering the code itself up with #ifdefs?)

   PlatWin.cxx, ScintillaWin.cxx and SciTEWin.cxx already contain some
support for switching between GetWindowLongPtr and GetWindowLong so
this could be extended.

My guess is that it used to be declared as PASCAL but that
it has been changed.  PASCAL and CALLBACK may be equivalent
on s ome platformsbut different on others.  I don't know...
that is why I figured do it the way MS does and then it
won't cause problems.

   Scintilla and SciTE, currently use PASCAL consistently for window
procedures. Inconsistencies are often cause for worry when looking for
bugs, so can cause unnecessary work. For example, when looking at
ListBoxX in the patch, the difference between StaticWndProc (LRESULT
CALLBACK) and ControlWndProc (long PASCAL) is notable. I expect you
meant to change ControlWndProc too.

The ones I'm generating are from subversion (I've imported
the scitilla HEAD so I can work with it.)  Is there problems
applying them?

   The patches are fine as far as patches go but I don't have a tool
to apply them on Windows. I can switch to Linux and apply them but
none of the Windows patch tools have ever worked well for me. Manually
applying patches is tedious and leads to errors.

   AFAICT PASCAL and CALLBACK only had a real difference on 16 bit
windows where CALLBACK was always FAR. There was also a difference in
how the name appeared in DLL import sections with PASCAL upper-cased
with no decoration but that didn't affect runtime behaviour.

   Neil

_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest


Index: E:/Users/Galb/Projects/scintilla/scintilla/win32/PlatWin.cxx
===================================================================
--- E:/Users/Galb/Projects/scintilla/scintilla/win32/PlatWin.cxx        
(revision 900)
+++ E:/Users/Galb/Projects/scintilla/scintilla/win32/PlatWin.cxx        
(revision 901)
@@ -42,8 +42,25 @@
 static void SetWindowPointer(HWND hWnd, void *ptr) {
        ::SetWindowLong(hWnd, 0, reinterpret_cast<LONG>(ptr));
 }
+
+#ifndef GWLP_USERDATA
+#define GWLP_USERDATA GWL_USERDATA
+#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 +1032,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 +1072,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 +1577,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 +1619,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 +1627,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 +1641,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 +1732,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: E:/Users/Galb/Projects/scintilla/scintilla/win32/scintilla.mak
===================================================================
--- E:/Users/Galb/Projects/scintilla/scintilla/win32/scintilla.mak      
(revision 900)
+++ E:/Users/Galb/Projects/scintilla/scintilla/win32/scintilla.mak      
(revision 901)
@@ -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
Index: E:/Users/Galb/Projects/scintilla/scintilla/src/Editor.cxx
===================================================================
--- E:/Users/Galb/Projects/scintilla/scintilla/src/Editor.cxx   (revision 900)
+++ E:/Users/Galb/Projects/scintilla/scintilla/src/Editor.cxx   (revision 901)
@@ -3777,7 +3777,7 @@
        /* Do nothing */
 }
 
-void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, 
long lParam) {
+void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t 
lParam) {
 
        // Enumerates all macroable messages
        switch (iMessage) {
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to