A brief introduction of CHTSlider control class of HTControl control class in VC++

  • 2020-04-02 02:33:06
  • OfStack

This article describes the file code for a joystick control class in the HTControl control control. This class is completely independent and does not have any base classes. Implemented directly by the WIN32 API. You can use it with the SDK, MFC, wxWidget, etc. The control includes a vertical lever control, which is used in exactly the same way as the horizontal control. The form must be created dynamically with the following code snippet:


m_HTSliderR.Create(130, 500, 400, 14, m_hWnd, iChildId++, 0, 9, 14);
m_HTSliderR.SetBgPic(_T(".\pic\SliderBg.png"), NULL, 5, 5);
m_HTSliderR.SetThumbPic(_T(".\pic\SliderThumbN.png"));
m_HTSliderR.SetMouseOnThumbPic(_T(".\pic\SliderThumbH.png"));

Easy to use, can be considered as a window is a C++ object, to achieve a function of direct call interface can be, no additional code. The following is the main file code of the joystick class:



#if !defined(__CHTSLIDER_H__)
#define __CHTSLIDER_H__
#include "CHTTip.h"
class CMySlider;
//#ifdef HTCONTROLAPI
//class __declspec(dllexport) CHTSlider
//#else
//class __declspec(dllimport) CHTSlider
//#endif
class AFX_CLASS_EXPORT CHTSlider
{
public:
 CHTSlider();
 ~CHTSlider();

HWND Create(int x, 
 int y,
 int iWidth, 
 int iHeight, 
 HWND hParent, 
 int iSliderId, 
 int iThumbTop,
 int iThumbWidth,
 int iThumbHeight,
 RECT* pRectChannel = NULL);

 void MoveWindow(int x, int y, int iWidth, BOOL bRepaint = TRUE);

 void SetToolTip(CHTTip* pclTip);

 HWND GetHandle();

 HWND GetParent();

void Disable();

void Enable();

void SetBgBitmap(HBITMAP hBitmap, int iBgLeftLen = 0, int iBgRightLen = 0);

void SetChannelBitmap(HBITMAP hBitmap, int iChannelLeftLen = 0, int iChannelRightLen = 0);

void SetThumbBitmap(HBITMAP hBitmap);

void SetMouseOnThumbBitmap(HBITMAP hBitmap);

void SetRange(int iRange);

int GetRange();

void SetValue(int iValue);

int GetValue();

int GetTipValue();

void SetLineSize(int iLineSize);

int GetLineSize();

void SetTransparency(int iTransparency);

void SetParentBgMemDC(HDC hParentBgMemDC, int x = 0, int y = 0);

void SetParentBgBitmap(HBITMAP hParentBgBitmap, int x = 0, int y = 0);

void SetParentBgColor(COLORREF CRParentBg = RGB(236, 233, 216));
private:
 CMySlider* m_pclSlider;
};
#endif //!__CHTSLIDER_H__

In addition to the window, CHTSlider also has flexible interface performance, arbitrary form transparency changes, such as using the following interface to achieve transparency changes:


void SetTransparency(int iTransparency);

Hope that the code described in this article can be useful to everyone's VC++ project development.


Related articles: