Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Crash on TrackPopupMenu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Crash on TrackPopupMenu

 Post Reply Post Reply
Author
Message
karim View Drop Down
Newbie
Newbie
Avatar

Joined: 09 January 2006
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote karim Quote  Post ReplyReply Direct Link To This Post Topic: Crash on TrackPopupMenu
    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
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2006 at 3:07pm
Yes, you have to switch state in your dll.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
karim View Drop Down
Newbie
Newbie
Avatar

Joined: 09 January 2006
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote karim Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.