]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/slider.cpp
Fix explicitly setting focus to generic wxSpinCtrl.
[wxWidgets.git] / src / os2 / slider.cpp
index cf5d9798f5fd2ed4d92704b2bdf7096eb198d790..b9864249f51f491dad78fe740eb8c879bbcbd445 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        slider.cpp
+// Name:        src/os2/slider.cpp
 // Purpose:     wxSlider
 // Author:      David Webster
 // Modified by:
 #endif
 
 #ifndef WX_PRECOMP
-#include <stdio.h>
-#include <wx/utils.h>
-#include <wx/brush.h>
-#include <wx/scrolwin.h>
+    #include <stdio.h>
+    #include "wx/utils.h"
+    #include "wx/brush.h"
+    #include "wx/scrolwin.h"
 #endif
 
+#if wxUSE_SLIDER
+
 #include "wx/slider.h"
 #include "wx/os2/private.h"
 
@@ -50,26 +52,24 @@ wxSlider::~wxSlider()
         ::WinDestroyWindow((HWND)m_hStaticValue);
 } // end of wxSlider::~wxSlider
 
-void wxSlider::AdjustSubControls(
-  int                               nX
-, int                               nY
-, int                               nWidth
-, int                               nHeight
-, int                               nSizeFlags
-)
+void wxSlider::AdjustSubControls( int nX,
+                                  int nY,
+                                  int nWidth,
+                                  int nHeight,
+                                  int WXUNUSED(nSizeFlags) )
 {
-    SWP                             vSwp;
     int                             nXOffset = nX;
     int                             nYOffset = nY;
     int                             nCx;     // slider,min,max sizes
     int                             nCy;
     int                             nCyf;
-    char                            zBuf[300];
+    wxChar                          zBuf[300];
+    wxFont                          vFont = this->GetFont();
 
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,&this->GetFont()
+                  ,&vFont
                  );
 
     if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
@@ -79,11 +79,11 @@ void wxSlider::AdjustSubControls(
             int                     nMinLen = 0;
             int                     nMaxLen = 0;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
 
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
 
             if (m_hStaticValue)
             {
@@ -104,7 +104,7 @@ void wxSlider::AdjustSubControls(
                               ,(LONG)nXOffset - (nMinLen + nCx)
                               ,(LONG)nYOffset
                               ,(LONG)nMinLen
-                              ,(LONG)nCy
+                              ,(LONG)nCyf
                               ,SWP_SIZE | SWP_MOVE
                              );
             nXOffset += nWidth + nCx;
@@ -114,14 +114,59 @@ void wxSlider::AdjustSubControls(
                               ,(LONG)nXOffset
                               ,(LONG)nYOffset
                               ,(LONG)nMaxLen
-                              ,(LONG)nCy
-                              ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+                              ,(LONG)nCyf
+                              ,SWP_ZORDER | SWP_SHOW
+                             );
+        }
+    }
+    else
+    {
+        //
+        // Now deal with a vertical slider
+        //
+
+        if (m_windowStyle & wxSL_LABELS )
+        {
+            int                     nMinLen = 0;
+            int                     nMaxLen = 0;
+
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
+
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
+
+            if (m_hStaticValue)
+            {
+                int                 nNewWidth = (wxMax(nMinLen, nMaxLen));
+
+                ::WinSetWindowPos( (HWND)m_hStaticValue
+                                  ,HWND_TOP
+                                  ,(LONG)nXOffset
+                                  ,(LONG)nYOffset + nHeight + nCyf
+                                  ,(LONG)nNewWidth
+                                  ,(LONG)nCyf
+                                  ,SWP_SIZE | SWP_MOVE
+                                 );
+            }
+            ::WinSetWindowPos( (HWND)m_hStaticMax
+                              ,HWND_TOP
+                              ,(LONG)nXOffset
+                              ,(LONG)nYOffset + nHeight
+                              ,(LONG)nMaxLen
+                              ,(LONG)nCyf
+                              ,SWP_SIZE | SWP_MOVE
+                             );
+            ::WinSetWindowPos( (HWND)m_hStaticMin
+                              ,HWND_TOP
+                              ,(LONG)nXOffset
+                              ,(LONG)nYOffset - nCyf
+                              ,(LONG)nMinLen
+                              ,(LONG)nCyf
+                              ,SWP_SIZE | SWP_MOVE
                              );
         }
     }
-    //
-    // Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
-    //
 } // end of wxSlider::AdjustSubControls
 
 void wxSlider::ClearSel()
@@ -159,9 +204,7 @@ bool wxSlider::Create(
 , const wxPoint&                    rPos
 , const wxSize&                     rSize
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
@@ -189,7 +232,7 @@ bool wxSlider::Create(
     m_windowStyle  = lStyle;
     m_nTickFreq    = 0;
 
-    if (vId == -1)
+    if (vId == wxID_ANY)
         m_windowId = (int)NewControlId();
     else
         m_windowId = vId;
@@ -216,7 +259,7 @@ bool wxSlider::Create(
         //
         // Now create min static control
         //
-        sprintf(wxBuffer, "%d", nMinValue);
+        wxSprintf(wxBuffer, wxT("%d"), nMinValue);
         lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE;
         if (m_windowStyle & wxCLIP_SIBLINGS)
             lWstyle |= WS_CLIPSIBLINGS;
@@ -239,9 +282,9 @@ bool wxSlider::Create(
 
     vSlData.cbSize = sizeof(SLDCDATA);
     if (m_windowStyle & wxSL_VERTICAL)
-        lMsStyle = SLS_VERTICAL | WS_VISIBLE | WS_TABSTOP;
+        lMsStyle = SLS_VERTICAL | SLS_HOMEBOTTOM | WS_VISIBLE | WS_TABSTOP;
     else
-        lMsStyle = SLS_HORIZONTAL | WS_VISIBLE | WS_TABSTOP;
+        lMsStyle = SLS_HORIZONTAL | SLS_HOMELEFT | WS_VISIBLE | WS_TABSTOP;
 
     if (m_windowStyle & wxCLIP_SIBLINGS)
         lMsStyle |= WS_CLIPSIBLINGS;
@@ -264,22 +307,23 @@ bool wxSlider::Create(
         lMsStyle |= SLS_PRIMARYSCALE1 | SLS_PRIMARYSCALE2;
     else
         lMsStyle |= SLS_PRIMARYSCALE2;
+    lMsStyle |= SLS_RIBBONSTRIP;
 
     m_nPageSize = ((nMaxValue - nMinValue)/10);
-    vSlData.usScale1Increments = m_nPageSize;
-    vSlData.usScale2Increments = m_nPageSize;
-
-    HWND                            hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
-                                                                   ,WC_SLIDER                // Window class
-                                                                   ,(PSZ)wxBuffer            // Initial Text
-                                                                   ,(ULONG)lMsStyle          // Style flags
-                                                                   ,0L, 0L, 0L, 0L           // Origin -- 0 size
-                                                                   ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
-                                                                   ,HWND_TOP                 // initial z position
-                                                                   ,(HMENU)m_windowId       // Window identifier
-                                                                   ,&vSlData                 // Slider control data
-                                                                   ,NULL                     // no Presentation parameters
-                                                                  );
+    vSlData.usScale1Increments = (USHORT)m_nPageSize;
+    vSlData.usScale2Increments = (USHORT)m_nPageSize;
+
+    HWND hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
+                                        ,WC_SLIDER                // Window class
+                                        ,(PSZ)wxBuffer            // Initial Text
+                                        ,(ULONG)lMsStyle          // Style flags
+                                        ,0L, 0L, 0L, 0L           // Origin -- 0 size
+                                        ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
+                                        ,HWND_BOTTOM                 // initial z position
+                                        ,(HMENU)m_windowId       // Window identifier
+                                        ,&vSlData                 // Slider control data
+                                        ,NULL                     // no Presentation parameters
+                                       );
     m_nRangeMax = nMaxValue;
     m_nRangeMin = nMinValue;
 
@@ -288,7 +332,7 @@ bool wxSlider::Create(
     //
     ::WinSendMsg( hScrollBar
                  ,SLM_SETTICKSIZE
-                 ,MPFROM2SHORT(SMA_SETALLTICKS, 6)
+                 ,MPFROM2SHORT(SMA_SETALLTICKS, (USHORT)12)
                  ,NULL
                 );
     //
@@ -304,18 +348,13 @@ bool wxSlider::Create(
     SubclassWin(GetHWND());
     ::WinSetWindowText((HWND)m_hWnd, "");
 
-    wxFont*                          pTextFont = new wxFont( 10
-                                                            ,wxMODERN
-                                                            ,wxNORMAL
-                                                            ,wxNORMAL
-                                                           );
-    SetFont(*pTextFont);
+    SetFont(*wxSMALL_FONT);
     if (m_windowStyle & wxSL_LABELS)
     {
         //
         // Finally, create max value static item
         //
-        sprintf(wxBuffer, "%d", nMaxValue);
+        wxSprintf(wxBuffer, wxT("%d"), nMaxValue);
         lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE;
         if (m_windowStyle & wxCLIP_SIBLINGS)
             lMsStyle |= WS_CLIPSIBLINGS;
@@ -351,6 +390,8 @@ bool wxSlider::Create(
         }
     }
 
+    SetXComp(0);
+    SetYComp(0);
     SetSize( nX
             ,nY
             ,nWidth
@@ -365,11 +406,9 @@ bool wxSlider::Create(
                                               )
                                  ) + 4; // for bordersizes
 
-    wxColour                        vColour;
-
-    vColour.Set(wxString("BLACK"));
+    wxColour vColour(*wxBLACK);
 
-    LONG                            lColor = (LONG)vColour.GetPixel();
+    LONG lColor = (LONG)vColour.GetPixel();
 
     ::WinSetPresParam( m_hStaticMin
                       ,PP_FOREGROUNDCOLOR
@@ -412,31 +451,36 @@ bool wxSlider::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
+    vColour.Set(wxString(wxT("BLUE")));
+    lColor = (LONG)vColour.GetPixel();
+    ::WinSetPresParam( m_hWnd
+                      ,PP_HILITEBACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
     SetValue(nValue);
-    delete pTextFont;
-    return TRUE;
+    return true;
 } // end of wxSlider::Create
 
-void wxSlider::DoSetSize(
-  int                               nX
-, int                               nY
-, int                               nWidth
-, int                               nHeight
-, int                               nSizeFlags
-)
+void wxSlider::DoSetSize( int nX,
+                          int nY,
+                          int nWidth,
+                          int nHeight,
+                          int nSizeFlags )
 {
-    int                             nX1      = nX;
-    int                             nY1      = nY;
-    int                             nWidth1  = nWidth;
-    int                             nHeight1 = nHeight;
-    int                             nXOffset = nX;
-    int                             nYOffset = nY;
-    int                             nCx;     // slider,min,max sizes
-    int                             nCy;
-    int                             nCyf;
-    int                             nCurrentX;
-    int                             nCurrentY;
-    char                            zBuf[300];
+    int    nX1      = nX;
+    int    nY1      = nY;
+    int    nWidth1  = nWidth;
+    int    nHeight1 = nHeight;
+    int    nXOffset = nX;
+    int    nYOffset = nY;
+    int    nCx;     // slider,min,max sizes
+    int    nCy;
+    int    nCyf;
+    int    nCurrentX;
+    int    nCurrentY;
+    wxChar zBuf[300];
+    wxFont vFont = this->GetFont();
 
     //
     // Adjust for OS/2's reverse coordinate system
@@ -447,29 +491,28 @@ void wxSlider::DoSetSize(
 
     if (nOS2Height < 0)
         nOS2Height = 20;
+    CacheBestSize(wxSize(nWidth,nOS2Height));
 
     if (pParent)
     {
-        int                         nOS2ParentHeight = GetOS2ParentHeight(pParent);
+        int nOS2ParentHeight = GetOS2ParentHeight(pParent);
 
         nYOffset = nOS2ParentHeight - (nYOffset + nOS2Height);
-        if (nY != -1)
+        if (nY != wxDefaultCoord)
             nY1 = nOS2ParentHeight - (nY1 + nOS2Height);
     }
     else
     {
-        RECTL                       vRect;
+        RECTL vRect;
 
         ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
         nYOffset = vRect.yTop - (nYOffset + nOS2Height);
-        if (nY != -1)
+        if (nY != wxDefaultCoord)
             nY1 = vRect.yTop - (nY1 + nOS2Height);
     }
     m_nSizeFlags = nSizeFlags;
 
-    GetPosition( &nCurrentX
-                ,&nCurrentY
-               );
+    GetPosition( &nCurrentX, &nCurrentY );
     if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
         nX1 = nCurrentX;
     if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
@@ -482,7 +525,7 @@ void wxSlider::DoSetSize(
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,&this->GetFont()
+                  ,&vFont
                  );
 
     if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
@@ -492,10 +535,10 @@ void wxSlider::DoSetSize(
             int                  nMinLen = 0;
             int                  nMaxLen = 0;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
 
             if (m_hStaticValue)
             {
@@ -505,7 +548,7 @@ void wxSlider::DoSetSize(
                 ::WinSetWindowPos( (HWND)m_hStaticValue
                                   ,HWND_TOP
                                   ,(LONG)nXOffset
-                                  ,(LONG)nYOffset - (nCyf * 1.2)
+                                  ,(LONG)nYOffset - (LONG)(nCyf * 1.2)
                                   ,(LONG)nNewWidth
                                   ,(LONG)nValueHeight
                                   ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -515,7 +558,7 @@ void wxSlider::DoSetSize(
             ::WinSetWindowPos( (HWND)m_hStaticMin
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset - nCyf
+                              ,(LONG)nYOffset - (LONG)(nCyf * 1.2)
                               ,(LONG)nMinLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -542,12 +585,20 @@ void wxSlider::DoSetSize(
                               ,(LONG)nSliderHeight
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                              );
+            ::WinQueryWindowPos(GetHwnd(), GetSwp());
+            ::WinSendMsg( GetHwnd()
+                         ,SLM_SETSLIDERINFO
+                         ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
+                                       ,0
+                                      )
+                         ,MPFROMLONG((ULONG)(nSliderHeight/2))
+                        );
             nXOffset += nSliderLength + nCx;
 
             ::WinSetWindowPos( (HWND)m_hStaticMax
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset - nCyf
+                              ,(LONG)nYOffset - (LONG)(nCyf * 1.2)
                               ,(LONG)nMaxLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -591,42 +642,33 @@ void wxSlider::DoSetSize(
             int                  nMinLen;
             int                  nMaxLen;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
             if (m_hStaticValue)
             {
                 int              nNewWidth = wxMax(nMinLen, nMaxLen);
                 int              nValueHeight = nCyf;
 
-                nNewWidth += nCx;
-
-                //
-                // The height needs to be a bit bigger under Win95 if using native
-                // 3D effects.
-                //
-                nValueHeight = (int)(nValueHeight * 1.5);
                 ::WinSetWindowPos( (HWND)m_hStaticValue
                                   ,HWND_TOP
                                   ,(LONG)nXOffset
-                                  ,(LONG)nYOffset
+                                  ,(LONG)nYOffset + nHeight
                                   ,(LONG)nNewWidth
                                   ,(LONG)nValueHeight
                                   ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                                  );
-                nYOffset -= nValueHeight;
-                nUsedHeight += nValueHeight;
+                nUsedHeight += nCyf;
             }
             ::WinSetWindowPos( (HWND)m_hStaticMin
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset
+                              ,(LONG)nYOffset + nHeight - nCyf
                               ,(LONG)nMinLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                              );
-            nYOffset -= nCy;
             nUsedHeight += nCy;
 
             int                  nSliderLength = nHeight1 - (nUsedHeight + (2 * nCy));
@@ -641,20 +683,27 @@ void wxSlider::DoSetSize(
             if (nSliderLength < 100)
                 nSliderLength = 100;
 
-            ::WinSetWindowPos( (HWND)m_hStaticMin
+            ::WinSetWindowPos( GetHwnd()
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset
+                              ,(LONG)nYOffset + nCyf
                               ,(LONG)nSliderWidth
                               ,(LONG)nSliderLength
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                              );
-            nYOffset -= nSliderLength;
+            ::WinQueryWindowPos(GetHwnd(), GetSwp());
+            ::WinSendMsg( GetHwnd()
+                         ,SLM_SETSLIDERINFO
+                         ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
+                                       ,0
+                                      )
+                         ,MPFROMLONG((ULONG)(nSliderWidth/2))
+                        );
             nUsedHeight += nSliderLength;
             ::WinSetWindowPos( (HWND)m_hStaticMax
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset
+                              ,(LONG)nYOffset - nCyf
                               ,(LONG)nMaxLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -758,8 +807,10 @@ void wxSlider::GetPosition(
         vPoint.x -= vPt.x;
         vPoint.y -= vPt.y;
     }
-    *pnX = vPoint.x;
-    *pnY = vPoint.y;
+    if (pnX)
+        *pnX = vPoint.x;
+    if (pnY)
+        *pnY = vPoint.y;
 } // end of wxSlider::GetPosition
 
 int wxSlider::GetSelEnd() const
@@ -810,8 +861,10 @@ void wxSlider::GetSize(
         wxFindMaxSize( m_hStaticValue
                       ,&vRect
                      );
-    *pnWidth  = vRect.xRight - vRect.xLeft;
-    *pnHeight = vRect.yBottom - vRect.yTop;
+    if (pnWidth)
+        *pnWidth  = vRect.xRight - vRect.xLeft;
+    if (pnHeight)
+        *pnHeight = vRect.yTop - vRect.yBottom;
 } // end of wxSlider::GetSize
 
 int wxSlider::GetThumbLength() const
@@ -864,14 +917,12 @@ WXHBRUSH wxSlider::OnCtlColor(
            );
 } // end of wxSlider::OnCtlColor
 
-bool wxSlider::OS2OnScroll(
-  int                               WXUNUSED(nOrientation)
-, WXWORD                            wParam
-, WXWORD                            wPos
-, WXHWND                            hControl
-)
+bool wxSlider::OS2OnScroll( int    WXUNUSED(nOrientation),
+                            WXWORD wParam,
+                            WXWORD WXUNUSED(wPos),
+                            WXHWND WXUNUSED(hControl) )
 {
-    wxEventType                     eScrollEvent = wxEVT_NULL;
+    wxEventType eScrollEvent = wxEVT_NULL;
 
     switch (wParam)
     {
@@ -887,28 +938,25 @@ bool wxSlider::OS2OnScroll(
             break;
 
         default:
-            return FALSE;
+            return false;
     }
 
-    int                             nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd()
-                                                                            ,SLM_QUERYSLIDERINFO
-                                                                            ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
-                                                                                          ,SMA_RANGEVALUE
-                                                                                         )
-                                                                            ,(MPARAM)0
-                                                                           )
-                                                              );
+    int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd()
+                                               , SLM_QUERYSLIDERINFO
+                                               , MPFROM2SHORT( SMA_SHAFTDIMENSIONS, SMA_RANGEVALUE )
+                                               , (MPARAM)0
+                                               )
+                                  );
     m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin);
-    int                             nNewPos = 0;
-    int                             nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd()
-                                                                          ,SLM_QUERYSLIDERINFO
-                                                                          ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
-                                                                                        ,SMA_RANGEVALUE
-                                                                                       )
-                                                                          ,(MPARAM)0
-                                                                         )
-                                                            );
-    nNewPos = (nPixelPos/m_dPixelToRange);
+    int nNewPos = 0;
+    int nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd()
+                                             , SLM_QUERYSLIDERINFO
+                                             , MPFROM2SHORT( SMA_SLIDERARMPOSITION, SMA_RANGEVALUE )
+                                             , (MPARAM)0
+                                             )
+                                );
+
+    nNewPos = (int)(nPixelPos/m_dPixelToRange);
     if (nNewPos > (m_nRangeMax - m_nRangeMin)/2)
         nNewPos++;
     if ((nNewPos < GetMin()) || (nNewPos > GetMax()))
@@ -916,38 +964,30 @@ bool wxSlider::OS2OnScroll(
         //
         // Out of range - but we did process it
         //
-        return TRUE;
+        return true;
     }
     SetValue(nNewPos);
 
-    wxScrollEvent                   vEvent( eScrollEvent
-                                           ,m_windowId
-                                          );
+    wxScrollEvent vEvent( eScrollEvent, m_windowId );
 
     vEvent.SetPosition(nNewPos);
     vEvent.SetEventObject(this);
-    GetEventHandler()->ProcessEvent(vEvent);
+    HandleWindowEvent(vEvent);
 
-    wxCommandEvent                  vCevent( wxEVT_COMMAND_SLIDER_UPDATED
-                                            ,GetId()
-                                           );
+    wxCommandEvent vCevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() );
 
     vCevent.SetInt(nNewPos);
     vCevent.SetEventObject(this);
-    return (GetEventHandler()->ProcessEvent(vCevent));
+    return (HandleWindowEvent(vCevent));
 } // end of wxSlider::OS2OnScroll
 
-void wxSlider::SetLineSize(
-  int                               nLineSize
-)
+void wxSlider::SetLineSize( int nLineSize )
 {
     m_nLineSize = nLineSize;
 } // end of wxSlider::SetLineSize
 
 
-void wxSlider::SetPageSize(
-  int                               nPageSize
-)
+void wxSlider::SetPageSize( int nPageSize )
 {
     m_nPageSize = nPageSize;
 } // end of wxSlider::SetPageSize
@@ -974,13 +1014,13 @@ void wxSlider::SetRange(
     if (m_hStaticMin)
     {
         wxSprintf(zBuf, wxT("%d"), m_nRangeMin);
-        ::WinSetWindowText((HWND)m_hStaticMin, zBuf);
+        ::WinSetWindowText((HWND)m_hStaticMin, (PSZ)zBuf);
     }
 
     if (m_hStaticMax)
     {
         wxSprintf(zBuf, wxT("%d"), m_nRangeMax);
-        ::WinSetWindowText((HWND)m_hStaticMax, zBuf);
+        ::WinSetWindowText((HWND)m_hStaticMax, (PSZ)zBuf);
     }
 } // end of wxSlider::SetRange
 
@@ -1027,7 +1067,7 @@ void wxSlider::SetTick(
   int                               nTickPos
 )
 {
-    nTickPos *= m_dPixelToRange;
+    nTickPos = (int)(nTickPos * m_dPixelToRange);
     ::WinSendMsg( GetHwnd()
                  ,SLM_ADDDETENT
                  ,MPFROMSHORT(nTickPos)
@@ -1036,15 +1076,12 @@ void wxSlider::SetTick(
 } // end of wxSlider::SetTick
 
 // For trackbars only
-void wxSlider::SetTickFreq(
-  int                               n
-, int                               nPos
-)
+void wxSlider::SetTickFreq( int n, int WXUNUSED(nPos) )
 {
-    SLDCDATA                        vSlData;
-    WNDPARAMS                       vWndParams;
-    int                             nPixelPos;
-    int                             i;
+    SLDCDATA  vSlData;
+    WNDPARAMS vWndParams;
+    int       nPixelPos;
+    int       i;
 
     vSlData.cbSize = sizeof(SLDCDATA);
     if (m_windowStyle & wxSL_AUTOTICKS)
@@ -1052,8 +1089,8 @@ void wxSlider::SetTickFreq(
         vSlData.usScale1Spacing = 0;
         vSlData.usScale2Spacing = 0;
     }
-    vSlData.usScale1Increments = (m_nRangeMax - m_nRangeMin)/n;
-    vSlData.usScale2Increments = (m_nRangeMax - m_nRangeMin)/n;
+    vSlData.usScale1Increments = (USHORT)((m_nRangeMax - m_nRangeMin)/n);
+    vSlData.usScale2Increments = (USHORT)((m_nRangeMax - m_nRangeMin)/n);
 
     vWndParams.fsStatus = WPM_CTLDATA;
     vWndParams.cchText  = 0L;
@@ -1065,7 +1102,7 @@ void wxSlider::SetTickFreq(
     ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)0);
     for (i = 1; i < (m_nRangeMax - m_nRangeMin)/n; i++)
     {
-        nPixelPos = i * n * m_dPixelToRange;
+        nPixelPos = (int)(i * n * m_dPixelToRange);
         ::WinSendMsg( GetHwnd()
                      ,SLM_ADDDETENT
                      ,MPFROMSHORT(nPixelPos)
@@ -1078,14 +1115,6 @@ void wxSlider::SetValue(
   int                               nValue
 )
 {
-    int                             nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd()
-                                                                          ,SLM_QUERYSLIDERINFO
-                                                                          ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
-                                                                                        ,SMA_RANGEVALUE
-                                                                                       )
-                                                                          ,(MPARAM)0
-                                                                         )
-                                                            );
     int                             nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd()
                                                                             ,SLM_QUERYSLIDERINFO
                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
@@ -1107,7 +1136,7 @@ void wxSlider::SetValue(
     if (m_hStaticValue)
     {
         wxSprintf(wxBuffer, wxT("%d"), nValue);
-        ::WinSetWindowText((HWND)m_hStaticValue, wxBuffer);
+        ::WinSetWindowText((HWND)m_hStaticValue, (PSZ)wxBuffer);
     }
 } // end of wxSlider::SetValue
 
@@ -1122,6 +1151,7 @@ bool wxSlider::Show(
         ::WinShowWindow((HWND)m_hStaticMin, bShow);
     if(m_hStaticMax)
         ::WinShowWindow((HWND)m_hStaticMax, bShow);
-    return TRUE;
+    return true;
 } // end of wxSlider::Show
 
+#endif // wxUSE_SLIDER