简体   繁体   English

C ++ winapi将鼠标单击子窗口传递到父窗口

[英]C++ winapi pass mouse clicks on child windows to parent window

I want to handle the clicks on child windows the same as clicks on parent window - how can I do that in winapi? 我想处理子窗口上的单击与处理父窗口上的单击相同-如何在winapi中做到这一点?

Currently, I can move the parent window by pressing anywhere on it but not on the child windows, because then it won't move. 目前,我可以通过在父窗口上按任何位置来移动父窗口,但不能在子窗口上按它,因为那样便不会移动。 How can I change that? 我该如何改变?

Capture the mouse click on the desired child controls(s), and then send a WM_SYSCOMMAND message with SC_DRAGMOVE (0xF012, aka SC_MOVE OR'ed with 2) as the wParam parameter to the parent window. 捕获鼠标单击所需的子控件,然后将带有SC_DRAGMOVE (0xF012,又名SC_MOVE或为2)作为wParam参数的WM_SYSCOMMAND消息发送到父窗口。 That will invoke a drag operation on the parent window. 这将在父窗口上调用拖动操作。

This is a widely known trick, and well documented online (just not by Microsoft) if you do a search for SC_DRAGMOVE . 这是一个广为人知的技巧,如果您搜索SC_DRAGMOVESC_DRAGMOVE在线上对其进行详细记录(并非Microsoft记录)。

The answer that works: 有效的答案:

case WM_NCHITTEST: 
        if (hWnd==parent)
        return HTCAPTION;
        else return HTTRANSPARENT;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM