Print Page | Close Window

Crash on TrackPopupMenu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=4971
Printed Date: 11 November 2025 at 2:41am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Crash on TrackPopupMenu
Posted By: karim
Subject: Crash on TrackPopupMenu
Date Posted: 05 September 2006 at 12:59pm
I'm seeing a crash when I call the static version of CXTPCommandBars::TrackPopupMenu where the first parameter is the CMenu pointer.  This call is being made inside a DLL that dynamically links to MFC(and Codejock).   It's crashing in the function below and I believe the problem is AfxGetThread is returning NULL.  I think it's a manage state problem, but the message is originating from a control in the dll - the call isn't being made from the executable.

Thanks,
Karim


void CXTPPopupBar::PumpMessage()
{

    while (IsTrackingMode())
    {
        MSG msg;
        if (::GetMessage(&msg, NULL, NULL, NULL))
        {
            if (!IsTrackingMode())
            {
                ::PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
                break;
            }

            if (msg.message != WM_KICKIDLE && !AfxGetThread()->PreTranslateMessage(&msg))
            {
                // process this message
                ::TranslateMessage(&msg);
                ::DispatchMessage(&msg);
            }
        }
        else
            break;
    }
}





-------------
Karim Shehadeh
Verint Video Solutions
http://www.verint.com



Replies:
Posted By: Oleg
Date Posted: 05 September 2006 at 3:07pm
Yes, you have to switch state in your dll.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: karim
Date Posted: 05 September 2006 at 3:49pm
I'm sorry I wasn't clear about that.  Yeah, I am switching state but it makes no difference.  Specifically, I'm calling
AFX_MANAGE_STATE(AfxGetStaticModuleState());
at the top of the function.  And besides, since the menu resource is loading fine, that seems to indicate that the module state is correct at least to some extent. 

Can CXTPCommandBars::TrackPopupMenu be called anywhere or are there certain restrictions?  I don't know what they would be, but...

Thanks,
Karim




-------------
Karim Shehadeh
Verint Video Solutions
http://www.verint.com


Posted By: Oleg
Date Posted: 07 September 2006 at 2:01pm
Hello,
 
if AfxGetThread returns NULL it means that AfxGetApp will return NULL also. and this means something wrong with initialization/swiching MFC.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net