// CxShadeButton.cpp : implementation file
/** 12/05/2001 v1.00
* - ing.davide.pizzolato@libero.it
** 23/05/2001 v1.10
* - added text shift on button down
* - fixed many CxDib bugs
* - fixed SHS_HARDBUMP bug
* - added icon support
* - added text alignment
* - added flat style
** 16/06/2001 v1.20
* - fixed keyboard shortcut bug
* - check box & radio button add on by Rainer@Mangold.com
* - 2nd icon & 2nd tooltip add on by Rainer@Mangold.com
** 03/08/2001 v1.30
* - fixed SetIcon bug
* - added Font support
** 23/09/2001 v1.40
* - fixed memory leakage bug in DrawItem() (by David Scambler <dave@bmm.com.au>)
* - fixed memory leakage bug in SetIcon() (by Orioli Alessandro <aorioli@temaweb.it>)
* - fixed second tooltip initialization bug (by Jesper Kinn�s)
* - added multiline tooltip support (thanks to Derek Lakin)
* - fixed OnLButtonUp() problem with drag & drop. (by Hyeonsoo Jung <debussy2k@hanmail.net>)
** 28/10/2001 v1.41
* - fixed memory leakage bug in SetIcon() and in the destructor.
* - added 3rd icon for highlighted state.
*/
#include "stdafx.h"
#include "xShadeButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CxDib (under development)
/////////////////////////////////////////////////////////////////////
CxDib::CxDib()
{
hDib=NULL;
memset(&m_bi,0,sizeof(BITMAPINFOHEADER));
m_bi.biSize = sizeof(BITMAPINFOHEADER);
m_LineWidth=0;
m_nColors=0;
}
/////////////////////////////////////////////////////////////////////
CxDib::~CxDib()
{
if (hDib) free(hDib);
}
/////////////////////////////////////////////////////////////////////
bool CxDib::IsWin30Dib(){
return ((*(LPDWORD)(hDib))==sizeof(BITMAPINFOHEADER));
}
/////////////////////////////////////////////////////////////////////
WORD CxDib::GetPaletteSize()
{
// if (IsWin30Dib())
return (m_nColors * sizeof(RGBQUAD));
// else return (m_nColors * sizeof(RGBTRIPLE));
}
/////////////////////////////////////////////////////////////////////
BYTE* CxDib::GetBits()
{
if (hDib) return ((BYTE*)hDib + *(LPDWORD)hDib + GetPaletteSize());
return NULL;
}
/////////////////////////////////////////////////////////////////////
HDIB CxDib::Create(DWORD dwWidth, DWORD dwHeight, WORD wBitCount)
{
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
DWORD dwLen; // size of memory block
if (hDib) free(hDib);
hDib=NULL;
// Make sure bits per pixel is valid
if (wBitCount <= 1) wBitCount = 1;
else if (wBitCount <= 4) wBitCount = 4;
else if (wBitCount <= 8) wBitCount = 8;
else wBitCount = 24;
switch (wBitCount){
case 1:
m_nColors = 2;
break;
case 4:
m_nColors = 16;
break;
case 8:
m_nColors = 256;
break;
default:
m_nColors = 0;
}
m_LineWidth = WIDTHBYTES(wBitCount * dwWidth);
// initialize BITMAPINFOHEADER
m_bi.biSize = sizeof(BITMAPINFOHEADER);
m_bi.biWidth = dwWidth; // fill in width from parameter
m_bi.biHeight = dwHeight; // fill in height from parameter
m_bi.biPlanes = 1; // must be 1
m_bi.biBitCount = wBitCount; // from parameter
m_bi.biCompression = BI_RGB;
m_bi.biSizeImage = m_LineWidth * dwHeight;
m_bi.biXPelsPerMeter = 0;
m_bi.biYPelsPerMeter = 0;
m_bi.biClrUsed = 0;
m_bi.biClrImportant = 0;
// calculate size of memory block required to store the DIB. This
// block should be big enough to hold the BITMAPINFOHEADER, the color
// table, and the bits
dwLen = GetSize();
//hDib = malloc(dwLen); // alloc memory block to store our bitmap
hDib = new (HDIB[dwLen]); //fixes allocation problem under Win2k
if (!hDib) return NULL;
// use our bitmap info structure to fill in first part of
// our DIB with the BITMAPINFOHEADER
lpbi = (LPBITMAPINFOHEADER)(hDib);
*lpbi = m_bi;
return hDib; //return handle to the DIB
}
/////////////////////////////////////////////////////////////////////
long CxDib::Draw(HDC pDC, long xoffset, long yoffset)
{
if((hDib)&&(pDC)) {
//palette must be correctly filled
LPSTR lpDIB = (char*)hDib; //set image to hdc...
SetStretchBltMode(pDC,COLORONCOLOR);
SetDIBitsToDevice(pDC, xoffset, yoffset,
m_bi.biWidth, m_bi.biHeight, 0, 0, 0,
m_bi.biHeight, GetBits(),
(BITMAPINFO*)lpDIB, DIB_RGB_COLORS);
return 1;
}
return 0;
}
/////////////////////////////////////////////////////////////////////
long CxDib::Stretch(HDC pDC, long xoffset, long yoffset, long xsize, long ysize)
{
if((hDib)&&(pDC)) {
//palette must be correctly filled
LPSTR lpDIB = (char*)hDib; //set image to hdc...
SetStretchBltMode(pDC,COLORONCOLOR);
StretchDIBits(pDC, xoffset, yoffset,
xsize, ysize, 0, 0, m_bi.biWidth, m_bi.biHeight,
GetBits(),(BITMAPINFO*)lpDIB,DIB_RGB_COLORS,SRCCOPY);
return 1;
}
return 0;
}
/////////////////////////////////////////////////////////////////////
void CxDib::SetPaletteIndex(BYTE idx, BYTE r, BYTE g, BYTE b)
{
if ((hDib)&&(m_nColors)){
BYTE* iDst = (BYTE*)(hDib) + sizeof(BITMAPINFOHEADER);
if ((idx>=0)&&(idx<m_nColors)){
long ldx=idx*sizeof(RGBQUAD);
iDst[ldx++] = (BYTE) b;
iDst[ldx++] = (BYTE) g;
iDst[ldx++] = (BYTE) r;
iDst[ldx] = (BYTE) 0;
}
}
}
/////////////////////////////////////////////////////////////////////
void CxDib::SetPaletteIndex(BYTE idx, RGBQUAD c)
{
if ((hDib)&&(m_nColors)){
BYTE* iDst = (BYTE*)(hDib) + sizeof(BITMAPINFOHEADER);
if ((idx>=0)&&(idx<m_nColors)){
long ldx=idx*sizeof(RGBQUAD);
iDst[ldx++] = (BYTE) c.rgbBlue;
iDst[ldx++] = (BYTE) c.rgbGreen;
iDst[ldx++] = (BYTE) c.rgbRed;
iDst[ldx] = (BYTE) 0;
}
}
}
/////////////////////////////////////////////////////////////////////
void CxDib::SetPaletteIndex(BYTE idx, COLORREF cr)
{
if ((hDib)&&(m_nColors)){
BYTE* iDst = (BYTE*)(hDib) + sizeof(BITMAPINFOHEADER);
if ((idx>=0)&&(idx<m_nColors)){
long ldx=idx*sizeof(RGBQUAD);
iDst[ldx++] = (BYTE) GetBValue(cr);
iDst[ldx++] = (BYTE) GetGValue(cr);
iDst[ldx++] = (BYTE) GetRValue(cr);
iDst[ldx] = (BYTE) 0;
}
}
}
/////////////////////////////////////////////////////////////////////
RGBQUAD CxDib::GetPaletteIndex(BYTE idx)
{
RGBQUAD rgb = {0,0,0,0};
if ((hDib)&&(m_nColors)){
BYTE* iDst = (BYTE*)(hDib) + sizeof(BITMAPINFOHEADER);
if ((idx>=0)&&(idx<m_nColors)){
long ldx=idx*sizeof(RGBQUAD);
rgb.rgbBlue = iDst[ldx++];
rgb.rgbGreen=iDst[ldx++];
rgb.rgbRed =iDst[ldx];
rgb.rgbReserved = 0;
}
}
return rgb;
}
/////////////////////////////////////////////////////////////////////
BYTE CxDib::GetPixelIndex(long x,long y)
{
if ((hDib==NULL)||(m_nColors==0)||
(x<0)||(y<0)||(x>=m_bi.biWidth)||(y>=m_bi.biHeight)) return 0;
BYTE* iDst = GetBits();
return iDst[(m_bi.biHeight - y - 1)*m_LineWidth + x];
}
/////////////////////////////////////////////////////////////////////
RGBQUAD CxDib::GetPixelColor(long x,long y)
{
RGBQUAD rgb={0,0,0,0};
if ((hDib==NULL)||(x<0)||(y<0)||
(x>=m_bi.biWidth)||(y>=m_bi.biHeight)) return rgb;
if (m_nColors) return GetPaletteIndex(GetPixelIndex(x,y));
else {
BYTE* iDst = GetBits()+(m_bi.biHeight - y - 1)*m_LineWidth + x*sizeof(RGBQUAD);
rgb.rgbBlue = *iDst++;
rgb.rgbGreen= *iDst++;
rgb.rgbRed =*iDst;
return rgb;
}
}
/////////////////////////////////////////////////////////////////////
void CxDib::SetPixelIndex(long x,long y,BYTE i)
{
if ((hDib==NULL)||(m_nColors==0)||
(x<0)||(y<0)||(x>=m_bi.biWidth)||(y>=m_bi.biHeight)) return ;
BYTE* iDst = GetBits();
iDst[(m_bi.biHeight - y - 1)*m_LineWidth + x]=i;
}
/////////
没有合适的资源?快使用搜索试试~ 我知道了~
C++的开源的按钮皮肤
共89个文件
bmp:24个
h:11个
ico:11个
4星 · 超过85%的资源 需积分: 9 24 下载量 193 浏览量
2011-07-17
19:30:21
上传
评论
收藏 3.29MB RAR 举报
温馨提示
CxShadeButton_demo CxSkinButton_demo 偶然看到的一些资源,不错的说,使用简单,效果还不错
资源推荐
资源详情
资源评论
收起资源包目录
c++开源的一些项目.rar (89个子文件)
CxShadeButton_demo
CxShadeButtonDemo.cpp 2KB
xShadeButton.cpp 48KB
CxShadeButtonDemo.ncb 57KB
StdAfx.cpp 219B
resource.h 2KB
CxShadeButtonDemo.h 1KB
CxShadeButtonDemo.dsw 557B
Doc
CxShadeButton.htm 11KB
CxShadeButtonDemo.plg 268B
CxShadeButtonDemoDlg.h 2KB
CxShadeButtonDemo.opt 53KB
CxShadeButtonDemo.clw 2KB
Debug
CxShadeButtonDemoDlg.obj 40KB
CxShadeButtonDemo.pdb 337KB
vc60.pdb 356KB
vc60.idb 209KB
xShadeButton.obj 83KB
CxShadeButtonDemo.res 15KB
CxShadeButtonDemo.pch 6.56MB
xShadeButton.sbr 23KB
StdAfx.obj 103KB
CxShadeButtonDemo.exe 321KB
CxShadeButtonDemo.obj 19KB
CxShadeButtonDemo.sbr 8KB
CxShadeButtonDemo.ilk 289KB
StdAfx.sbr 1.31MB
CxShadeButtonDemoDlg.sbr 11KB
CxShadeButtonDemo.rc 7KB
StdAfx.h 1KB
CxShadeButtonDemoDlg.cpp 6KB
CxShadeButtonDemo.exe 221KB
CxShadeButtonDemo.dsp 5KB
res
radioon.ico 318B
32x32x256_Cancel.ico 2KB
icon5.ico 2KB
32x32x256_Ok.ico 2KB
checked.ico 318B
CxShadeButtonDemo.rc2 409B
icon4.ico 318B
Shade.ico 4KB
icon3.ico 318B
radiooff.ico 318B
unchecked.ico 318B
xShadeButton.h 6KB
CxSkinButton_demo
CxSkinButtonDemo.clw 2KB
CxSkinButtonDemo.cpp 2KB
CxSkinButtonDemo.ncb 49KB
StdAfx.cpp 218B
CxSkinButtonDemoDlg.cpp 5KB
resource.h 2KB
CxSkinButtonDemo.h 1KB
xSkinButton.h 3KB
CxSkinButtonDemo.dsw 646B
CxSkinButtonDemo.rc 7KB
CxSkinButtonDemo.exe 293KB
CxSkinButtonDemoDlg.h 2KB
CxSkinButtonDemo.dsp 6KB
Debug
StdAfx.h 1KB
CxSkinButtonDemo.opt 53KB
res
Image8.bmp 5KB
b1norm.bmp 5KB
Image10.bmp 5KB
eyegray.bmp 2KB
Image12.bmp 5KB
Image6.bmp 2KB
b1norm1.bmp 5KB
Image9.bmp 5KB
b1down.bmp 5KB
b1mask.bmp 2KB
eyemask.bmp 718B
eyeblue.bmp 2KB
Image11.bmp 5KB
eyeclosed.bmp 2KB
CxSkinButtonDemo2.ico 4KB
Image2.bmp 3KB
Image1.bmp 3KB
b1gray.bmp 5KB
Image3.bmp 2KB
eyered.bmp 2KB
eyegreen.bmp 2KB
Image4.bmp 5KB
CxSkinButtonDemo.rc2 408B
Image5.bmp 5KB
Image7.bmp 5KB
eyecl2.bmp 2KB
xStaticText.h 2KB
doc
CxSkinButton.htm 5KB
xStaticText.cpp 6KB
xSkinButton.cpp 25KB
共 89 条
- 1
资源评论
- str999_cn2012-01-19该程序新建了一个类ShadeButton,继承于CButton类,然后在子类里修改控件的外观属性。但是该类将15种按钮、2组radio按钮和2组check按钮的代码统统糅合在一起,初学者会很难辨认哪些代码是干什么的。此程序作于2001年,外国人写的,注释是英语,而且注释非常少,关键的地方都没有注释。不过作为参考,还是可以的。
- qinhualiuyue22014-03-07非常好用,谢谢你分享,我正要找它
nexuiz2
- 粉丝: 2
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功