Implementation of mouse buttons

xiaoxiao2021-03-06  39

To achieve the effects of this article, the key is to understand the message mechanism because the various actions completed by the program are determined by the received message, so by sending some special messages, they can indicate that the program completes the corresponding action.

Sometimes you need to simulate a variety of mouse buttons

:: SendMessage (this-> getsafehwnd (), wm_lbuttondown, 0, 0); // Simulation Press the left mouse button Press

:: SendMessage (this-> getsafehwnd (), wm_lbuttonup, 0, 0); // Simulation Punch Left button

:: SendMessage (this-> getsafehwnd (), wm_lbuttondblclk, 0, 0); // Simulation Press the left mouse button Double click

:: SendMessage (this-> getsafehwnd (), wm_rbuttonup, 0,0); // Simulation Punch Left mouse button

In the control, you can simulate the action of the mouse button, as long as the corresponding processing function is called, take the tree control as an example:

CTREELISTCTRL :: OnRButtondown (mk_rbutton, 0);

The above statement simulates behavior of right-click on the tree control. Modify the name of the response function to simulate the corresponding mouse action.

Understand the above, you can simply implement the following interesting operations, define a dialog box, bounce out, the automatic analog button's action turns off. The implementation method is as follows:

First of all of course, it is a custom a dialog and displays it, and the code is as follows.

Mydlg * dlg = new mydlg; // mydlg is a custom dialog class

DLG-> CREATE (IDD_MYDLG); // IDD_MYDLG is a custom dialog identifier

DLG-> ShowWindow (sw_shownormal); // Displays a non-modular dialog

Next, it is automatically turned off.

HWND HWND = :: FindWindow (NULL, "TEST"); // "TEST" is the title of the dialog, this statement gets the pair

// 话 框 手柄

IF (hwnd)

:: SendMessage (hwnd, wm_close, null, null); // Send a message that closes the current dialog

If you are interested, try it.

转载请注明原文地址:https://www.9cbs.com/read-70218.html

New Post(0)