How to display the current mouse position in the status bar

Source: Internet
Author: User
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 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.