简体   繁体   中英

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?

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. 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 .

The answer that works:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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