使用类CGfxOutBarCtrl类,在响应消息点击消息的时候,
long CMainFrame::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case NM_OB_ITEMCLICK:
// cast the lParam to an integer to get the clicked item
{
int index = (int) lParam;
CString cs;
cs = m_OutBar.wndBar.GetItemText(index);
ReleaseCapture();//释放鼠标扑捉----------------!!!!!!!!!!!!
//执行弹出模式对话框后,CMyDialog dlg; dlg.DoModal();出现问题。
}
return 0;
case NM_OB_ONLABELENDEDIT:
// cast the lParam to an OUTBAR_INFO * struct; it will contain info about the edited item
// return 1 to do the change and 0 to cancel it
{
OUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;
TRACE2("Editing item %d, new text:%s/n", pOI->index, pOI->cText);
}
return 1;
case NM_OB_ONGROUPENDEDIT:
// cast the lParam to an OUTBAR_INFO * struct; it will contain info about the edited folder
// return 1 to do the change and 0 to cancel it
{
OUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;
TRACE2("Editing folder %d, new text:%s/n", pOI->index, pOI->cText);
}
return 1;
case NM_OB_DRAGITEM:
// cast the lParam to an OUTBAR_INFO * struct; it will contain info about the dragged items
// return 1 to do the change and 0 to cancel it
{
OUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;
TRACE2("Drag item %d at position %d/n", pOI->iDragFrom, pOI->iDragTo);
}
return 1;
}
return 0;
}
//以下是对这个问题的解释、
Trick: How to open a modal dialog from the OnOutbarNotify funtion
--------------------------------------------------------------------------------
Since may have written to me reporting trouble when trying to execute a modal dialog box from within the OnOutbarNotify function, here's the trick;
- add ReleaseCapture(); before opening your dialog
The trouble is related to how the bar control capture the mouse to get the hoover look; if the control has capture (as is always the case in this function), no modal will be correctly executed until you release the mouse capture, with the function above.