// CoolSliderDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CoolSlider.h"
#include "CoolSliderDlg.h"
#include "BitItem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCoolSliderDlg dialog
CCoolSliderDlg::CCoolSliderDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCoolSliderDlg::IDD, pParent),
m_lpNormal(NULL),
m_lpActive(NULL),
m_lpThumb(NULL),
m_hHandCur(NULL)
{
//{{AFX_DATA_INIT(CCoolSliderDlg)
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
CCoolSliderDlg::~CCoolSliderDlg()
{
if( m_lpNormal != NULL )
{
delete m_lpNormal;
m_lpNormal = NULL;
}
if( m_lpActive != NULL )
{
delete m_lpActive;
m_lpActive = NULL;
}
if( m_lpThumb != NULL )
{
delete m_lpThumb;
m_lpThumb = NULL;
}
}
void CCoolSliderDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCoolSliderDlg)
DDX_Control(pDX, IDC_SLIDER_VERTICAL2, m_ctlVert2);
DDX_Control(pDX, IDC_SLIDER_VERTICAL1, m_ctlVert1);
DDX_Control(pDX, IDC_SLIDER_SHARE3, m_ctlShare3);
DDX_Control(pDX, IDC_SLIDER_SHARE2, m_ctlShare2);
DDX_Control(pDX, IDC_SLIDER_SHARE1, m_ctlShare1);
DDX_Control(pDX, IDC_COOL_SLIDER, m_ctlSlider);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCoolSliderDlg, CDialog)
//{{AFX_MSG_MAP(CCoolSliderDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_ERASEBKGND()
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_COOL_SLIDER, OnReleasedcaptureCoolSlider)
ON_NOTIFY(NM_OUTOFMEMORY, IDC_SLIDER1, OnOutofmemorySlider1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCoolSliderDlg message handlers
BOOL CCoolSliderDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// m_hHandCur = this->GetSysHandCursor();
this->BuildCoolSlider(); // Build your cool-slider in simple mode...
this->BuildShareSlider(); // Build your cool-slider in shared resource mode...:)
this->BuildVerticalSlider();
return TRUE;
}
void CCoolSliderDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCoolSliderDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCoolSliderDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
HCURSOR CCoolSliderDlg::GetSysHandCursor()
{
TCHAR strWinDir[MAX_PATH] = {0};
HCURSOR hHandCursor = NULL;
hHandCursor = ::LoadCursor(NULL, MAKEINTRESOURCE(32649));
// Still no cursor handle - load the WinHelp hand cursor
if( hHandCursor == NULL )
{
GetWindowsDirectory(strWinDir, MAX_PATH);
strcat(strWinDir, _T("\\winhlp32.exe"));
// This retrieves cursor #106 from winhlp32.exe, which is a hand pointer
HMODULE hModule = ::LoadLibrary(strWinDir);
DWORD dwErr = GetLastError();
if( hModule != NULL )
{
HCURSOR hTempCur = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
hHandCursor = (hTempCur != NULL) ? CopyCursor(hTempCur) : NULL;
FreeLibrary(hModule);
}
}
return hHandCursor;
}
void CCoolSliderDlg::BuildCoolSlider()
{
m_hHandCur = this->GetSysHandCursor();
ASSERT( m_hHandCur != NULL );
m_ctlSlider.SetFlipCursor(m_hHandCur);
m_ctlSlider.BuildThumbItem(IDB_BITMAP_THUMB, 12,6);
m_ctlSlider.BuildBackItem(IDB_BITMAP_NORMAL, IDB_BITMAP_ACTIVE);
m_ctlSlider.SetTopOffset(3);
m_ctlSlider.SetRange(0, 100);
m_ctlSlider.SetLineSize(0);
m_ctlSlider.SetPos(100);
/* m_ctlVert1.SetFlipCursor(m_hHandCur);
m_ctlVert1.BuildThumbItem(IDB_VERTICAL_THUMB, 12, 6);
m_ctlVert1.BuildBackItem(IDB_VERTICAL_NORMAL, IDB_VERTICAL_ACTIVE);
m_ctlVert1.SetLeftOffset(3);
m_ctlVert1.SetRange(0, 100);
m_ctlVert1.SetLineSize(0);
m_ctlVert1.SetPos(50);
*/
}
void CCoolSliderDlg::BuildShareSlider()
{
ASSERT( m_hHandCur != NULL );
ASSERT( m_lpActive == NULL );
ASSERT( m_lpNormal == NULL );
ASSERT( m_lpThumb == NULL );
m_lpActive = new CBitItem(IDB_BITMAP_ACTIVE, 0, 0);
m_lpNormal = new CBitItem(IDB_BITMAP_NORMAL, 0, 0);
m_lpThumb = new CBitItem(IDB_BITMAP_THUMB, 6, 12);
m_ctlShare1.SetFlipCursor(m_hHandCur);
m_ctlShare1.BuildThumbItem(m_lpThumb);
m_ctlShare1.BuildBackItem(m_lpNormal, m_lpActive);
m_ctlShare1.SetTopOffset(3);
m_ctlShare1.SetRange(0, 100);
m_ctlShare1.SetLineSize(0);
m_ctlShare1.SetPos(40);
m_ctlShare2.SetFlipCursor(m_hHandCur);
m_ctlShare2.BuildThumbItem(m_lpThumb);
m_ctlShare2.BuildBackItem(m_lpNormal, m_lpActive);
m_ctlShare2.SetTopOffset(3);
m_ctlShare2.SetRange(0, 100);
m_ctlShare2.SetLineSize(0);
m_ctlShare2.SetPos(60);
m_ctlShare3.SetFlipCursor(m_hHandCur);
m_ctlShare3.BuildThumbItem(m_lpThumb);
m_ctlShare3.BuildBackItem(m_lpNormal, m_lpActive);
m_ctlShare3.SetTopOffset(3);
m_ctlShare3.SetRange(0, 100);
m_ctlShare3.SetLineSize(0);
m_ctlShare3.SetPos(80);
}
void CCoolSliderDlg::BuildVerticalSlider()
{
m_ctlVert1.SetFlipCursor(m_hHandCur);
m_ctlVert1.BuildThumbItem(IDB_VERTICAL_THUMB, 12, 6);
m_ctlVert1.BuildBackItem(IDB_VERTICAL_NORMAL, IDB_VERTICAL_ACTIVE);
m_ctlVert1.SetLeftOffset(0);
m_ctlVert1.SetRange(0, 100);
m_ctlVert1.SetLineSize(0);
m_ctlVert1.SetPos(50);
m_ctlVert2.SetFlipCursor(m_hHandCur);
m_ctlVert2.BuildThumbItem(IDB_VERTICAL_THUMB, 12, 6);
m_ctlVert2.BuildBackItem(IDB_VERTICAL_NORMAL, IDB_VERTICAL_NORMAL);
m_ctlVert2.SetLeftOffset(3);
m_ctlVert2.SetRange(0, 100);
m_ctlVert2.SetLineSize(0);
m_ctlVert2.SetPos(5
没有合适的资源?快使用搜索试试~ 我知道了~
VC++_Slider自绘滑块控件
共31个文件
h:7个
bmp:6个
cpp:6个
5星 · 超过95%的资源 需积分: 50 145 下载量 182 浏览量
2012-12-03
23:05:13
上传
评论 3
收藏 52KB RAR 举报
温馨提示
Slider自绘滑块. VC++代码。 可直接代替VC提供的Slider
资源推荐
资源详情
资源评论
收起资源包目录
VC++_Slider自绘滑块控件.rar (31个子文件)
www.NewXing.com
StdAfx.h 1KB
res
Thumb.bmp 1KB
BarBackVer.bmp 3KB
BarBack.bmp 3KB
ThumbVer.bmp 1KB
BarActive.bmp 3KB
CoolSlider.rc2 402B
CoolSlider.ico 1KB
BarActiveVer.bmp 3KB
Thumbs.db 11KB
CoolSlider.opt 55KB
CoolSlider.cpp 2KB
CoolSlider.dsw 543B
CoolSliderDlg.cpp 8KB
CoolSlider.h 1KB
CoolSlider.ncb 129KB
CoolSlider.rc 7KB
UI
BitSlider.cpp 5KB
BitItem.h 3KB
BitWnd.h 2KB
BitSlider.h 2KB
BitItem.cpp 7KB
BitWnd.cpp 4KB
resource.h 1KB
CoolSlider.aps 51KB
CoolSliderDlg.h 2KB
CoolSlider.gif 7KB
CoolSlider.plg 2KB
StdAfx.cpp 212B
CoolSlider.clw 2KB
CoolSlider.dsp 5KB
共 31 条
- 1
baiqiang111
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页