Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to use CExtRibbonNode's pointer across functions ? Collapse All
Subject Author Date
himanshu joshi Dec 28, 2006 - 10:21 PM

HI


CExtRibbonNode * m_pRibbonNode = new CExtRibbonNode;
m_pRibbonNode is member of my RibbonClass derived from CExtRibbonBar.

When i create object of my class using "new" keyword constructor of that class is called and in that constructor i using the above statement to create m_pRibbonNode.

After that i use "Create" method to create ribbon bar.

Then i am calling some function of that class where m_pRibbonNode is used to insert tabpagecollection.

When i try to use m_pRibbonNode->InsertNode method of m_pRibbonNode ,inside some other function of that class it throws me runtime exception "access violation reading some address location .."

Why i am not able to use m_pRibbonNode insert method in that function but when i create m_pRibbonNode(CExtRibbonNode * m_pRibbonNode = new CExtRibbonNode) in that function where i am using it to insert a node it is working ?


Technical Support Dec 30, 2006 - 2:11 PM

What you are trying to do is to change the contents of the ribbon bar control dynamically (at run time) depending on some conditions, aren’t you? There should not be any problem with this but you should be careful. For example, if you want to insert a new tab/page/group/button then you should follow these simple rules:

1) Keep only one root ribbon node created at startup (in your ribbon bar’s constuctor).
2) Destroy this note only once at shutdown (in your ribbon bar’s destuctor).
3) Modify any subtree of this root node any time and apply the changes immediately by invoking CExtRibbonBar::SetButtons().

It is hardly possible to add more because we cannot see what you are doing. If the problem persists, please send us the project so we can help you.

himanshu joshi Jan 1, 2007 - 11:14 PM

Hi

Regarding the third point mentioned above if i modify any subtree of the ribbon node in "one function" and call SetButtons it will apply the changes .What will happen to these changes when i modify different subtree in some "different function" of my class and call SetButtons.

Another thing is i am creating the ribbon node at startup(constructor) and using it in different functions of my ribbon bar’s class ,i am getting the error.Could you elaborate on how the code should be written

Thanks in advance

Suhai Gyorgy Jan 2, 2007 - 3:33 AM

If m_pRibbonNode is a member variable of your CExtRibbonBar-derived class, in the constructor of your class you should call m_pRibbonNode = new CExtRibbonNode; instead of CExtRibbonNode * m_pRibbonNode = new CExtRibbonNode; . The latter code declares a new local variable inside of the constructor’s scope and will initialize this local variable instead of your member variable of the same name. This explains why your member variable is not initialized.