vendredi 27 février 2015

MFC Picture 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 picture control on the dialog (yes i set notify to true) then the picture 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 picture control and drag the dialog like this then nothing happens since dialog did not get any messages from the picture control.


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


Aucun commentaire:

Enregistrer un commentaire