具体的实现见资源中心的CAD.rar
方法一:
(1)在String Table中添加New String,在此定义为IDS_MOUSE_POINT,将其Caption设为0000,0000
(2)在MainFrm.cpp中indicators声明处添加IDS_MOUSE_POINT,代码如下:
…
static UINT indicators[] =
{
ID_SEPARATOR,
IDS_MOUSE_POINT,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
(3)在view里添加OnMouseMove函数及代码如下:
void CEOView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame* pFrame = (CMainFrame*) AfxGetMainWnd();
CStatusBar* pStatusBar = (CStatusBar*) pFrame->GetDescendantWindow(AFX_IDW_STATUS_BAR);
CString strMousePoint;
strMousePoint.Format("%4d,%4d", point.x, point.y);
pStatusBar->SetPaneText(pStatusBar->CommandToIndex(IDS_MOUSE_POINT), strMousePoint);
CView::OnMouseMove(nFlags, point);
方法2
1、view resource symbol 打开对话框
2、new 打开new symbol
3、在name的标识符中IDC_STATUSBAR VALUE 取默认值
4、在MainFrm.cpp中indicators声明处添加IDS_MOUSE_POINT,代码如下:
…
static UINT indicators[] =
{
ID_SEPARATOR,
ID_SEPARATOR,
ID_SEPARATOR,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
5、 设置状态条信息的宽度CMainFrame::OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::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
}
m_wndStatusBar.SetPaneInfo(1,IDC_STATUSBAR,SBPS_POPOUT,70);
m_wndStatusBar.SetPaneInfo(2,IDC_STATUSBAR,SBPS_POPOUT,70);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
6 添加处理函数
void CCADView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
char PositionString[50];
CMainFrame*MFrame=(CMainFrame*)AfxGetMainWnd(); //定义主框架指针
sprintf (PositionString,"X:%d",point.x);
MFrame->m_wndStatusBar.SetPaneText(1,PositionString);
sprintf (PositionString,"Y:%d",point.y);
MFrame->m_wndStatusBar.SetPaneText(2,PositionString);
阅读(672) | 评论(0) | 转发(0) |