How to respond to mouse messages in the View class when MapX is used in VC

Source: Internet
Author: User

IfProgramSimilarly, the on_wm_lbuttondown () macro does not work. The program will never be executed in your onlbuttondown (uint nflags, cpoint point) function.

The method is as follows:
It mainly uses a set of message-related macros defined by MapX.
We assume that the name of the attempt class is:
Cdemoview
Here we want to add a message processing function that responds to mouse movement.

1. First, add the declare_eventsink_map () macro under declare_message_map () of the demoview. h file.
2. Add the following in the demoview. cpp file header:Code:
# Define idr_map 100
3. Add the following code to the demoview. cpp file:

1 Begin_eventsink_map (cdemoview, cview)
2 On_event (cdemoview, idc_map, dispid_mousemove, onmousemoveinmap, vts_i2 vts_i2 vts_xpos_pixels vts_ypos_pixels)
3 End_eventsink_map ()

4. Add the following code in the demoview. h file:Bool onmousemoveinmap (ShortButton,ShortShift, ole_xpos_pixels X, ole_ypos_pixels y );

5. Add the following code to the demoview. cpp file:
Bool cmapgeneratorview: onmousemoveinmap ( Short Button, Short Shift, ole_xpos_pixels X, ole_ypos_pixels y)
{
Float Screenx = ( Float ) X;
Float Screeny = ( Float ) Y;
Double MapX;
Double Mapy;

M_ctrlmapx.convertcoord ( & Screenx, & Screeny, & MapX, & Mapy, miscreentomap );
Cstring currentpos;
Currentpos. Format ( " Longitude: % F, latitude: % F " , MapX, mapy );
Return True;
}

In general, you can add the methods for responding to related events such as mouse clicks, and so on.

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.