Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
IEButton.cpp
Package: VC界面编程高级应用技术.rar [view]
Upload User: szcysw
Upload Date: 2013-03-11
Package Size: 6752k
Code Size: 2k
Category:
GUI Develop
Development Platform:
Visual C++
- // IEButton.cpp : implementation file
- //
- #include "stdafx.h"
- #include "IEButtonDemo.h"
- #include "IEButton.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CIEButton
- CIEButton::CIEButton()
- {
- //初始化按钮状态:鼠标未移入按钮
- IsMouseOn=FALSE;
- }
- CIEButton::~CIEButton()
- {
- }
- BEGIN_MESSAGE_MAP(CIEButton, CButton)
- //{{AFX_MSG_MAP(CIEButton)
- ON_WM_MOUSEMOVE()
- ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CIEButton message handlers
- void CIEButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
- // TODO: Add your code to draw the specified item
- CDC ButtonDC;
- CBitmap bitmapTrans;
- BITMAP bmp;
- CDC mem;
- CRect rc,rc2;
- //得到用于绘制按钮的DC
- ButtonDC.Attach( lpDrawItemStruct->hDC );
- //准备用于向按钮区域传输位图
- mem.CreateCompatibleDC(&ButtonDC);
- //获取按钮所占的矩形大小
- rc=lpDrawItemStruct->rcItem;
- rc2=rc;
- //在任何状态下,图片是首先要绘绘制的
- bitmapTrans.LoadBitmap(IDB_IE);
- bitmapTrans.GetBitmap(&bmp);
- CBitmap *old=mem.SelectObject(&bitmapTrans);
- int x,y;
- x=rc.Width()/2-bmp.bmWidth/2;
- y=rc.Height()/2-bmp.bmHeight/2;
- //向按钮中心点传输位图
- ButtonDC.BitBlt(x,y,rc.right,rc.bottom,&mem, 0, 0, SRCCOPY);
- mem.SelectObject(old);
- //获取按钮目前所处的状态,根据不同的状态绘制不同的按钮
- //如果鼠标移入按钮,绘制浮起状态
- if (IsMouseOn )
- {
- //为按钮绘制立体效果
- rc.top=rc.top+1;rc.bottom=rc.bottom-1;
- rc.left=rc.left+1;rc.right=rc.right-1;
- //绘制立体边框
- ButtonDC.Draw3dRect(&rc,RGB(255,255,255),RGB(0,0,0));
- }
- //如果按钮被按下,绘制下沉立体效果
- if(lpDrawItemStruct->itemAction &ODA_SELECT)
- {
- rc2.top=rc2.top+1;rc2.bottom=rc2.bottom-1;
- rc2.left=rc2.left+1;rc2.right=rc2.right-1;
- //绘制立体边框
- ButtonDC.Draw3dRect(&rc2,RGB(0,0,0),RGB(255,255,255));
- }
- }
- void CIEButton::OnMouseMove(UINT nFlags, CPoint point)
- {
- //如果鼠标移入按钮
- if(!IsMouseOn)
- {
- this->IsMouseOn=TRUE;
- //重绘整个控件
- this->Invalidate();
- }
- CButton::OnMouseMove(nFlags, point);
- }
- void CIEButton::OnClicked()
- {
- AfxMessageBox("测试信息");
- }