资源描述:
《为状态栏添加显示辅助信息功能》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、为状态栏添加像素位置,度量单位,图像大小以及图像位数四个信息一、在主框架中定义状态栏各个分栏位置。1、在CMainFrame.h中,添加:#definePANE_CURSOR_POSITION1#definePANE_LENGTH_UNIT2#definePANE_IMAGE_SIZE3#definePANE_BIT_COUNT42、在CMainFrame.cpp中,indicators数组处改为:staticUINTindicators[]={ID_SEPARATOR,//statuslineindicator//cursorpositionID_SEPARATOR,//lengt
2、hunitID_SEPARATOR,//imagesizeID_SEPARATOR,//bitcountID_SEPARATOR,ID_INDICATOR_CAPS,ID_INDICATOR_NUM,ID_INDICATOR_SCRL,};3、在OnCreate函数中,添加如下代码:intCMainFrame::OnCreate(LPCREATESTRUCTlpCreateStruct){…if(!m_wndStatusBar.Create(this)
3、
4、!m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeo
5、f(UINT))){TRACE0("Failedtocreatestatusbar");return-1;//failtocreate}//addpanesm_wndStatusBar.SetPaneInfo(PANE_CURSOR_POSITION,ID_SEPARATOR,SBPS_NORMAL,72);m_wndStatusBar.SetPaneInfo(PANE_LENGTH_UNIT,ID_SEPARATOR,SBPS_NORMAL,25);m_wndStatusBar.SetPaneInfo(PANE_IMAGE_SIZE,ID_SEPARATOR,SBPS_NORM
6、AL,72);m_wndStatusBar.SetPaneInfo(PANE_BIT_COUNT,ID_SEPARATOR,SBPS_NORMAL,28);}二、添加各状态栏分栏的控制函数1、在StringTable中,添加以下几个字串:2、在View类中,添加成员变量:intm_nLengthUnit,并在View类的构造函数中,添加初始化代码:m_nLengthUnit=MM_TEXT;3、在View类中,添加以下几个成员函数:voidSetStatusBarLengthUnit(intnUnit);voidSetStatusBarCursorPosition(CPointpoi
7、nt);voidSetStatusBarImageSize(CSizesize);voidSetLengthUnit(intnUnit);voidSetStatusBarBitCount(WORDwBitcount);4、分别为它们添加函数代码:voidCImageBoardView::SetStatusBarBitCount(WORDwBitcount){CStringstr;switch(wBitcount){case1:str.LoadString(IDS_BITCOUNT_1);break;case4:str.LoadString(IDS_BITCOUNT_4);break;
8、case8:str.LoadString(IDS_BITCOUNT_8);break;case24:default:str.LoadString(IDS_BITCOUNT_24);break;}CMainFrame*pMainFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd);ASSERT_KINDOF(CMainFrame,pMainFrame);pMainFrame->m_wndStatusBar.SetPaneText(PANE_BIT_COUNT,str);}voidCImageBoardView::SetStatusBarLengthU
9、nit(intnUnit){CStringstr;switch(m_nLengthUnit){caseMM_HIENGLISH:str.LoadString(IDS_LENGTH_UNIT_INCH);break;caseMM_HIMETRIC:str.LoadString(IDS_LENGTH_UNIT_MM);break;caseMM_TEXT:default:str.LoadString(IDS_LENGTH_UNIT_PIXEL);break;}C