Why屏幕颜色拾取源代码.rar

  • why1732
    了解作者
  • Visual C++
    开发工具
  • 63KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 10
    下载次数
  • 2005-08-07 19:21
    上传日期
VC例程:该程序是由VC编写的有关颜色拾取器源代码(完整)
Why屏幕颜色拾取源代码.rar
  • res
  • ColorSnap.rc2
    401B
  • ColorSnap.ico
    1.1KB
  • ButtonsWin3000.bmp
    17.8KB
  • StdAfx.h
    1KB
  • ColorSnap.plg
    1.8KB
  • ColorSnap.h
    1.5KB
  • www.pudn.com.txt
    218B
  • ColorSnapDlg.cpp
    7.2KB
  • WBButton.h
    4.2KB
  • AutoFont.h
    2.3KB
  • ColorSnapDlg.h
    1.7KB
  • ColorSnap.dsw
    541B
  • AutoFont.cpp
    7.4KB
  • ColorSnap.rc
    6.2KB
  • WBButton.cpp
    8.5KB
  • resource.h
    916B
  • ColorSnap.opt
    113KB
  • ColorSnap.cpp
    2.8KB
  • ColorSnap.aps
    38.9KB
  • ColorSnap.dsp
    4.3KB
  • StdAfx.cpp
    211B
  • ColorSnap.ncb
    65KB
  • ColorSnap.clw
    1.5KB
内容介绍
// WBButton.cpp : // //功能:位图按钮类,实现按钮的位图显示 //修改人:徐景周   //日期:2001年2月8日 // #include "stdafx.h" #include "ColorSnap.h" //在此加入当前对话框应用类的头文件 #include "WBButton.h" #include "AutoFont.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWBButton CWBButton::CWBButton() { m_TopHeight = 8; m_BottomHeight = 8; m_LeftWidth = 8; m_RightWidth = 17; m_State = notInited; m_pFnt = new CAutoFont("宋体"); // MS Sans Serif"); m_BkColor = RGB(255,0,255); m_RcId = 0; // Resource ID m_NumofPics = 0; } CWBButton::~CWBButton() { NormalBitmap.DeleteObject(); SelectBitmap.DeleteObject(); FocusBitmap.DeleteObject(); DisableBitmap.DeleteObject(); SAFE_DELETE(m_pFnt); } BEGIN_MESSAGE_MAP(CWBButton, CButton) //{{AFX_MSG_MAP(CWBButton) ON_WM_ERASEBKGND() //}}AFX_MSG_MAP END_MESSAGE_MAP() //在对按钮初始化时,自动为按钮属性添加自画属性(OWNERDRAW) void CWBButton::PreSubclassWindow() { SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW); } void CWBButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC xdc; xdc.Attach( lpDrawItemStruct->hDC ); CRect rc; GetClientRect(rc); CMemDC dc(&xdc,rc); UINT state = lpDrawItemStruct->itemState ; bool IsDisable = false; if (state & ODS_FOCUS) { DrawBitmap( &dc, focus ); if (state & ODS_SELECTED) { DrawBitmap( &dc, select ); rc.left += 5; } } else if (state & ODS_DISABLED) { IsDisable = true; DrawBitmap( &dc, disable ); }else{ DrawBitmap( &dc, normal ); } int imode = dc.SetBkMode(TRANSPARENT); CFont *pOldFnt = dc.SelectObject(m_pFnt); COLORREF oldColor; if(IsDisable) oldColor = dc.SetTextColor( GetSysColor(COLOR_GRAYTEXT) ); else oldColor = dc.SetTextColor( m_pFnt->GetFontColor() ); CString txt; GetWindowText(txt); dc.DrawText(txt,rc,DT_CENTER | DT_VCENTER | DT_SINGLELINE); dc.SetTextColor( oldColor ); dc.SelectObject(pOldFnt); dc.SetBkMode(imode ); } bool CWBButton::LoadBitmaps ( UINT id, int count , int TopHeight, int BottomHeight, int LeftWidth, int RightWidth ) { m_TopHeight = TopHeight; m_BottomHeight = BottomHeight; m_LeftWidth = LeftWidth; m_RightWidth = RightWidth; m_RcId = id; // Resource ID m_NumofPics = count; CBitmap bmp; if( !bmp.LoadBitmap(id) ) return false; if( !InitBitmap( bmp, NormalBitmap, 0, count ) ) return false; if( !InitBitmap( bmp, SelectBitmap, 1, count ) ) return false; if( !InitBitmap( bmp, DisableBitmap,2, count ) ) return false; if( !InitBitmap( bmp, FocusBitmap, 3, count ) ) return false; bmp.DeleteObject(); return true; } bool CWBButton::InitBitmap( CBitmap & src, CBitmap & dist, int index, int count ) { CDC * pDC = GetDC(); CDC memDC; memDC.CreateCompatibleDC(pDC); CDC srcDC; srcDC.CreateCompatibleDC(pDC); CBitmap* pOldBitmap1; pOldBitmap1 = srcDC.SelectObject(&src); BITMAP bmpinfo; src.GetBitmap(&bmpinfo); int bmpWidth = bmpinfo.bmWidth / count; int bmpHeight = bmpinfo.bmHeight; int orix = bmpWidth * index; CRect rc; GetClientRect(rc); CBitmap* pOldBitmap2; dist.DeleteObject(); dist.CreateCompatibleBitmap(pDC,rc.Width(),rc.Height()); pOldBitmap2 = memDC.SelectObject(&dist); // lefttop,leftbottom,righttop,rightbottom if( !memDC.BitBlt(0,0,m_LeftWidth, m_TopHeight, &srcDC,orix,0,SRCCOPY) ) return false; if( !memDC.BitBlt(0,rc.bottom - m_BottomHeight,m_LeftWidth, m_BottomHeight, &srcDC,orix,bmpHeight - m_BottomHeight,SRCCOPY) ) return false; if( !memDC.BitBlt(rc.right - m_RightWidth, 0 ,m_RightWidth, m_TopHeight, &srcDC,orix + bmpWidth - m_RightWidth,0,SRCCOPY) ) return false; if( !memDC.BitBlt(rc.right - m_RightWidth,rc.bottom - m_BottomHeight,m_RightWidth,m_BottomHeight, &srcDC,orix + bmpWidth - m_RightWidth,bmpHeight - m_BottomHeight,SRCCOPY) ) return false; // entireimage memDC.StretchBlt(m_LeftWidth, m_TopHeight, rc.Width() - ( m_LeftWidth + m_RightWidth ) , rc.Height() - ( m_TopHeight + m_BottomHeight) , &srcDC, orix + m_LeftWidth, m_TopHeight, bmpWidth - ( m_LeftWidth + m_RightWidth ) , bmpHeight - ( m_TopHeight + m_BottomHeight ) ,SRCCOPY); // topbar,bottombar( Stretch ) memDC.StretchBlt(m_LeftWidth,0, rc.Width() - (m_LeftWidth + m_RightWidth), m_TopHeight, &srcDC,orix + m_LeftWidth, 0, bmpWidth - ( m_LeftWidth + m_RightWidth) , m_TopHeight,SRCCOPY); memDC.StretchBlt(m_LeftWidth, rc.bottom - m_BottomHeight, rc.Width() - ( m_LeftWidth + m_RightWidth), m_BottomHeight, &srcDC,orix + m_LeftWidth,bmpHeight - m_BottomHeight,bmpWidth - ( m_LeftWidth + m_RightWidth) , m_BottomHeight,SRCCOPY ); // sidebar ( STretch? ) memDC.StretchBlt(0,m_TopHeight,m_LeftWidth,rc.bottom - m_TopHeight - m_BottomHeight , &srcDC, orix,m_TopHeight, m_LeftWidth, bmpHeight - ( m_TopHeight + m_BottomHeight ) ,SRCCOPY); memDC.StretchBlt(rc.right - m_RightWidth ,m_TopHeight,m_RightWidth,rc.bottom - m_TopHeight - m_BottomHeight , &srcDC, orix + bmpWidth - m_RightWidth,m_TopHeight, m_RightWidth, bmpHeight - m_TopHeight - m_BottomHeight ,SRCCOPY); srcDC.SelectObject(pOldBitmap1); memDC.SelectObject(pOldBitmap2); ReleaseDC(pDC); ReleaseDC(&srcDC); ReleaseDC(&memDC); m_State = FileLoaded; return true; } void CWBButton::DrawBitmap( CDC * pDC, int mode ) { if( m_State < FileLoaded ) return; CRect rc; GetClientRect(rc); COLORREF crOldBack = pDC->SetBkColor(RGB(255,255,255)); COLORREF crOldText = pDC->SetTextColor(RGB(0,0,0)); CDC dcImage, dcTrans; // Create two memory dcs for the image and the mask dcImage.CreateCompatibleDC(pDC); dcTrans.CreateCompatibleDC(pDC); // Select the image into the appropriate dc CBitmap* pOldBitmapImage; switch(mode) { case normal: pOldBitmapImage = dcImage.SelectObject(&NormalBitmap); break; case select: pOldBitmapImage = dcImage.SelectObject(&SelectBitmap); break; case focus: pOldBitmapImage = dcImage.SelectObject(&FocusBitmap); break; case disable: pOldBitmapImage = dcImage.SelectObject(&DisableBitmap); break; default: return; } // Create the mask bitmap CBitmap bitmapTrans; int nWidth = rc.Width(); int nHeight = rc.Height(); bitmapTrans.CreateBitmap(nWidth, nHeight, 1, 1, NULL); // Select the mask bitmap into the appropriate dc CBitmap* pOldBitmapTrans = dcTrans.SelectObject(&bitmapTrans); // Build mask based on transparent colour dcImage.SetBkColor(m_BkColor); dcTrans.BitBlt(0, 0, nWidth, nHeight, &dcImage, 0, 0, SRCCOPY); // Do the work - True Mask method - cool if not actual display pDC->BitBlt(0, 0, nWidth, nHeight, &dcImage, 0, 0, SRCINVERT); pDC->BitBlt(0, 0, nWidth, nHeight, &dcTrans, 0, 0, SRCAND); pDC->BitBlt(0, 0, nWidth, nHeight, &dcImage, 0, 0, SRCINVERT); // Restore settings dcImage.SelectObject(pOldBitmapImage); dcTrans.SelectObject(pOldBitmapTrans); pDC->SetBkColor(crOldBack); pDC->SetTextColor(crOldText); } BOOL CWBButton::OnEraseBkgnd(CDC*
评论
    相关推荐
    • 颜色拾取器
      一款很小巧的屏幕颜色拾取器,可用于HTML的颜色设置,VC++的颜色设置,很小,很好用
    • 颜色拾取器
      颜色拾取器可以取屏幕上任意坐标的颜色(rgb,html,hex)等,小而强大
    • 颜色拾取器
      颜色拾取器,WPF通过自定义样式实现了简单的颜色拾取功能
    • 颜色拾取器
      一款绿色小巧的屏幕颜色拾取工具,有点类似于Photoshop中的色板
    • 颜色拾取器C#
      啸天颜色拾取器C#源码,简单易用,获取的颜色值准确无误,可以非常方便的获取指定颜色的值,复制颜色值,请按住Ctrl+F键复制网页颜色。可设置本拾色器窗口是否显示为最顶层,取色的时候,只需移动鼠标在想取色的地方...
    • 颜色拾取器
      对控件进行自绘,绘制色度图进行颜色的选择,绘图技术涉及到GDI,MFC,以及双缓冲
    • 颜色拾取器
      颜色拾取器,无需安装,可以直接使用,前端用于获取色值
    • 颜色拾取器
      小巧的RGB颜色获取程序 debug文件夹中ColorSnap.exe 为执行程序 可直接运行 代码页附上 搬运而来 出处忘记了
    • 颜色拾取器
      颜色拾取器,值得拥有,美工,前端的颜色拾取利器。
    • 颜色拾取器
      这个小工具可以拾取颜色,便于网页开发,CSS定义样式