• PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 62KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 242
    下载次数
  • 2005-09-21 08:01
    上传日期
在这个程序中当工具栏比较复杂,选项较多时隹隹需要一个平移按钮,且会弹出一个下拉的菜单
特色状态栏.rar
  • 特色状态栏
  • res
  • StatusBarDoc.ico
    1.1KB
  • Toolbar.bmp
    1.5KB
  • smile2.ico
    1.1KB
  • StatusBar.rc2
    401B
  • StatusBar.ico
    1.1KB
  • smile3.ico
    1.1KB
  • jmnco.ico
    766B
  • smile1.ico
    1.1KB
  • StdAfx.h
    499B
  • ActiveStatusBar.cpp
    1.5KB
  • StatusBar.rc
    13.1KB
  • StatusCombo.cpp
    2.8KB
  • StatusBar.cpp
    3.8KB
  • StatusBar.plg
    2.8KB
  • StatusBarDoc.h
    1KB
  • StatusBar.h
    955B
  • MainFrm.cpp
    7.5KB
  • StatusBarView.h
    1.4KB
  • StatusBar.mak
    10.8KB
  • StatusBar.exe
    136.1KB
  • StatusEdit.h
    875B
  • StatusBar.dsp
    5.6KB
  • MainFrm.h
    1.4KB
  • StatusBarView.cpp
    3.1KB
  • StatusBar.aps
    38KB
  • StatusEdit.cpp
    1.5KB
  • resource.h
    2KB
  • StatusBar.opt
    56.5KB
  • StatusBar.ncb
    89KB
  • StatusBarDoc.cpp
    1.8KB
  • StatusControl.h
    1KB
  • StatusControl.cpp
    4.9KB
  • StatusStatic.cpp
    1.5KB
  • StatusBar.dsw
    543B
  • ActiveStatusBar.h
    1.2KB
  • StatusProgress.cpp
    1.4KB
  • StatusProgress.h
    880B
  • StdAfx.cpp
    207B
  • StatusCombo.h
    1.6KB
  • StatusStatic.h
    860B
  • www.pudn.com.txt
    218B
内容介绍
// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include <afxcview.h rel='nofollow' onclick='return false;'> #include "StatusBar.h" #include "StatusBarDoc.h" #include "StatusBarView.h" #include "StatusControl.h" #include "StatusStatic.h" #include "StatusProgress.h" #include "StatusEdit.h" #include "StatusCombo.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_EN_CHANGE(ID_INDICATOR_EDIT, OnChangeEdit) ON_CBN_SELCHANGE(ID_INDICATOR_COMBO, OnSelchangeCombo) ON_COMMAND(ID_STATUS_COMBO, OnStatusCombo) ON_COMMAND(ID_STATUS_EDIT, OnStatusEdit) ON_COMMAND(ID_STATUS_ICON, OnStatusIcon) ON_COMMAND(ID_STATUS_PROGRESS, OnStatusProgress) ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_EDIT, ID_INDICATOR_PROGRESS, ID_INDICATOR_COMBO, ID_INDICATOR_ICON, ID_INDICATOR_CAPS, ID_INDICATOR_NUM, // ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.Create(this) || !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: Remove this if you don't want tool tips or a resizeable toolbar m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // 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); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CFrameWnd::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers void CMainFrame::OnStatusCombo() { if(c_StatusCombo.m_hWnd == NULL) { //第一次点击,创建 c_StatusCombo.Create(&m_wndStatusBar, ID_INDICATOR_COMBO, WS_VISIBLE | WS_BORDER | CBS_DROPDOWNLIST); logEvent(IDS_CREATE_COMBO); for(int i = IDS_FIRST_VALUE; i <= IDS_LAST_VALUE; i++) { //添加列表项 CString s; s.LoadString(i); c_StatusCombo.AddString(s); } } else { //第二次点击,销毁 c_StatusCombo.DestroyWindow(); logEvent(IDS_DESTROY_COMBO); } } void CMainFrame::OnStatusEdit() { if(c_StatusEdit.m_hWnd == NULL) { //第一次点击,创建 c_StatusEdit.Create(&m_wndStatusBar, ID_INDICATOR_EDIT, WS_VISIBLE | WS_BORDER); logEvent(IDS_CREATE_EDIT); } else { //第二次点击,销毁 c_StatusEdit.DestroyWindow(); logEvent(IDS_DESTROY_EDIT); } } void CMainFrame::OnStatusIcon() { static int icons[] = {IDI_SMILE1, IDI_SMILE2, IDI_SMILE3}; if(c_StatusIcon.m_hWnd == NULL) //第一次调用,创建Static控件,显示图片 { c_StatusIcon.Create(&m_wndStatusBar, ID_INDICATOR_ICON, WS_VISIBLE | SS_ICON | SS_CENTERIMAGE); //创建Static控件 HICON icon = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(icons[0]), IMAGE_ICON, 16, 16, LR_SHARED); //载入图标 c_StatusIcon.SetIcon(icon); //设置图标 logEvent(IDS_CREATE_STATIC); //显示当前状态 iconstate = 0; //计数器为0 CString s; s.Format(_T("%d"), icons[iconstate]); logEvent(IDS_SM_SETICON, s); } else { iconstate++; if(iconstate > 2) { //如果已经点击3次,销毁 c_StatusIcon.DestroyWindow(); logEvent(IDS_DESTROY_STATIC); } else { //换至其他的图标 CString s; HICON icon = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(icons[iconstate]), IMAGE_ICON, 16, 16, LR_SHARED); c_StatusIcon.SetIcon(icon); s.Format(_T("%d"), icons[iconstate]); logEvent(IDS_SM_SETICON, s); } } } void CMainFrame::OnStatusProgress() { if(c_StatusProgress.m_hWnd == NULL) { //第一次点击,创建 c_StatusProgress.Create(&m_wndStatusBar, ID_INDICATOR_PROGRESS, WS_VISIBLE | PBS_SMOOTH); c_StatusProgress.SetRange(0, 5); //设置进度条的范围 c_StatusProgress.SetPos(1); //设置进度条的位置 logEvent(IDS_CREATE_PROGRESS); logEvent(IDS_PBM_SETPOS, _T("1")); progress = 1; } else { progress++; if(progress > 5) { //如果点击大于5次,需要销毁 c_StatusProgress.DestroyWindow(); logEvent(IDS_DESTROY_PROGRESS); } else { //否则,进度条进度前进 c_StatusProgress.SetPos(progress); CString s; s.Format(_T("%d"), progress); logEvent(IDS_PBM_SETPOS, s); } } } void CMainFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); c_StatusProgress.Reposition(); c_StatusEdit.Reposition(); c_StatusIcon.Reposition(); c_StatusCombo.Reposition(); } /**************************************************************************** * CMainFrame::OnSelchangeCombo * Result: void * * Effect: * Handles selection change for combo box ****************************************************************************/ void CMainFrame::OnSelchangeCombo() { int n = c_StatusCombo.GetCurSel(); if(n == CB_ERR) return; CString s; c_StatusCombo.GetLBText(n, s); logEvent(IDS_CBN_SELCHANGE, s); } // CMainFrame::OnSelchangeCombo /**************************************************************************** * CMainFrame::OnChangeEdit * Result: void * * Effect: * Handles a change in the edit control ****************************************************************************/ void CMainFrame::OnChangeEdit() { CString s; c_StatusEdit.GetWindowText(s); logEvent(IDS_EN_CHANGE, s); } // CMainFrame::OnChangeEdit /**************************************************************************** * CMainFrame::logEvent * Inputs: * UINT id: ID to log * CString s: Text to log with it * Result: void * * Effect: * Logs the event ****************************************************************************/ void CMainFrame::logEvent(UINT id, CString s) { CStatusBarView * view = (CStatusBarView *)GetActiveView(); if(view == NULL) return; view->AddString(id, s); } // CMainFrame::logEvent
评论
    相关推荐