Print Page | Close Window

Migration Problem from XTP8 to XTP12

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=12846
Printed Date: 23 June 2025 at 11:52am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Migration Problem from XTP8 to XTP12
Posted By: lion
Subject: Migration Problem from XTP8 to XTP12
Date 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



Replies:
Posted By: Oleg
Date 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


Posted By: lion
Date 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 ?


Posted By: Oleg
Date 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



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