// SpinnerTBView.cpp : implementation of the CSpinnerTBView class
#include "stdafx.h"
#include "SpinnerTB.h"
#include "SpinnerTBDoc.h"
#include "SpinnerTBView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSpinnerTBView
IMPLEMENT_DYNCREATE(CSpinnerTBView, CView)
BEGIN_MESSAGE_MAP(CSpinnerTBView, CView)
//{{AFX_MSG_MAP(CSpinnerTBView)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_ERASEBKGND()
ON_WM_QUERYNEWPALETTE()
ON_WM_PALETTECHANGED()
ON_COMMAND(ID_COLORS_RED, OnColorsRed)
ON_COMMAND(ID_COLORS_GREEN, OnColorsGreen)
ON_COMMAND(ID_COLORS_BLUE, OnColorsBlue)
ON_COMMAND(ID_COLORS_SPINNERS, OnColorsSpinners)
ON_EN_CHANGE(ID_EDIT_R, OnUpdateRed)
ON_EN_CHANGE(ID_EDIT_G, OnUpdateGreen)
ON_EN_CHANGE(ID_EDIT_B, OnUpdateBlue)
ON_EN_CHANGE(ID_EDIT_SLD, OnUpdateGradient)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSpinnerTBView construction/destruction
CSpinnerTBView::CSpinnerTBView()
{
// TODO: add construction code here
}
CSpinnerTBView::~CSpinnerTBView()
{
}
BOOL CSpinnerTBView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CSpinnerTBView drawing
void CSpinnerTBView::OnDraw(CDC* pDC)
{
CSpinnerTBDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
/////////////////////////////////////////////////////////////////////////////
// CSpinnerTBView printing
BOOL CSpinnerTBView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CSpinnerTBView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CSpinnerTBView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CSpinnerTBView diagnostics
#ifdef _DEBUG
void CSpinnerTBView::AssertValid() const
{
CView::AssertValid();
}
void CSpinnerTBView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CSpinnerTBDoc* CSpinnerTBView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSpinnerTBDoc)));
return (CSpinnerTBDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSpinnerTBView message handlers
void CSpinnerTBView::OnPaint()
{
CRect rect;
GetClientRect (&rect);
rect.OffsetRect (0, 60);
CPaintDC dc (this);
DoDrawText (&dc, &rect);
}
int CSpinnerTBView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CClientDC dc (this);
if (dc.GetDeviceCaps (RASTERCAPS) & RC_PALETTE) {
struct {
LOGPALETTE lp;
PALETTEENTRY ape[63];
} pal;
LOGPALETTE* pLP = (LOGPALETTE*) &pal;
pLP->palVersion = 0x300;
pLP->palNumEntries = 64;
for (int i=0; i<64; i++) {
pLP->palPalEntry[i].peRed = 0;
pLP->palPalEntry[i].peGreen = 0;
pLP->palPalEntry[i].peBlue = 255 - (i * 4);
pLP->palPalEntry[i].peFlags = 0;
}
m_palette.CreatePalette (pLP);
}
return 0;
}
BOOL CSpinnerTBView::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect (&rect);
CPalette* pOldPalette;
if ((HPALETTE) m_palette != NULL) {
pOldPalette = pDC->SelectPalette (&m_palette, FALSE);
pDC->RealizePalette ();
}
DoGradientFill (pDC, &rect);
if ((HPALETTE) m_palette != NULL)
pDC->SelectPalette (pOldPalette, FALSE);
return TRUE;
}
BOOL CSpinnerTBView::OnQueryNewPalette ()
{
if ((HPALETTE) m_palette == NULL) // Shouldn't happen, but
return 0; // let's be sure.
CClientDC dc (this);
CPalette* pOldPalette = dc.SelectPalette (&m_palette, FALSE);
UINT nCount;
if (nCount = dc.RealizePalette ())
Invalidate ();
dc.SelectPalette (pOldPalette, FALSE);
return nCount;
}
void CSpinnerTBView::OnPaletteChanged (CWnd* pFocusWnd)
{
if ((HPALETTE) m_palette == NULL) // Shouldn't happen, but
return; // let's be sure.
if (pFocusWnd != this) {
CClientDC dc (this);
CPalette* pOldPalette = dc.SelectPalette (&m_palette, FALSE);
if (dc.RealizePalette ())
Invalidate ();
dc.SelectPalette (pOldPalette, FALSE);
}
}
void CSpinnerTBView::DoGradientFill (CDC* pDC, LPRECT pRect)
{
CSpinnerTBDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush* pBrush[64];
for (int i=0; i<64; i++)
pBrush[i] = new CBrush (PALETTERGB (pDoc->m_nGradValue,
pDoc->m_nGradValue,
pDoc->m_nGradValue - (i * 4)));
int nWidth = pRect->right - pRect->left;
int nHeight = pRect->bottom - pRect->top;
CRect rect;
for (i=0; i<nHeight; i++) {
rect.SetRect (0, i, nWidth, i + 1);
pDC->FillRect (&rect, pBrush[(i * 63) / nHeight]);
}
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_GRADIENT, 0,
(LPARAM) (UINT) pDoc->m_nGradValue);
m_strRGB.Format("Gradient Value: %d ",pDoc->m_nGradValue);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_GRADIENT_STATUS, 0,
(LPARAM) (LPCTSTR) m_strRGB);
for (i=0; i<64; i++)
delete pBrush[i];
}
void CSpinnerTBView::DoDrawText (CDC* pDC, LPRECT pRect)
{
CSpinnerTBDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CFont font;
font.CreatePointFont (120,
_T ("Comic Sans MS"));
CFont* pOldFont = pDC->SelectObject (&font);
pDC->SetBkMode (TRANSPARENT);
pDC->SetTextColor(pDoc->m_clrTextClr);
pDC->DrawText (pDoc->m_strText, -1, pRect,
DT_CENTER | DT_VCENTER);
pDC->SelectObject (pOldFont);
m_strRGB.Format("Text: Red=%d, Green=%d, Blue=%d.", pDoc->m_nRed, pDoc->m_nGreen, pDoc->m_nBlue);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_COLOR, 0,
(LPARAM) (LPCTSTR) m_strRGB);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_SPINNER_RED, 0,
(LPARAM) (UINT) pDoc->m_nRed);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_SPINNER_GREEN, 0,
(LPARAM) (UINT) pDoc->m_nGreen);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_SPINNER_BLUE, 0,
(LPARAM) (UINT) pDoc->m_nBlue);
}
void CSpinnerTBView::OnColorsRed()
{
// Get a pointer to our Main Frame
// CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
// ASSERT_VALID(pFrame);
CSpinnerTBDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->m_nRed = 255;
pDoc->m_nGreen = 0;
pDoc->m_nBlue = 0;
pDoc->m_clrTextClr = RGB(pDoc->m_nRed, pDoc->m_nGreen, pDoc->m_nBlue);
pDoc->UpdateAllViews(0);
pDoc->SetModifiedFlag();
m_strRGB.Format("Text: Red=%d, Green=%d, Blue=%d.", pDoc->m_nRed, pDoc->m_nGreen, pDoc->m_nBlue);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_COLOR, 0,
(LPARAM) (LPCTSTR) m_strRGB);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_SPINNER_RED, 0,
(LPARAM) (UINT) pDoc->m_nRed);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_SPINNER_GREEN, 0,
(LPARAM) (UINT) pDoc->m_nGreen);
AfxGetMainWnd ()->SendMessage (WM_USER_UPDATE_SPINNER_BLUE, 0,
(LP
没有合适的资源?快使用搜索试试~ 我知道了~
Spin_Slide_ToolBar.rar_带Spin
共49个文件
h:9个
cpp:8个
obj:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 2 浏览量
2022-09-14
19:02:38
上传
评论
收藏 1.7MB RAR 举报
温馨提示
带微调和滑动条控件的工具栏,较精美,功能实用
资源推荐
资源详情
资源评论
收起资源包目录
Spin_Slide_ToolBar.rar (49个子文件)
Spin_Slide_ToolBar
SpinnerToolBar.h 2KB
SpinnerToolBar.cpp 7KB
SpinnerTB.dsp 5KB
SpinnerTB.dsw 543B
SpinnerTBView.h 2KB
SlideToolBar.h 2KB
RES
SpinnerTB.rc2 401B
SpinnerTB.ico 1KB
SpinnerTBDoc.ico 1KB
Toolbar.bmp 1KB
cursor_spinner.cur 326B
slider_bar.bmp 2KB
cursor_slider.cur 326B
spinner_bar.bmp 2KB
SpinnerTBView.cpp 13KB
SpinnerTB.h 1KB
ChildFrm.cpp 1KB
SpinnerTBDoc.h 2KB
SpinnerTB.plg 3KB
SpinnerTB.ncb 129KB
SlideToolBar.cpp 7KB
StdAfx.cpp 211B
MainFrm.cpp 6KB
SpinnerTB.aps 43KB
SpinnerTB.rc 16KB
MainFrm.h 2KB
RESOURCE.H 4KB
ChildFrm.h 1KB
StdAfx.h 1KB
SpinnerTB.dep 2KB
SpinnerTBDoc.cpp 2KB
Debug
SpinnerTB.exe 156KB
StdAfx.obj 12KB
SpinnerTB.ilk 429KB
SpinnerTB.pdb 401KB
SpinnerTB.res 16KB
SpinnerTB.obj 34KB
SpinnerTBView.obj 57KB
vc60.idb 209KB
SpinnerToolBar.obj 35KB
vc60.pdb 76KB
SpinnerTB.pch 4.86MB
MainFrm.obj 40KB
ChildFrm.obj 26KB
SpinnerTBDoc.obj 28KB
SlideToolBar.obj 34KB
SpinnerTB.opt 52KB
SpinnerTB.mak 6KB
SpinnerTB.cpp 4KB
共 49 条
- 1
资源评论
刘良运
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功