CTreeCtrl Popup Menu Selection Dialog Box Intermittantly Freezes
Hi:
I have a dialog-based C++ .NET application that has a class based on
CTreeCtrl. The "OnRButtonDown()" method of this class has code that
brings up a popup menu that allows the user to select any of 5 choices
(when they right click a tree item whose ItemData value is 29 in this
example) with the following code:
hTItem = HitTest( point, &nFlags );
DWORD iData = GetItemData( hTItem );
HMENU hMenu=::CreatePopupMenu();
if (NULL!=hMenu)
{
if ( iData==29 )
{
::AppendMenu(hMenu, MF_STRING, 1, "SEL 1");
::AppendMenu(hMenu, MF_STRING, 2, "SEL 2");
::AppendMenu(hMenu, MF_STRING, 3, "SEL 3");
::AppendMenu(hMenu, MF_STRING, 4, "SEL 4");
::AppendMenu(hMenu, MF_STRING, 5, "SEL 5");
::AppendMenu(hMenu, MF_STRING, 6, "Exit");
point.y = 16*(point.y/16);
ClientToScreen(&point);
int sel=0;
sel=::TrackPopupMenu( hMenu, TPM_CENTERALIGN|TPM_RETURNCMD,
point.x, point.y-57,
0, m_hWnd, NULL);
if ( sel<6 )
{
::PostMessage(m_hPWnd, P_MESSAGE, (WPARAM) 29, (LPARAM) sel );
}
}
}
When any of the selections SEL 1 to SEL 5 are chosen, a message is
sent to the main program where the message handler causes a dialog box
to be generated that depends on the selection that was made with code
that is similar to the following:
if ( wParam==29 )
{
sdDlg.selType = lParam;
sdDlg.DoModal();
}
The problem I'm having is that when "SEL 4" is selected the dialog box
that is brought up, sdDlg, intermittantly freezes the program (about
half the time) and I need to bring up the task manager and choose "End
Task" to stop it.
This doesn't happen on any of the other selections and I've tried to
bring up different dialog boxes on "SEL 4", but they freeze also.
I've run out of ideas on how to troubleshoot this problem.
Can anyone tell me what to do to figure out how to solve this?
Thanks,
Brad McMillan