Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Help with LoadStateFromString
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help with LoadStateFromString

 Post Reply Post Reply
Author
Message
JoshV View Drop Down
Newbie
Newbie
Avatar

Joined: 09 January 2005
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote JoshV Quote  Post ReplyReply Direct Link To This Post Topic: Help with LoadStateFromString
    Posted: 09 January 2005 at 5:57pm

I have several dynamic toolbars with dropdown lists (xtpControlSplitButtonPopup) that change based upon the type of  'document' that a user has opened.  For example, I want to display 3 control buttons with 'A', 'B', and 'C' one time a user logs in and I want it to be 'D', 'E', and 'F' on the next login.

I'm fine loading these programically, but as soon as I use LoadStateFromString to try to restore the last position of each of the application's toolbars, I run into problems.  My dropdown lists no longer contain the values I programitacally load.  Instead they show the content of the lists as they were when I last called SaveStateToString. 

I can see where that might make sense, but when I try delete these list items and re-add them with the correct items, the control doesn't update on the screen.  If I had 'A', 'B', and 'C' showing the last time I called SaveStateToString and then run code such as:

-------------------

Public ToolbarAssignment As CommandBar
Public ToolbatAssignmentPopup As CommandBarPopup

-------------------


Set ToolbarAssignment = CommandBars1.Add("Assignment", xtpBarTop)
With ToolbarAssignment.Controls
       
   Set ToolBarAssignmentPopup = .Add(xtpControlSplitButtonPopup, 0, "Assignments")
   ToolBarAssignmentPopup.ID = ID_ASSIGNPOPUP

End With

CommandBars1.LoadStateFromString    &nbs p;

ToolBarAssignmentPopup.CommandBar.Controls.DeleteAll
ToolBarAssignmentPopup.CommandBar.Controls.Add(xtpControlBut ton, 100, 'D')
ToolBarAssignmentPopup.CommandBar.Controls.Add(xtpControlBut ton, 101, 'E')
ToolBarAssignmentPopup.CommandBar.Controls.Add(xtpControlBut ton, 102, 'F')

---------------------


After this, the control still shows 'A', 'B', and 'C'  When I access the ToolBarAssignmentPopup buttons through code, I correctly see 'D', 'E', and 'F'.  Do I need to do something to force the control to repaint or refresh?  Does my variable ToolBarAssignmentPopup no longer reference the same node in the commandbar after calling LoadStateFromString?

Thanks.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 10 January 2005 at 7:17am
First make sure that ToolBarAssignmentPopup  was added to the toolbar before the layout was saved.

Try:
       CommandBars.LoadStateFromString

       Set ToolBarAssignmentPopup = CommandBars.ActiveMenuBar.FindControl(xtpControlSplitButt onPopup, ID_ASSIGNPOPUP, ,TRUE)
        With ToolBarAssignmentPopup .CommandBar.Controls
            .Add xtpControlBut ton, 100, 'D'
            .Add xtpControlBut ton, 101, 'E'
            .Add xtpControlBut ton, 102, 'F'
         End With
   


Edited by SuperMario
Back to Top
JoshV View Drop Down
Newbie
Newbie
Avatar

Joined: 09 January 2005
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote JoshV Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2005 at 11:24am

When I call FindControl as outlined above, it sets ToolBarAssignmentPopup to Nothing.

If I just reference the object variable without setting it in the FindControl call, it is not Nothing (ie ToolbarAssignmentPopup is Nothing = False).  This object reference (ToolbarAssignmentPopup) allows me to call ToolbarAssignmentPopup.CommandBar.Control.DeleteAll etc, without generating an error, but they have no effect on the screen.

If I don't call LoadStateFromString in the code segment you gave above, the FindControl works without a problem and returns a reference to the control that I want.  That would be fine, except I need the toolbar positioning that I can only get from LoadStateFromString.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2005 at 1:14pm
In the saved layout do you have a popup with Id = ID_ASSIGNPOPUP?
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.156 seconds.