![]() |
Find PopupControl |
Post Reply ![]() |
Author | ||
Paolo ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() Posted: 17 May 2007 at 11:15am |
|
I create a CXTPPopupToolBar instance and set it as TearOffPopup.
I create a CXTPControlPopup instance and set its CommandBar to be the CXTPPopupToolBar instance that was previously created. I create a CXTPControl instance (a CXTPControlButton instance) and add it to the CXTPPopupToolBar instance that was previously created.
When I click on this CXTPControlButton I want to get a pointer to its CXTPControlPopup instance parent to change Icon, Tooltip, Description, .. of the parent. How can I do this? I tried this way (commandId_ is correctly set to 3501):
But controlPopup_p is always NULL. Trying to follow events chain I found this: - method CXTPPopupBar::Popup is called and sets m_pControlPopup to the right pointer: "m_pControlPopup = pControlPopup;"; - CXTPPopupBar::SetTrackingMode is then called and it executes instruction "m_pControlPopup = 0;" - finally my method to handle button click is called. So when I handle click for my button (ID=3501) "parentPopupBar_p->GetControlPopup();" returns NULL. Is there another way to find Popup parent? Is there another way to keep Popup parent's icon, tooltip, description, ... syncronized to last clicked button? Thanks for any hint. Paolo |
||
![]() |
||
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
|
Hi,
Never use FindControl if your application supports customization - user can delete/copy control and your FindControl will return 0;
Here sample how it can work:
|
||
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
||
![]() |
||
Source ![]() Senior Member ![]() Joined: 19 June 2006 Status: Offline Points: 103 |
![]() ![]() ![]() ![]() ![]() |
|
Can you please send this example in vbasic ?
Regards. |
||
![]() |
||
Source ![]() Senior Member ![]() Joined: 19 June 2006 Status: Offline Points: 103 |
![]() ![]() ![]() ![]() ![]() |
|
My previous request is based on the following example:
Dim Control As CommandBarControl, ControlFile As CommandBarPopup Set ControlFile = cmdBarraPrincipal.ActiveMenuBar.Controls.Add(xtpControlPopup, ID_APP, ID_APP_DESC, -1, False) With ControlFile.CommandBar.Controls Set Control = .Add(xtpControlButton, ID_APP_ACESSO, ID_APP_ACESSO_DESC) Control.BeginGroup = True End With ID_APP = 100 in a const public declaration variable ID_APP = 101 in a const public declaration variable Using cmdBarraPrincipal.FindControl(, 100).Enabled = False I can change itīs state, but... for the popup control 101 (ID_APP_ACESSO) this does not work! Can you please help. Regards. Carlos Neves |
||
![]() |
||
Paolo ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() |
|
I looker into your sample, if I'm not wrong you're somewhat "hard-coding" a link between PopupControl button and its children.
Let me to explain: all children button set a boolean variable named "m_nOptionID" and parent PopupControl is updated by checking the value of m_nOptionID. By using your m_nOptionID variable I would be forced to create a variable for each set PopupControl-children and this is somewhat difficult to me as these toolbars are created from external source and I should create a non predefined number of variables and link all dynamically created buttons to their own variable. I think I'll solve this problem by using a STL::map to associate PopupControl and its children while dynamically creating them. 2) In your reply you said me "Never use FindControl if your application supports customization". My previous code was just part of my application, and some cheks may have been omitted to make code block shorter. If I do check control_p to be non NULL would it be correct to use FindControl? If not, which is the correct way to get a Control pointer given its ID? Thanks for help. Paolo |
||
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |