Introduction to Chtslider control bar control class of Htcontrol control class in VC + + _c language

Source: Internet
Author: User

This article describes a control bar control class file code in the Htcontrol control, which is completely self-contained and has no base class. Implemented directly by the WIN32 API. You can use it in sdk,mfc,wxwidget and so on. Control includes a vertical joystick control, which is used in exactly the same way as the horizontal one. The form must be created dynamically, with specific code snippets as follows:

M_htsliderr.create (130, M_hwnd, ichildid++, 0, 9);
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 to be a window is a C + + object, to implement a function of direct call interface, there is no additional code. Here is the main file code for the joystick class:

/****************************************************************************
|
Copyright (c) 2012, | /#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 (); /****************************************************************************
| function function: Create Joystick Control | | Input Parameters: | | X: Form position x coordinates (relative to parent form) | | Y: Form position y-coordinate (relative to parent form) | | Iwidth: Form Width | | Iheight: Form High | | Hparent: parent form Handle | | Isliderid: Form ID | | Ithumbtop: Slider Top Coordinates | |                 Ithumbwidth: Slider Width           |
| Ithumbheight: Sliding block Height | | Prectchannel:channel Rectangle (channel occupied rectangle) null represents not drawing Channel | | Output parameters: none | | Return value: Successfully return form handle failed return NULL | |
Description: | /HWND Create (int x, int y, int iwidth, I NT Iheight, HWND hparent, int isliderid, int ithumbtop, int ithumbwidth, int ithumbheight, rect* prectchannel = N
ULL); /****************************************************************************
| function function: Change window position Size | | Input Parameters: | | X: Form position x coordinates (relative to parent form) | | Y: Form position y-coordinate (relative to parent form) | | Iwidth: Form Width | | Brepaint: Whether to redraw the form | | Output parameters: none | | return value: none | |
Description: Do not support height change | ******************************************/void MoveWindow (int x, int y, int iwidth, BOOL brepaint = TRUE); /****************************************************************************
| function function: Set hint window class pointer | | Input Parameters: | | PCLTIP: Hint window class pointer | | Output parameters: none | | return value: none | |
Description: |
/void SetToolTip (chttip* pcltip); /****************************************************************************
| function function: Get the handle of the window | | Input parameters: none | | Output parameters: none | | Return value: Form Handle | |
Description: |
/HWND gethandle ();
/****************************************************************************| function function: Get the handle of the parent window | | Input parameters: none | | Output parameters: none | | Return value: Form Handle | |
Description: |
/HWND getparent (); /****************************************************************************
| function function: Make window Invalid | | Input parameters: none | | Output parameters: none | | return value: none | |
Description: |
/void Disable (); /****************************************************************************
| function function: Make window effective | | Input parameters: none | | Output parameters: none | | return value: none | |
Description: | **************************************/void Enable (); /****************************************************************************
| function function: Set form background Bitmap | | Input Parameters: | | Hbitmap: Bitmap | | Ibgleftlen: The left side of the picture is not stretched part length | | Ibgrightlen: The right side of the picture is not stretched part length | | Output parameters: none | | return value: none | |
Description: | /void Setbgbitmap (Hbitmap hbitmap,
int ibgleftlen = 0, int ibgrightlen = 0); /****************************************************************************
| function function: Set Channel Bitmap | | Input Parameters: | | Hbitmap: Bitmap | | Ichannelleftlen: The left side of the picture is not stretched part length | | Ichannelrightlen: The right side of the picture is not stretched part length | | Output parameters: none | |          return value: None                     |
|
Description: | /void Setchannelbitmap (HBITMAP
hbitmap, int ichannelleftlen = 0, int ichannelrightlen = 0); /****************************************************************************
| function function: Set slider Bitmap | | Input Parameters: | | Hbitmap: Bitmap | | Output parameters: none | | return value: none | |
Description: | /void Setthumbbitmap (Hbitmap hbitmap
); /****************************************************************************
| function function: Set the mouse on the slider bitmap | | Input Parameters: | | Hbitmap: Bitmap | | Output parameters: none | | return value: none | |                             Description   | /void Setmouseonthumbbitmap (HBITMAP
HBITMAP); /****************************************************************************
| function function: Set logical range, restore logical value to 0, | | Input Parameters: | | Irange: Maximum value of logical value | | Output parameters: none | | return value: none | |
Note: If the parameter is 0, this function has no effect |
/void SetRange (int irange); /****************************************************************************
| function function: Get Logical Range | | Input parameters: none | | Output parameters: none | | Return value: Range | |
Description: |
/int GetRange (); /****************************************************************************
| function function: Set current logical value | | Input Parameters: | | Ivalue: Logical value to set | | Output parameters: none | | return value: none | |
Description: |
/void SetValue (int ivalue); /****************************************************************************
| function function: Get current logical value | | Input parameters: none | | Output parameters: none | | Return value: Current Logical value | |
Description: |
/int GetValue (); /****************************************************************************
| function function: Get the logical value of the mouse location | | Input parameters: none | | Output parameters: none | | Return value: Logical value | | Description                               |
/int gettipvalue (); /****************************************************************************
| function function: Sets the logical value change size when the arrow key or pulley is rolled once Input Parameters: | | Ilinesize: Logical value change Size | | Output parameters: none | | return value: none | |
Description: |
/void setlinesize (int ilinesize); /****************************************************************************
| function function: Gets the logical value change size when the arrow key or pulley is rolled once Input Parameters: | | Output parameters: none | | Return value: Logical value change Size | |
Description: |
/int getlinesize (); /****************************************************************************
| function function: Set the opacity of the form | | Input Parameters: | | Itransparency: Percentage of opacity | | Output parameters: none | | return value: none | |
Description: | /void settransparency (int
Itransparency); /****************************************************************************
| function function: Set parent form background Memory Canvas | | Input Parameters: | | HPARENTBGMEMDC: Parent form background Memory Canvas | | Output parameters: none | | return value: none | |      Description: When the background of the parent form changes and the form itself is transparent (including the bitmap used by the form | |
Has transparency or the form does not have a background bitmap), you need to call this interface | /void Setparentbgmemdc (HDC
HPARENTBGMEMDC, int x = 0, int y = 0); /****************************************************************************
| FunctionFunction: Set the background bitmap used by the parent form | | Input Parameters: | | Hparentbgbitmap: The background bitmap used by the parent form | | x, y bitmap painting starting point coordinates | | Output parameters: none | | return value: none | |      Description: When the parent form background uses a static bitmap and the form itself is transparent (including form use | |
Bitmap has transparency or the form does not have a background bitmap), you need to call this interface | /void Setparentbgbitmap (HBITMAP
Hparentbgbitmap, int x = 0, int y = 0); /****************************************************************************
| function function: Set parent form background Color | | Input Parameters: | | CRPARENTBG: Parent form background Color | | Output parameters: none | | return value: none | |      Description: When the parent form background uses a fixed color and the form itself is transparent (including form use | |
Bitmap has transparency or the form does not have a background bitmap), you need to call this interface | /void Setparentbgcolor (COLORREF CRPARENTBG = RGB (236, 233, 216));
private:cmyslider* M_pclslider;
};

 #endif//!__chtslider_h__

In addition, the Chtslider control bar class also has flexible interface performance, form arbitrary transparency changes, such as the use of the following interface to achieve transparency changes:

void settransparency (int itransparency);

I hope the code described in this article can be a certain help for VC + + project development.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.