mfc仿照360设置界面

  • b9_453111
    了解作者
  • 45KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-04 06:57
    上传日期
VC++ 实现仿照360设置界面,这是一个Demo,还有抽屉控件类,有什么问题可以在评论下面提出。这个界面做得比较粗糙,只是使用说明了一个效果
mfc仿照360设置界面.zip
  • mfc仿照360设置界面
  • XScrollBarTest.exe
    80KB
  • GfxOutBarCtrl.h
    7.4KB
  • GfxOutBarCtrl.cpp
    45.5KB
内容介绍
// Copyright (c) Iuri Apollonio 1998 // Use & modify as you want & need, and leave those 3 lines. // http://www.codeguru.com // GfxOutBarCtrl.cpp : implementation file // #include "stdafx.h" #include "resource.h"//"OutWAts1.h" #include "GfxOutBarCtrl.h" #include "XScrollBarTestDlg.h" #define _ID_GFX_SMALLICON "小图标方式" #define _ID_GFX_LARGEICON "大图标方式" #define _ID_GFX_ADDAGROUP "添加组" #define _ID_GFX_FONTCOLOR "改变字体颜色" #define _ID_GFX_BACKCOLOR "改变背景颜色" #define _ID_GFX_REMOVEITEM "从该组中删除" #define _ID_GFX_RENAMEITEM "改名" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGfxOutBarCtrl IMPLEMENT_DYNCREATE(CGfxOutBarCtrl, CWnd) CGfxOutBarCtrl::CGfxOutBarCtrl() { m_pParentWnd = NULL; crBackGroundColor = RGB(240,240,240); //背景色 crPreColor = RGB(190,190,190); //鼠标滑过颜色 crSelColor = RGB(49,128,65); //鼠标选中颜色 crNomalColor = RGB(210,210,210); //正常显示颜色 crNomalTextColor = RGB(255,255,255); //正常文本色 crSelTextColor = RGB(0,0,0); //鼠标选中文本颜色 m_OldSelFolder = 0; //默认上一次左键选中为第一个父项 m_bIsPackUp = FALSE; //FALSE为展开子项、TRUE为收起子项 m_nBackBottom = 0; m_bIsLeave = FALSE; iItemHeight = 22; //子项高 iFolderHeight = 25; //父项高 iSelFolder = 1; iLastFolderHighlighted = 0; iLastSelectedFolder = -1; pLargeImageList = NULL; pSmallImageList = NULL; iFirstItem = 0; xSmallIconLabelOffset = 4; yLargeIconLabelOffset = 3; ySmallIconSpacing = 10; yLargeIconSpacing = 8; xLeftMargin = 0; yTopMargin = 0; bUpArrow = FALSE; bDownArrow = FALSE; rcUpArrow = CRect(0,0,0,0); rcDownArrow = CRect(0,0,0,0); bUpPressed = FALSE; bDownPressed = FALSE; bLooping = FALSE; iLastItemHighlighted = 0; bPressedHighlight = FALSE; iLastDragItemDraw = -1; lAnimationTickCount = 10; iLastSel = -1; iSelAnimCount = 0; iSelAnimTiming = 0; pBlackPen = new CPen(PS_SOLID, 3, RGB(0,255,0)); // hHandCursor = AfxGetApp()->LoadCursor(IDC_HANDCUR); // hDragCursor = AfxGetApp()->LoadCursor(IDC_DRAGGING); // hNoDragCursor = AfxGetApp()->LoadCursor(IDC_NODRAGGING); dwFlags = fDragItems|fEditGroups|fEditItems|fRemoveGroups|fRemoveItems|fAddGroups|fAnimation|fSelHighlight; } CGfxOutBarCtrl::~CGfxOutBarCtrl() { for (int t = 0; t < arFolder.GetSize(); t++) { if (arFolder.GetAt(t)) delete (CBarFolder*) arFolder.GetAt(t); } arFolder.RemoveAll(); delete pBlackPen; } BEGIN_MESSAGE_MAP(CGfxOutBarCtrl, CWnd) //{{AFX_MSG_MAP(CGfxOutBarCtrl) ON_WM_CREATE() ON_WM_TIMER() ON_WM_PAINT() ON_WM_ERASEBKGND() ON_WM_MOUSEMOVE() ON_WM_LBUTTONDOWN() ON_WM_SETCURSOR() ON_WM_SIZE() ON_WM_RBUTTONDOWN() //}}AFX_MSG_MAP ON_MESSAGE(WM_OUTBAR_NOTIFY, OnEndLabelEdit) ON_WM_MOUSELEAVE() ON_WM_LBUTTONDBLCLK() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGfxOutBarCtrl message handlers long CGfxOutBarCtrl::OnEndLabelEdit(WPARAM wParam, LPARAM lParam) { #if 0 if (wParam == NM_OB_ONGROUPENDEDIT) { CGfxGroupEdit * pEdit = (CGfxGroupEdit *) lParam; OUTBAR_INFO ob; ob.index = pEdit->iIndex; ob.cText = pEdit->text; if (GetOwner()->SendMessage(WM_OUTBAR_NOTIFY, NM_OB_ONGROUPENDEDIT, (LPARAM) &ob)) { SetFolderText(pEdit->iIndex, pEdit->text); CRect rc; GetFolderRect(pEdit->iIndex, rc); InvalidateRect(rc, false); } } if (wParam == NM_OB_ONLABELENDEDIT) { CGfxGroupEdit * pEdit = (CGfxGroupEdit *) lParam; OUTBAR_INFO ob; ob.index = pEdit->iIndex; ob.cText = pEdit->text; if (GetOwner()->SendMessage(WM_OUTBAR_NOTIFY, NM_OB_ONLABELENDEDIT, (LPARAM) &ob)) { SetItemText(pEdit->iIndex, pEdit->text); CRect rc; GetInsideRect(rc); InvalidateRect(rc, true); } } #endif return 0; } void CGfxOutBarCtrl::SetFolderText(const int index, const char * text) { ASSERT(index >= 0 && index < GetFolderCount()); CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(index); if (pbf->cName) { delete [] pbf->cName; pbf->cName = NULL; } pbf->cName = new char [lstrlen(text)+1]; lstrcpy(pbf->cName, text); } void CGfxOutBarCtrl::SetItemText(const int index, const char * text) { ASSERT(iSelFolder >= 0 && iSelFolder < GetFolderCount()); CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(iSelFolder); CBarItem * pi = (CBarItem *) pbf->arItems.GetAt(index); if (pi->cItem) { delete [] pi->cItem; pi->cItem = NULL; } pi->cItem = new char [lstrlen(text)+1]; lstrcpy(pi->cItem, text); } BOOL CGfxOutBarCtrl::Create(DWORD dwStyle, const RECT & rect, CWnd * pParentWnd, UINT nID, const DWORD dwFlag) { dwFlags = dwFlag; m_pParentWnd = pParentWnd; return CWnd::CreateEx(WS_EX_STATICEDGE, NULL, NULL, dwStyle|WS_CHILD, rect, pParentWnd, nID); //GFXOUTBARCTRL_CLASSNAME } bool CGfxOutBarCtrl::IsSmallIconView() const { return dwFlags&fSmallIcon; } void CGfxOutBarCtrl::SetSmallIconView(const bool bSet) { iFirstItem = 0; if (bSet) { if (!IsSmallIconView()) { dwFlags |= fSmallIcon; CRect rc; GetInsideRect(rc); InvalidateRect(rc, false); } } else { if (IsSmallIconView()) { dwFlags &= ~fSmallIcon; CRect rc; GetInsideRect(rc); InvalidateRect(rc, false); } } } DWORD CGfxOutBarCtrl::GetFlag() const { return dwFlags; } void CGfxOutBarCtrl::ModifyFlag(const DWORD & dwRemove, const DWORD & dwAdd, const UINT redraw) { if (dwRemove) dwFlags &= ~(dwRemove); if (dwAdd) dwFlags |= dwAdd; if (GetSafeHwnd()) { if (redraw != 0) SetWindowPos(0,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|redraw); else Invalidate(); } } int CGfxOutBarCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here return 0; } void CGfxOutBarCtrl::OnTimer(UINT nIDEvent) { #if 0 if (nIDEvent == 1) { CPoint pt(GetMessagePos()); ScreenToClient(&pt); CRect rc; GetClientRect(&rc); if (!(rc.PtInRect(pt))) { // HighlightFolder(-1); // HighlightItem(-1); KillTimer(1); } } else if (nIDEvent == 3 && iLastSel >= 0) { iSelAnimCount ++; if (iSelAnimCount > 10) iSelAnimCount = -1; if (iSelAnimCount == 0) DrawAnimItem(-1, 1, iLastSel); if (iSelAnimCount == 1) DrawAnimItem(0, 0, iLastSel); if (iSelAnimCount == 2) DrawAnimItem(1, 1, iLastSel); if (iSelAnimCount == 3) DrawAnimItem(0, 0, iLastSel); } #endif CWnd::OnTimer(nIDEvent); } ////////////////////////////////////////////////////////////////////////// //该函数功能:定时画Item图片的动画效果。 void CGfxOutBarCtrl::DrawAnimItem(const int xoffset, const int yoffset, const int index) { CImageList * ima = GetFolderImageList(iSelFolder, IsSmallIconView()); CRect rc, irc; GetInsideRect(irc); GetItemRect(iSelFolder, iLastSel, rc); if (iLastSel >= iFirstItem && irc.bottom > rc.bottom && irc.top < rc.top) { ASSERT(iSelFolder >= 0 && iSelFolder < GetFolderCount()); CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(iSelFolder); ASSERT(index >= 0 && index < pbf->GetItemCount()); CBarItem * pi = (CBarItem *) pbf->arItems.GetAt(index); ASSERT(pi && ima); CClientDC dc(this); if (IsSmallIconView()) { if (ima) { IMAGEINFO ii; ima->GetImageInfo(pi->iImageIndex, &ii); CSize szImage = CRect(ii.rcImage).Size(); CPoint pt; pt.x = rc.left + 2; pt.y = rc.top + (rc.Height() - szImage.cy) / 2; CRect rcBck(pt.x-1, pt.y-1, pt.x + szImage.cx+2, pt.y + szImage.cy+2); dc.FillSolidRect(rcBck, crBackGroundColor); pt.x += xoffset;
评论
    相关推荐
    • MFC C++ Excel 导出 打印
      MFC C++ Excel 导出 打印
    • 数据采集客户端完整 MFC C++
      数据采集客户端完整 MFC C++ 原创 数据采集客户端完整 MFC C++ 原创 数据采集客户端完整 MFC C++ 原创 数据采集客户端完整 MFC C++ 原创 数据采集客户端完整 MFC C++ 原创 数据采集客户端完整 MFC C++ 原创 数据采集...
    • PAINT画图 MFC C++
      MFC画图,该程序基于MFC,用VC6.0制作,很好的实现了记事本的相关功能
    • mfc c++ 20130905
      mfc c++ 20130905
    • mfc c++--计算器
      1.MFC编写计算器代码 C++环境下运行 通过vc2005测设无错误 2.程序实现数字计算的功能,可实现开根号(sqrt)数等基本运算 3.界面良好
    • Learn the MFC C++ Classes
      Learn the MFC C++ Classes Learn the MFC C++ Classes
    • TreeListCode MFC C++ 源码
      TreeListCode MFC C++ 源码
    • MFC C++通信录
      MFC c++ 通信录 带界面
    • mfc c++总结
      从中可以学习到mfc基础知识以及c++基本知识点及相关重要的知识点
    • MFC C++串口通信
      MFC C++ 串口通信源代码,其中原代码中有对应的函数介绍