/***************************************************************************
**
**    $Header$
**
**    $Log$
** 
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  SPIN.H
//
//  Description:The header file for the class: CSpinControl
//
//  Author:     Roger Zhang
//
//  Date:       03/08/95
//
//  Modification:
//
//      1. 03/08/95, Initial version 
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////

#ifndef _SPIN_
#define _SPIN_

//Control-specific messages
#define MSM_HWNDASSOCIATESET  (WM_USER+1)
#define MSM_HWNDASSOCIATEGET  (WM_USER+2)
#define MSM_DWRANGESET        (WM_USER+3)
#define MSM_DWRANGEGET        (WM_USER+4)
#define MSM_WCURRENTPOSSET    (WM_USER+5)
#define MSM_WCURRENTPOSGET    (WM_USER+6)
#define MSM_FNOPEGSCROLLSET   (WM_USER+7)
#define MSM_FNOPEGSCROLLGET   (WM_USER+8)
#define MSM_FINVERTRANGESET   (WM_USER+9)
#define MSM_FINVERTRANGEGET   (WM_USER+10)
#define MSM_CRCOLORSET        (WM_USER+11)
#define MSM_CRCOLORGET        (WM_USER+12)

//Message API Functions
HWND     FAR PASCAL MSHAssociateSet(HWND hWnd, HWND hWndAssociate);
HWND     FAR PASCAL MSHAssociateGet(HWND hWnd);
DWORD    FAR PASCAL MSDwRangeSet(HWND hWnd, WORD iMin, WORD iMax);
DWORD    FAR PASCAL MSDwRangeGet(HWND hWnd);
WORD     FAR PASCAL MSWCurrentPosSet(HWND hWnd, WORD iPos);
WORD     FAR PASCAL MSWCurrentPosGet(HWND hWnd);
BOOL     FAR PASCAL MSFNoPegScrollSet(HWND hWnd, BOOL fNoPegScroll);
BOOL     FAR PASCAL MSFNoPegScrollGet(HWND hWnd);
BOOL     FAR PASCAL MSFInvertRangeSet(HWND hWnd, BOOL fInvertRange);
BOOL     FAR PASCAL MSFInvertRangeGet(HWND hWnd);
COLORREF FAR PASCAL MSCrColorSet(HWND hWnd, WORD iColor, COLORREF cr);
COLORREF FAR PASCAL MSCrColorGet(HWND hWnd, WORD iColor);

//Notification codes sent via WM_COMMAND from the control.
#define MSN_ASSOCIATEGAIN   1
#define MSN_ASSOCIATELOSS   2
#define MSN_RANGECHANGE     3

//Color indices for MSM_COLORSET/GET and MSCrColorSet/Get
#define MSCOLOR_FACE        0
#define MSCOLOR_ARROW       1
#define MSCOLOR_SHADOW      2
#define MSCOLOR_HIGHLIGHT   3
#define MSCOLOR_FRAME       4

#define CCOLORS             5

//Control specific styles.
#define MSS_VERTICAL        0x0001L
#define MSS_HORIZONTAL      0x0002L
#define MSS_NOPEGSCROLL     0x0004L
#define MSS_TEXTHASRANGE    0x0008L
#define MSS_INVERTRANGE     0x0010L

class CSpinControl : public CWnd
{
    DECLARE_DYNAMIC(CSpinControl)

// Constructors
public:
    CSpinControl();
    BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

// Attributes
    CWnd* GetAssociate();
    void SetAssociate(CWnd* pNew);
    void GetRange(UINT& iMin, UINT& iMax);
    void SetRange(UINT iMin, UINT iMax);
    UINT GetCurrentPos();
    void SetCurrentPos(UINT iPos);
    // there are more APIs not wrapped here

// Implementation
protected:
    virtual WNDPROC* GetSuperWndProcAddr();
};

/////////////////////////////////////////////////////////////////////////////
// inlines
inline CSpinControl::CSpinControl() {}
inline CWnd* CSpinControl::GetAssociate()
{ return CWnd::FromHandle((HWND)SendMessage(MSM_HWNDASSOCIATEGET)); }
inline void CSpinControl::SetAssociate(CWnd* pNew)
{ SendMessage(MSM_HWNDASSOCIATESET, (UINT)pNew->GetSafeHwnd()); }
inline void CSpinControl::GetRange(UINT& iMin, UINT& iMax)
{ DWORD dw = SendMessage(MSM_DWRANGEGET);
        iMin = LOWORD(dw); iMax = HIWORD(dw);
}
inline void CSpinControl::SetRange(UINT iMin, UINT iMax)
{ SendMessage(MSM_DWRANGESET, 0, MAKELONG(iMin, iMax)); }
inline UINT CSpinControl::GetCurrentPos()
{ return (UINT)SendMessage(MSM_WCURRENTPOSGET); }
inline void CSpinControl::SetCurrentPos(UINT iPos)
{ SendMessage(MSM_WCURRENTPOSSET, iPos); }

#endif

//////////////////////////////(EOF)//////////////////////////////////////////
