没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|其它|编辑:郝浩|2005-09-16 11:09:00.000|阅读 1438 次
概述:
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
三、程序代码
///////////////////////////////////////////////////////
#if !defined(FLATCOMBOBOX_H_INCLUDED)
#define FLATCOMBOBOX_H_INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define FC_DRAWNORMAL 0x00000001
#define FC_DRAWRAISED 0x00000002
#define FC_DRAWPRESSD 0x00000004
// CFlatComboBox window
class CFlatComboBox : public CComboBox
{
// Construction
public:
CFlatComboBox();
// Attributes
public:
bool m_bLBtnDown;
COLORREF m_clrHilite;
COLORREF m_clrShadow;
COLORREF m_clrDkShad;
COLORREF m_clrButton;
// Operations
public:
void DrawCombo(DWORD dwStyle, COLORREF clrTopLeft, COLORREF clrBottomRight);
int Offset();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFlatComboBox)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CFlatComboBox();
// Generated message map functions
protected:
//{{AFX_MSG(CFlatComboBox)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // !defined(FLATCOMBOBOX_H_INCLUDED)
///////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FlatComboBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
///////////////////////////////// CFlatComboBox
CFlatComboBox::CFlatComboBox()
{
m_bLBtnDown = false;
}
CFlatComboBox::~CFlatComboBox()
{}
BEGIN_MESSAGE_MAP(CFlatComboBox, CComboBox)
//{{AFX_MSG_MAP(CFlatComboBox)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_TIMER()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////
CFlatComboBox message handlers
void CFlatComboBox::OnMouseMove(UINT nFlags, CPoint point)
{
SetTimer(1,10,NULL);
CComboBox::OnMouseMove(nFlags, point);
}
void CFlatComboBox::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bLBtnDown = true;
CComboBox::OnLButtonDown(nFlags, point);
}
void CFlatComboBox::OnLButtonUp(UINT nFlags, CPoint point)
{
m_bLBtnDown = false;
Invalidate();
CComboBox::OnLButtonUp(nFlags, point);
}
void CFlatComboBox::OnTimer(UINT nIDEvent)
{
POINT pt;
GetCursorPos(&pt);
CRect rcItem;
GetWindowRect(&rcItem);
static bool bPainted = false;
// OnLButtonDown, show pressed.
if (m_bLBtnDown==true) {
KillTimer (1);
if (bPainted == true) {
DrawCombo(FC_DRAWPRESSD, ::GetSysColor(COLOR_BTNSHADOW),::GetSysColor(COLOR_BTNHIGHLIGHT));
bPainted = false;
}
return;
}
// If mouse leaves, show flat.
if (!rcItem.PtInRect(pt)) {
KillTimer (1);
if (bPainted == true) {
DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
bPainted = false;
}
return;
}
// On mouse over, show raised.
else {
if (bPainted == true)
return;
else {
bPainted = true;
DrawCombo(FC_DRAWRAISED, ::GetSysColor(COLOR_BTNSHADOW),::GetSysColor(COLOR_BTNHIGHLIGHT));
}
}
CComboBox::OnTimer(nIDEvent);
}
void CFlatComboBox::OnPaint()
{
Default();
DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
}
void CFlatComboBox::DrawCombo(DWORD dwStyle, COLORREF clrTopLeft, COLORREF
clrBottomRight)
{
CRect rcItem;
GetClientRect(&rcItem);
CDC* pDC = GetDC();
// Cover up dark 3D shadow.
pDC->Draw3dRect(rcItem, clrTopLeft, clrBottomRight);
rcItem.DeflateRect(1,1);
if (!IsWindowEnabled()) {
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNHIGHLIGHT));
}
else {
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
}
// Cover up dark 3D shadow on drop arrow.
rcItem.DeflateRect(1,1);
rcItem.left = rcItem.right-Offset();
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
// Cover up normal 3D shadow on drop arrow.
rcItem.DeflateRect(1,1);
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
if (!IsWindowEnabled()) {
return;
}
switch (dwStyle)
{
case FC_DRAWNORMAL:
rcItem.top -= 1;
rcItem.bottom += 1;
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNHIGHLIGHT));
rcItem.left -= 1;
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNHIGHLIGHT));
break;
case FC_DRAWRAISED:
rcItem.top -= 1;
rcItem.bottom += 1;
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNSHADOW));
break;
case FC_DRAWPRESSD:
rcItem.top -= 1;
rcItem.bottom += 1;
rcItem.OffsetRect(1,1);
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNSHADOW),::GetSysColor(COLOR_BTNHIGHLIGHT));
break;
}
ReleaseDC(pDC);
}
int CFlatComboBox::Offset()
{
// Thanks to Todd Brannam for this suggestion...
return ::GetSystemMetrics(SM_CXHTHUMB);
}
/////////////////// MainToolBar.h: interface for the CMainToolBar class.
#if !defined(AFX_MAINTOOLBAR_H__76CF28F4_005F_11D7_8F58_00E04C0BECE6__INCLUDED_)
#define AFX_MAINTOOLBAR_H__76CF28F4_005F_11D7_8F58_00E04C0BECE6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "FlatComboBox.h"
class CMainToolBar : public CToolBar
{
public:
CMainToolBar();
virtual ~CMainToolBar();
public:
CFlatComboBox m_wndZoom;
};
#endif
////////////////////////////// MainToolBar.cpp: implementation of the
CMainToolBar class.
#include "stdafx.h"
#include "ToolBar.h"
#include "MainToolBar.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CMainToolBar::CMainToolBar()
{}
CMainToolBar::~CMainToolBar()
{}
//////////////////////////////////////////////////////////////////////////////////////////////
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |
CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY |
CBRS_SIZE_DYNAMIC) ||!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don’t want the
toolbar to be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
int index = 0;
RECT rect;
//找到指定的工具项
while(m_wndToolBar.GetItemID(index)!=ID_TOOL_ZOOM)index++;
//设置指定工具项的宽度并获取新的区域 80是宽度
m_wndToolBar.SetButtonInfo(index, ID_TOOL_ZOOM, TBBS_SEPARATOR, 80);
m_wndToolBar.GetItemRect(index, &rect);
//设置位置
rect.top+=2;
rect.bottom += 200;
// 创建并显示
if (!m_wndToolBar.m_wndZoom.Create(WS_CHILD|WS_VISIBLE |CBS_AUTOHSCROLL|CBS_DROPDOWNLIST
|
CBS_HASSTRINGS ,rect, &m_wndToolBar, ID_TOOL_ZOOM))
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
m_wndToolBar.m_wndZoom.ShowWindow(SW_SHOW);
//填充内容
m_wndToolBar.m_wndZoom.AddString("25%");
m_wndToolBar.m_wndZoom.AddString("50%");
m_wndToolBar.m_wndZoom.AddString("75%");
m_wndToolBar.m_wndZoom.AddString("100%");
m_wndToolBar.m_wndZoom.AddString("125%");
m_wndToolBar.m_wndZoom.AddString("150%");
m_wndToolBar.m_wndZoom.AddString("175%");
m_wndToolBar.m_wndZoom.AddString("200%");
m_wndToolBar.m_wndZoom.SetCurSel(3);
return 0;
}
void CMainFrame::OnSelectZoomed()
{
CString strContent;
m_wndToolBar.m_wndZoom.GetWindowText(strContent);
AfxMessageBox(strContent);
}
四、小结
为了实现OFFICE2000风格的工具条,本实例介了一种比较巧妙的方法,利用Visual
C++6.0已有的开发环境支持,在工具条中加入了平面组合框控件,并实现了组合框的消息响应,用户选择组合框中的某一项后,会弹出一个对话框,提示用户所选择的信息。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
面对“数字中国”建设和中国制造2025战略实施的机遇期,中车信息公司紧跟时代的步伐,以“集约化、专业化、标准化、精益化、一体化、平台化”为工作目标,大力推进信息服务、工业软件等核心产品及业务的发展。在慧都3D解决方案的实施下,清软英泰建成了多模型来源的综合轻量化显示平台、实现文件不失真的百倍压缩比、针对模型中的大模型文件,在展示平台上进行流畅展示,提升工作效率,优化了使用体验。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号