发新话题
打印

工具条添加弹出菜单视出现异常!

工具条添加弹出菜单视出现异常!

各位兄弟门,小弟遇到一点小小的麻烦,还望各位不吝赐教,在次谢过!

我想在点击工具条的时候弹出一个菜单,遇到了下面的问题。::以下视点击工具条第一个按钮的响应函数

void CPlayListDlg::OnToolBarButton() //这个就是工具条上的第一个按钮
{
// TODO: Add your command handler code here
CRect rect;
GetDlgItem(ID_TOOLBAR_BUTTON)->GetWindowRect(&rect); //程序在此处出现异常!
              / /这个就是工具条上的第一个按钮的标识                            //程序在此处出现异常

CMenu menu;
menu.LoadMenu(IDR_TOOLBAR_MENU);
                            //想要弹出的菜单ID
CMenu *pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;

while (pWndPopupOwner->GetStyle() & WS_CHILD)
  pWndPopupOwner = pWndPopupOwner->GetParent();

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right, rect.bottom,
  pWndPopupOwner);
}



[email=jing-ge521@163.com]jing-ge521@163.com[/email]

TOP

使用这个声明一下试试
  RECT   rect;
换个头像,看见广告就眼红,直接封ID。

TOP

发新话题