Attribute VB_Name = "RegOptions" Option Explicit Private Const ModuleName = "RegOptions" Private Const P4FOROFFICE_KEY = "Software\Perforce\P4OFC" Private Const HELP_FILE_VALUE = "HelpFilePath" Private Const DIFF_VALUE = "HideDiffDialog" Private Const DISPLAY_CONFIRMATIONS_VALUE = "DisplayConfirmations" Private Const SUBMIT_CURRENT_DOC_ONLY_VALUE = "SubmitCurrentDocOnly" Private Const AUTO_LOCK_VALUE = "AutoLock" Private Const CHECKIN_AFTER_ADD_REMINDER_VALUE = "CheckInAfterAddReminder" Private Const CHECKOUT_ON_OPEN_VALUE = "CheckOutOnOpen" Private Const CHECKOUT_ON_REOPEN_VALUE = "CheckOutOnReopen" Private Const CHECKIN_ON_CLOSE_VALUE = "CheckInOnClose" Private Const DEBUG_TRACE_VALUE = "DebugTraceVB" Private Const SUPPORT_EMAIL_VALUE = "SupportEmailAddress" Public Enum OptionsValue Never = 0 Prompt = 1 Always = 2 End Enum Public Property Get HideDiffDialog() As Boolean Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get HideDiffDialog") HideDiffDialog = GetBooleanOption(DIFF_VALUE, False) End Property Public Property Let HideDiffDialog(NewValue As Boolean) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set HideDiffDialog") SetBooleanOption DIFF_VALUE, NewValue End Property Public Property Get DisplayConfirmations() As Boolean Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get DisplayConfirmations") DisplayConfirmations = GetBooleanOption(DISPLAY_CONFIRMATIONS_VALUE, True) End Property Public Property Let DisplayConfirmations(NewValue As Boolean) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set DisplayConfirmations") SetBooleanOption DISPLAY_CONFIRMATIONS_VALUE, NewValue End Property Public Property Get CheckOutOnOpen() As OptionsValue Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get CheckOutOnOpen") CheckOutOnOpen = GetOption(CHECKOUT_ON_OPEN_VALUE, Prompt) End Property Public Property Let CheckOutOnOpen(NewValue As OptionsValue) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set CheckOutOnOpen") SetOption CHECKOUT_ON_OPEN_VALUE, NewValue End Property Public Property Get CheckInOnClose() As OptionsValue Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get CheckInOnClose") CheckInOnClose = GetOption(CHECKIN_ON_CLOSE_VALUE, Prompt) End Property Public Property Let CheckInOnClose(NewValue As OptionsValue) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set CheckInOnClose") SetOption CHECKIN_ON_CLOSE_VALUE, NewValue End Property Public Property Get CheckOutOnReopen() As OptionsValue Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get CheckOutOnReopen") CheckOutOnReopen = GetOption(CHECKOUT_ON_REOPEN_VALUE, Prompt) End Property Public Property Let CheckOutOnReopen(NewValue As OptionsValue) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set CheckOutOnReopen") SetOption CHECKOUT_ON_REOPEN_VALUE, NewValue End Property Public Property Get SubmitCurrentDocOnly() As Boolean Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get SubmitCurrentDocOnly") SubmitCurrentDocOnly = GetBooleanOption(SUBMIT_CURRENT_DOC_ONLY_VALUE, True) End Property Public Property Let SubmitCurrentDocOnly(NewValue As Boolean) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set SubmitCurrentDocOnly") SetBooleanOption SUBMIT_CURRENT_DOC_ONLY_VALUE, NewValue End Property Public Property Get AutoLock() As OptionsValue Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get AutoLock") AutoLock = GetOption(AUTO_LOCK_VALUE, Always) End Property Public Property Let AutoLock(NewValue As OptionsValue) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set AutoLock") SetOption AUTO_LOCK_VALUE, NewValue End Property Public Property Get CheckinAfterAddReminder() As OptionsValue Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Get CheckinAfterAddReminder") CheckinAfterAddReminder = GetOption(CHECKIN_AFTER_ADD_REMINDER_VALUE, Prompt) End Property Public Property Let CheckinAfterAddReminder(NewValue As OptionsValue) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "Set CheckinAfterAddReminder") SetOption CHECKIN_AFTER_ADD_REMINDER_VALUE, NewValue End Property Public Property Get DebugTrace() As Boolean ' This is one procedure where we don't want any Stack tracing!! DebugTrace = GetBooleanOption(DEBUG_TRACE_VALUE, False, False) End Property Private Function GetOption(ValueName As String, DefaultValue As OptionsValue, _ Optional TraceStack As Boolean = True) As OptionsValue If TraceStack Then Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "GetOption") End If Dim vValue As Variant 'setting of queried value Dim v As Long GetOption = DefaultValue With New RegOp .Root = HKEY_CURRENT_USER .Key = P4FOROFFICE_KEY vValue = .Value(ValueName) If IsEmpty(vValue) Then v = DefaultValue .Value(ValueName) = v Else v = Int(vValue) If v > 2 Then v = DefaultValue End If GetOption = v End If End With End Function Private Function GetBooleanOption(ValueName As String, DefaultValue As Boolean, _ Optional TraceStack As Boolean = True) As Boolean If TraceStack Then Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "GetBooleanOption") End If Dim vValue As Variant 'setting of queried value Dim v As Long GetBooleanOption = DefaultValue With New RegOp .Root = HKEY_CURRENT_USER .Key = P4FOROFFICE_KEY vValue = .Value(ValueName) If IsEmpty(vValue) Then If DefaultValue Then v = 1 Else v = 0 End If .Value(ValueName) = v Else v = Int(vValue) GetBooleanOption = Not (v = 0) End If End With End Function Private Sub SetOption(ValueName As String, NewValue As OptionsValue) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "SetOption") Dim Result As Long 'result of the API functions Dim val As Integer val = NewValue With New RegOp .Root = HKEY_CURRENT_USER .Key = P4FOROFFICE_KEY .Value(ValueName) = val End With End Sub Private Sub SetBooleanOption(ValueName As String, NewValue As Boolean) Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "GetBooleanOption") Dim Result As Long 'result of the API functions Dim val As Integer val = 0 If NewValue Then val = 1 With New RegOp .Root = HKEY_CURRENT_USER .Key = P4FOROFFICE_KEY .Value(ValueName) = val End With End Sub Public Property Get HelpFilePath() As String Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "HelpFilePath") Dim vValue As Variant 'setting of queried value ' Search HKCU and HKLM in that order With New RegOp .Root = HKEY_CURRENT_USER .Key = P4FOROFFICE_KEY vValue = .Value(HELP_FILE_VALUE) If vValue = Empty Then HelpFilePath = vbNullString Else HelpFilePath = CStr(vValue) End If End With If Len(HelpFilePath) = 0 Then With New RegOp .Root = HKEY_LOCAL_MACHINE .Key = P4FOROFFICE_KEY vValue = .Value(HELP_FILE_VALUE) If vValue = Empty Then HelpFilePath = vbNullString Else HelpFilePath = CStr(vValue) End If End With End If End Property Public Property Get SupportEmailAddress(Optional DefaultValue As String = "support@perforce.com") As String Dim T As Tracker: Set T = GStackTrace.Enter(ModuleName, "SupportEmailAddress") Dim vValue As Variant 'setting of queried value ' Search HKCU and HKLM in that order With New RegOp .Root = HKEY_CURRENT_USER .Key = P4FOROFFICE_KEY vValue = .Value(SUPPORT_EMAIL_VALUE) If vValue = Empty Then SupportEmailAddress = DefaultValue Else SupportEmailAddress = CStr(vValue) End If End With End Property
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11893 | Robert Cowham |
Populate -o //guest/robert_cowham/perforce/P4OFC/main/... //guest/robert_cowham/perforce/P4OFC/icm/.... |
||
//guest/robert_cowham/perforce/P4OFC/main/p4comaddin/RegOptions.bas | |||||
#1 | 10843 | Robert Cowham |
Initial version of P4OFC source code. See README.txt (and LICENSE.txt and doc\P4OFC-Design.docx) |