Im trying to make popup menu, i recv msg WM_RBUTTONDOWN in PreTranslatedMessage() then create that popup but when open new Dialog with DoModal() or Create() it crash it crash when Cancel it.. when destroy it...
BOOL CMFCTestDlg::PreTranslateMessage(MSG * pMsg) { switch(pMsg->message) { case WM_RBUTTONDOWN: { POINT p; GetCursorPos(&p); HMENU hMenu = ::CreatePopupMenu(); if (NULL != hMenu) { // add a few test items ::AppendMenu(hMenu, MF_STRING, 1, "Start Sniff"); int sel = ::TrackPopupMenuEx(hMenu, TPM_CENTERALIGN | TPM_RETURNCMD, p.x, p.y, m_hWnd, NULL); ::DestroyMenu(hMenu); if(sel == 1) { // //CSniff.DoModal(); // OR //CSniff.Create(IDD_SNIF); //CSniff.ShowWindow(1); } } } } return 0;//CDialog::PreTranslateMessage(pMsg); }
So when im destroyng that dialog when is opened with popup it crash program... any help please
Edited by t3ch, 11 July 2005 - 06:19 AM.