Print Page | Close Window

SaveSatateToXMLString...

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=10774
Printed Date: 07 October 2024 at 10:52pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SaveSatateToXMLString...
Posted By: suja
Subject: SaveSatateToXMLString...
Date Posted: 26 May 2008 at 12:14am
Hi~~
 
Help me
 
i want to set the State by using
SaveStateToXMLString/LoadStateFromXMLString..
 
when i clicked "Add or Remove Button" and  Saved the State ,
the Button State was not set ....
 
but When i used the RegistryKey, the Button State was Set..
 
is there diffrence from Using Xml and RegistryKey ??
 
 
 



Replies:
Posted By: Oleg
Date Posted: 26 May 2008 at 1:10am
Hello,
 
Check that you give same string to LoadStateFromXMLString that you get from Save. Maybe you save it wrong.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: joeliner
Date Posted: 26 May 2008 at 2:00am
Just a quick one oleg,

as earlier mentioned, we will have the ribbonbar designer in 12.1 (correct me if am wrong). will there be a feature of importing xml generated from ribbonbar to the designer?




Posted By: Oleg
Date Posted: 26 May 2008 at 9:51am
Yes.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: joeliner
Date Posted: 26 May 2008 at 9:59am
Splendid!


Posted By: suja
Date Posted: 27 May 2008 at 1:10am
would you check this method?
as i mentioned the Button State was not set ....
 
 
i want to save the state from each users. and Load that state...
 
 
 
 
'Load the State of CommandBar

Public Sub CommandBar_LoadState(ByVal argIDNumber As String, ByVal argEXEName As String)
   
On Error Resume Next
    Dim FreeF As Integer, sFile As String, sLayout As String
   
    strsql = "          SELECT String From DockingpaneState "
    strsql = strsql & "  WHERE UserID  = '" & Trim$(argIDNumber) & "' "
    strsql = strsql & "    AND EXEName = '" & UCase(argEXEName) & "' "
   
    If Not OpenADO1(strsql) Then Exit Sub
   
    sFile = "c:\" & Trim$(argIDNumber) & ".txt"
    FreeF = FreeFile
    Kill sFile
    Open sFile For Binary As #FreeF
    Put #FreeF, , Trim$(AdoRs1("String"))
    Close #FreeF
   
    AdoRs1.Close
   
    sLayout = Space(FileLen(sFile))
    Open sFile For Binary As #FreeF
    Get #FreeF, , sLayout
    Close #FreeF
    On Error GoTo 0
    CommandBars.LoadStateFromXMLString CommandBars.name, sLayout  ' sLayout, "a"
    Kill sFile
 
End Sub
 
 
 
'Save the State of CommandBar
Public Sub DockingPane_SaveState(ByVal argIDNumber As String, ByVal argEXEName As String)
Dim nCnt As Integer
   
    strsql = "SELECT count(*) as cnt From DockingpaneState "
    strsql = strsql & "  WHERE UserID  = '" & Trim$(argIDNumber) & "' "
    strsql = strsql & "    AND EXEName = '" & UCase(argEXEName) & "' "
   
    Call OpenADO1(strsql)
   
    nCnt = AdoRs1("Cnt")
    AdoRs1.Close
   
    If nCnt = 0 Then
        strsql = "Insert into DockingpaneState values ( "
        strsql = strsql & " '" & Trim$(UserID.IDNumber) & "', "
        strsql = strsql & " '" & UCase(argEXEName) & "', "
        'strsql = strsql & " '" & Trim$(NurseMDI.DockingPaneManager.SaveStateToString) & "') "
        strsql = strsql & " '" & Trim$(NurseMDI.CommandBars.SaveStateToXMLString(NurseMDI.CommandBars.name)) & "' "
    Else
        strsql = "          UPDATE DockingpaneState "
        'strsql = strsql & "    Set string  = '" & Trim$(NurseMDI.DockingPaneManager.SaveStateToString) & "' "
        'strsql = strsql & "    Set string  = '" & Trim$(NurseMDI.CommandBars.SaveStateToString(True, True)) & "' "
    strsql = strsql & "    Set string  = '" & Trim$(NurseMDI.CommandBars.SaveStateToXMLString(NurseMDI.CommandBars.name)) & "' "
        strsql = strsql & "  WHERE UserID = '" & Trim$(argIDNumber) & "' "
        strsql = strsql & "    AND EXEName = '" & UCase(argEXEName) & "' "
    End If
   
    AdoCn.BeginTrans
    If ExecADO(strsql) Then
        AdoCn.CommitTrans
    Else
        AdoCn.RollbackTrans
    End If
   
End Sub
 
 
 
 
 
[this is get from saved file]
 
<CommandBars CompactMode="1">
  <Layout>
    <DockState Version="21" ScreenSize="1280, 1024" Count="2">
      <BarInfo0 BarId="1" MRUWidth="32767"/>
      <BarInfo1 BarId="1694431857" Floating="1" MRUWidth="32767" PointPos="529, 238"
              MRUDockPos="545, 18, 1113, 44" MRUFloatPos="529, 238"/>
    </DockState>
    <DockBars>
      <DockBar0 Count="3" Id1="1"/>
    </DockBars>
  </Layout>
</CommandBars>
 


Posted By: Oleg
Date Posted: 27 May 2008 at 7:44am

Hi,

Right. by default SaveStateToXMLString don't save controls state.
 
Create Options and set SerializeControls  property:
 
    Dim op As StateOptions
    Set op = CommandBars.CreateStateOptions
    op.SaveOriginalControls = True
    op.SerializeControls = True


-------------
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