1. How to display the current mouse position in the status bar 1.1 Add a pane command ID
Switch to the resource view interface, right-click, select resource symbols, click New in the resource symbols dialog box, and enter a command ID, id_indicator_pos,
1.2 Add a string to the string table
The added string is to be displayed in the pane added in the previous step.
In the Add step, right-click string table-> New and select the ID of pane added in Step 1.1: id_indicator_page. Confirm to add.
1.3 add pane to the indicator array of statusbar.
This can be the case after adding
Static uint based_code indicators [] =
{
Id_separator, // status line indicator
Id_indicator_caps,
Id_indicator_num,
Id_indicator_scrl,
Id_indicator_pos, // added
};
After completing the above three steps, the pane in the status bar is added.
1.4 Add a processing function to update the mouse position to the status bar in real time
Add the following macro to the View class (or other classes) Message ing table:
(1) on_update_command_ui (id_indicator_pos, onupdatepos)
Add the onupdatepos () function to the View class;
(2) Statement
Afx_msg void onupdatepos (ccmdui * pcmui );
(3) Implementation
Void clearndisplaybmp view: onupdatepage (ccmdui * pcmdui)
{
Pcmdui-> enable ();
Pcmdui-> settext (currentpos );
}
Currentpos is a member variable of the cstring type defined in clearndisplaybmp view.
After the preceding three steps, the program automatically calls the onupdatepos function to change the display in the status bar as long as currentpos is changed in the view's mousemove event handler.
The implementation of the event processing function of mousemove is as follows:
Void clearndisplaybmp view: onmousemove (uint nflags, cpoint point)
{
Currentpos. Format ("X: % d, Y: % d", point. X, point. y );
Cformview: onmousemove (nflags, point );
}