Reputation: 495
I want to add a toolbar at the bottom that will show my mouse position.
How can I add a read-only that will be constantly updated when I move my mouse?
All I did is make a toolbar and it has a button instead of a read-only style.
Upvotes: 0
Views: 363
Reputation: 1939
I would add, you should not push your info to the status bar. Let the main message pump deal with it on idle. In your child/main derived frame add a UI handler. Let it pull the information from the view.
ON_UPDATE_COMMAND_UI( ID_STATUSBAR_LABEL, &OnUpdateStatusText )
...
void CADFrame::OnUpdateStatusText( CCmdUI *pCmdUI )
{
pCmdUI->Enable( );
CADView* pView= dynamic_cast< CADView* >( GetActiveView( ) );
ASSERT_VALID( pView );
pCmdUI->SetText( pView->GetStatusInfo( ) );
...
}
As you are working with mouse positions you will have a last mouse position stored in the view for progressive calculations. So in you view something like, (it depends what you are up to):
const CString& CADView::GetStatusInfo( )
{
if( bStatusMouseChanged )
{
strStatus.Format( _T(" x: %.4f y: %.4f")
,(double)( ptLastMouse.x - offsetx ) / winScale
,(double)( ptLastMouse.y - offsety ) / winScale
);
bStatusMouseChanged= false;
}
return strStatus;
}
By keeping a flag you only build the string when you need to. From shameless promo of my project.
Upvotes: 0
Reputation: 589
You need a statusbar. see https://msdn.microsoft.com/en-us/library/fha3tfk7.aspx
Also look at here CStatusBar::SetPaneText(): https://msdn.microsoft.com/en-us/library/fha3tfk7.aspx#cstatusbar__setpanetext
Upvotes: 1