When I open the menu to insert a table, I can hold down the mouse and drag over the table image of the menu to select how many cols/rows I want to insert. I wonder how can I make a menu that works similarly ? (dragging the mouse without losing the focus on the menu and do no create the effect of separating the whole item out of the menu itself)
If I understand what you're describing, and I'm not sure I do adequately, you're describing a custom control (one that may take the position of and function in the context of a menu).
Without knowing more about the exact nature of your design intent I might easily go on a tangent. However, the general topics that relate to your inquiry are SetCapture, ReleaseCapture (these control the focus of the mouse messages), various draw operations which may be on a client DC, and of course some state tracking to indicate when such a drag has begun, which ties into the mouse down/up messages.
With more specifics of your intent I can be of more help in reply.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).