Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Migration Problem from XTP8 to XTP12
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Migration Problem from XTP8 to XTP12

 Post Reply Post Reply
Author
Message
lion View Drop Down
Groupie
Groupie


Joined: 04 March 2008
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote lion Quote  Post ReplyReply Direct Link To This Post Topic: Migration Problem from XTP8 to XTP12
    Posted: 03 December 2008 at 4:28am
Hello,
shortly we were mirgating from xtp8 to xtp12. There were hardly any issues. But now I have discovered a problem with popupmenus. In the picture u can see what the menu looks like.



And this is what we used to do: when selecting a font with a style popupmenu (like in the screenshot) we fetched the index of the parent control to know which font was selected in the first place. Since we knew that a style (e.g. italic) was selected, but we did not know in which font. So knowing "italic" we got the parent's index and that way we knew what font was selected.
This way we get the FontFamilyID and the style that was selected from the popup.
Here is part of the code that is executed on popupmenu-selection:

void CMainFrm::OnToolbarCtrlExec(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
    NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;

    CXTPControl* pControl = tagNMCONTROL->pControl;
        //items of font submenu are handled here, because we need an index

            long id = pControl->GetIndex();

            CXTPPopupBar* pPopupBar = (CXTPPopupBar*)pControl->GetParent();

            CXTPControl* pParentControl = pPopupBar->GetControlPopup();
            long startIndex = pParentControl->GetControls()->FindControl(FONT_ITEMS_ID_START)->GetIndex();
            long familyId = pParentControl->GetIndex()-startIndex-1;

now this does not work anymore in xtp12.
The Problem is that "pParentControl" (as in the sourcecode above) is suddenly always NULL.
Is that a problem here or is that a problem with the code generating the popup to begin with?

Thanx very much for your help!
Cheers Björn
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 03 December 2008 at 12:05pm
Hello,
 
Yes it was changed in some 9-10.x version.
OnExecute event is called after Popup is already closed and "ControlPopup" already set to NULL :(
 
If you build this menu dynamically you can use Tag property to save parent information.
 
Or Create button class for these controls, override OnExecute method, etc.
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
lion View Drop Down
Groupie
Groupie


Joined: 04 March 2008
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote lion Quote  Post ReplyReply Direct Link To This Post Posted: 15 December 2008 at 4:20am
Thank you for your advice.
I tried it, but did not quite get to a solution.

I wanted to write the index of the font popup menu in the MENUINFO of the font version menuitem, in order to be able to retrieve it later again, to know which font was selected.

This is how the menu is created:

HMENU hMenu = CreateMenu(); // the fonts menu
HMENU hSubMenu; // the font versions menu
for (i = 1; i <= NumItems; i++)
    hSubMenu = CreatePopupMenu();
    for (j = 0; j < versionNum; j++) {
        AppendMenu(hSubMenu, MF_STRING, versionCounter++, versionLabels[j]);
    }
    AppendMenu(hMenu, MF_STRING|MF_POPUP, (UINT)hSubMenu, itemName);
}

I tried setting the MENUINFO on the hSubMenu but the values are not to be found when evaluating the "OnToolbarCtrlExec()" function.
how do I get access to this with the code mentioned above earlier?

Thanx in advance!
Cheers
Björn

PS:
is there a way to retrieve this original HMENU from the NMHDR* pNMHDR pointer inside "OnToolbarCtrlExec()" function ?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 16 December 2008 at 1:28am
Another option is to set
 
info.dwItemData with ::SetMenuItemInfo and then retieve it with pControl->GetTag();
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.157 seconds.