Do a Send Expression dialog box, similar to QQ, click on the expression button, pop-up expression box, mouse click on the outside of the expression box, the expression box was killed.
This is the window to get the mouse message outside the window.
Google Baidu, a lot of people say that using hooks to get the window outside of the click event, this is too much fuss about it.
Fortunately, a simple function was found:
setcapture (*this);
function function: This function sets mouse capture in the specified window belonging to the current thread. Once the window captures the mouse, all mouse input is directed at the window, regardless of whether the cursor is within the bounds of the window. Only one window can capture the mouse at a time. If the mouse cursor is on a window created by another thread, the system will only point the mouse input to the specified window when the mouse button is pressed.
So when creating a window, using this function allows the window to get a mouse click message outside the window:
int500;int800;SetWindowPos(*thisNULL, x_position_, y_position_, cx, cy, SWP_FRAMECHANGED);SetCapture(*this);
The next task is simply to get the mouse click position, using the GetCursorPos () function:
function function: The function checks the position of the cursor, expressed in screen coordinates.
Function prototype: BOOL GetCursorPos (Lppoint lppoint);
Parameters:
Ippoint:point The structure pointer that receives the screen coordinates of the cursor.
This allows you to make a judgment in the message queue of this window:
POINT click_point;GetCursorPos(&click_point);if500 > click_point.x && click_point.x > x_position_ 800 > click_point.y && click_point.y> y_position_) { MessageBox(NULL"表情", L"没有表情"NULL); }else { //delete 该窗口 }
No pit to hide--mouse messages outside the Capture window (hooks or??) )