0
votes

I am trying to create a new frame window with toolbars inside a dll. I was able to create the frame and the toolbars but however the messages do not work properly in the CToolbar. Particularly the ON_UPDATE_COMMAND_UI messages are never called in the DLL. After some research I came to know that this is because PreTranslateMessage(MSG* pMsg) and OnIdle(LONG lCount)

need to be called. But my calling application is Delphi based and this cannot be done.

After research I came to know that this is best possible from an Extension dll. Since MFC extension dlls can only be called from an MFC application. I thought of the following solution.

Delphi calls an regular MFC dll The MFC dll calls the Extension dll.

But I have run into problems because of asserts in in MFC AfxGetResourceHandle() and AfxGetInstanceHandle().

But I am also aware that AFX_MANAGE_STATE(AfxGetStaticModuleState()); cannot be called from an extension dll.

Does anybody have a solution for this problem?

1
I doubt that will help. You need to change the message loop. Which is in the host exe.David Heffernan

1 Answers

0
votes

The ON_UPDATE_COMMAND_UI messages are created by the MFC message loop. You don't have one. You will have to build your own ON_UPDATE_COMMAND_UI translator or something equivalent. It all starts with this in your frame window message map:

    ON_WM_INITMENUPOPUP()

Your OnInitMenuPopup handler will be called when the user selects a menu, before the menu is displayed.