|
of_save
|
|
Full name
|
pfc_n_cst_winsrv_preference.of_save
|
Access
|
protected
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_save(boolean,string,string)
|
Name
|
Datatype
|
lb_visible
|
boolean
|
li_barindexarray
|
integer[]
|
li_cnt
|
integer
|
li_height
|
integer
|
li_rc
|
integer
|
li_tbindex
|
integer
|
li_upperbound
|
integer
|
li_width
|
integer
|
li_x
|
integer
|
li_y
|
integer
|
lnv_conversion
|
n_cst_conversion
|
lnv_inifile
|
n_cst_inifile
|
lnv_menu
|
n_cst_menu
|
ls_tbindex
|
string
|
ls_title
|
string
|
ltb_alignment
|
toolbaralignment
|
protected function integer of_save (boolean ab_useregistry, string as_keyorini, string as_inisection);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Save
//
// Access: protected
//
// Arguments:
// ab_UseRegistry Function behavior. - use the registry or an .ini file.
// as_KeyOrIni The KeyName for use with the Registry or the IniFile name
// for use with an .Ini file.
// as_IniSection The name of the .Ini section.
//
// Returns: Integer
// 1 if it succeeds and -1 if an error occurs.
//
// Description: Saves the preference information to either the Registry or
// to an .INI file.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.02 Check for an associated menu prior to saving menu preferences.
// 5.0.02 Save menu items that have pictures only when requested.
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
string ls_tbindex
string ls_title
integer li_rc
integer li_barindexarray[]
integer li_upperbound
integer li_cnt=0
integer li_tbindex
integer li_x, li_y, li_width, li_height
boolean lb_visible
toolbaralignment ltb_alignment
n_cst_menu lnv_menu
n_cst_inifile lnv_inifile
n_cst_conversion lnv_conversion
//Check for a window association with this object.
If IsNull(iw_requestor) Or Not IsValid (iw_requestor) Then
Return -1
End If
//Check arguments
If IsNull(ab_UseRegistry) or IsNull(as_KeyOrIni) Then
Return -1
End If
//Validate specifics for either Registry or .Ini functionality.
If ab_UseRegistry Then
Else
//Check for the existance of the file.
If Not FileExists(as_KeyOrIni) Then
Return -1
End If
//Check the section parameter
If IsNull(as_IniSection) or Len(Trim(as_IniSection))=0 Then
Return -1
End If
End If
//Clear the section prior to updating it
If ab_UseRegistry Then
RegistryDelete (as_KeyOrIni, '')
Else
lnv_inifile.of_Delete(as_KeyOrIni, as_IniSection)
End If
//Save window size and position
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, 'window.windowstate', &
lnv_conversion.of_string(iw_requestor.WindowState))
//If the window is currently Maximized or Minimized then used the
//stored Position/Size values. If the window is currently Normal!
//then refresh the stored Position/Size values to ensure accurate data.
If iw_requestor.WindowState=Normal! Then of_SetPosSize()
//The X,Y,Width,&Height values are for the Normal State Window.
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
'window.x', string(ii_normalstate_x))
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
'window.y', string(ii_normalstate_y))
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
'window.width', string(ii_normalstate_width))
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
'window.height', string(ii_normalstate_height))
//Check for a Menu on the window
If Not IsValid(iw_requestor.MenuId) or IsNull(iw_requestor.MenuId) Then
//There is no menu associated on this window. Processing
//can end.
Return 1
End If
//Check for toolbars
If Not lnv_menu.of_ToolBarExists (iw_requestor.MenuId) Then
//Toolbars do not exist. Processing can end.
Return 1
End If
//Get handles to all the Toolbars
If lnv_menu.of_GetAllToolbarIndex (iw_requestor.MenuId, li_barindexarray) < 0 Then
//Fatal error
Return -1
End If
//Loop around all the toolbars
li_upperbound = UpperBound(li_barindexarray[])
For li_cnt = 1 to li_upperbound
li_tbindex = li_barindexarray[li_cnt]
ls_tbindex = 'toolbarindex'+string(li_tbindex)
//Get the GetToolbar information.
If iw_requestor.GetToolbar (li_tbindex,lb_visible,ltb_alignment,ls_title) = 1 Then
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.title', ls_title)
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.visible', lnv_conversion.of_string(lb_visible))
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.alignment', lnv_conversion.of_string(ltb_alignment))
End If
//Call the appropriate function for a Floating Toolbar.
If ltb_alignment = Floating! Then
If Not iw_requestor.GetToolbarPos &
(li_tbindex, li_x, li_y, li_width, li_height) = 1 Then Continue
Else
If Not iw_requestor.GetToolbarPos &
(li_tbindex, li_x, li_y) = 1 Then Continue
End If
//Save the Toolbar information.
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.x', string(li_x))
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.y', string(li_y))
If ltb_alignment = Floating! Then
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.width', string(li_width))
li_rc = of_Save (ab_UseRegistry, as_KeyOrIni, as_IniSection, &
ls_tbindex+'.height', string(li_height))
End If
Next
//When requested, save menu items that have pictures.
If ib_menuitems Then
If of_SaveMenu (ab_UseRegistry, as_KeyOrIni, as_IniSection, iw_requestor.MenuId) < 0 Then
Return -1
End If
End If
//Success return value
Return 1
end function