lundi 2 mars 2015

Button Control does not get/forward mouseDown/mouseUp/MouseMove messages

I have title-less MFC Dialog. So it does not move if you drag it and you need to take care movements yourself. I do this like this:



bool mbMousedown;
void MyDialog::OnLButtonDown(UINT nFlags, CPoint point)
{
mbMousedown = true;
CDialogEx::OnLButtonDown(nFlags, point);
}
void MyDialog::OnLButtonUp(UINT nFlags, CPoint point)
{
mbMousedown = false;
CDialogEx::OnLButtonUp(nFlags, point);
}

afx_msg LRESULT MyDialog::OnNcHitTest(CPoint point)
{
CRect r;
GetClientRect(&r);
ClientToScreen(&r);
if (r.PtInRect(point))
{
if (mbMousedown)
{
return HTCAPTION;
}
}
return CDialogEx::OnNcHitTest(point);
}


It works - when i drag the dialog it moves. But when i place button control on the dialog (yes i set notify to true) then the button control forward only click messages to the dialog but not mousedown/mouseup/mousemove. It just does not have these handlers in class wizard. So if user press the image inside the button control and drag the dialog like this then nothing happens since dialog did not get any messages from the button control.


I know i can solve this using activeX - i do not want to add activeX. I know i can derive from button box and do that - but really there is no easiest solution than that to get button to pass the notification or to make my dialog to move when user drag it with the picture control ? I have many button controls on the dialog ...


Aucun commentaire:

Enregistrer un commentaire