Cstatic space mouse event response, and...

Source: Internet
Author: User

Yesterday, Avatar's avatar was displayed in the tool. After planning and adjusting the Avatar position, a world matrix was saved to the Avatar file. When avatar's avatar was displayed in the game, you only need to read the matrix of the world. Everything is ready. The experiment is successful. The message response originally in dialog is available. In order to improve the operation means, I decided to put the mouse event in cstatic to allow the planning to operate intuitively. Therefore, this requires two mouse events:



When the left mouse button is pressed and the mouse is moved, the view is moved.

Right-click and move the mouse to rotate avatar.


However, there are still many problems.


Happy to write the processing.CodeAnd the results cannot be matched.


There was a very important reason. You need to set policy for cstatic. You can change it in the resource interface or in the creation function. In this way, you can support on_mousemove messages. However, on_mousewheel still cannot respond.


It turns out that cstatic is just like its name. It is a static control, and the static control cannot obtain the input focus by default. For example, editctrl, you can enter text at a point, but static controls are different. Therefore, to enable it to support mousewheel messages, you need to enable it to get focus.

Simply put, in the response to the on_lbuttondown and on_rbuttondown events in cstatic, You can manually set the focus.

A control without focus does not respond to onmousewheel, so you need to get the focus.

Void cstatictest: onlbuttondown (uint nflags, cpoint point)
// Todo: add your message handler code here and/or call default
Setfocus ();
Cstatic: onlbuttondown (nflags, point );
Void cstatictest: onrbuttondown (uint nflags, cpoint point)
// Todo: add your message handler code here and/or call default
Setfocus ();
Cstatic: onrbuttondown (nflags, point );
Now you can:
Bool cstatictest: onmousewheel (uint nflags, short zdelta, cpoint pt)
// Todo: add your message handler code here and/or call default
Afxmessagebox ("Haha ");//
Return cstatic: onmousewheel (nflags, zdelta, pt );


In general, the control does not respond to messages. There may be only two reasons. One is external reasons. The message of the control is filtered by the parent control, and the other is its own reason. This control, in itself, it only does not support certain types of messages, or does it need to enable a certain switch to support it? For example, if the cstatic notify switch is used, and you need to obtain the focus to respond to situations such as mousewheel.

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.