Article ID: 143044
Article Last Modified on 12/9/2003
''' MODULE1.BAS
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#If Win16 Then
Declare Function WritePrivateProfileString Lib "KERNEL" ( _
ByVal AppName As String, ByVal KeyName As String, _
ByVal keydefault As String, ByVal FileName As String) As _
Integer
Declare Function GetPrivateProfileString Lib "KERNEL" ( _
ByVal AppName As String, ByVal KeyName As String, _
ByVal keydefault As String, ByVal ReturnString As String, _
ByVal NumBytes As Integer, ByVal FileName As String) As Integer
#ElseIf Win32 Then
Declare Function WritePrivateProfileString Lib "KERNEL32" _
Alias "WritePrivateProfileStringA" (ByVal AppName As String, _
ByVal KeyName As String, ByVal keydefault As String, _
ByVal FileName As String) As Long
Declare Function GetPrivateProfileString Lib "KERNEL32" _
Alias "GetPrivateProfileStringA" (ByVal AppName As String, _
ByVal KeyName As String, ByVal keydefault As String, _
ByVal ReturnString As String, ByVal NumBytes As Long, _
ByVal FileName As String) As Long
#End If
Sub Main()
#If Win16 Then
Const Section = "Add-Ins16"
#ElseIf Win32 Then
Const Section = "Add-Ins32"
#End If
Const BufSize = 255
Dim Ret As Variant
Dim RetStr As String
' Check to see if the entry is already in the VB.INI file.
' Add if not.
RetStr = Space(BufSize)
Ret = GetPrivateProfileString(Section, "ReadOnlyMode.Switch", _
"NotFound", RetStr, BufSize, "VB.INI")
RetStr = Left(RetStr, Ret)
If RetStr = "NotFound" Then
WritePrivateProfileString Section, "ReadOnlyMode.Switch", _
"0", "VB.INI"
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Property Value
---------------------------------------
Instancing 1 - Creatable MultiUse
Name Switch
Public True
''' CLASS1.CLS
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Private ThisInstance As VBIDE.Application
Private AddInMenuLine As VBIDE.MenuLine
Private AddInID As Long
Public Sub ConnectAddIn(VBInstance As Object)
Set ThisInstance = VBInstance
Set AddInMenuLine = ThisInstance.AddInMenu.MenuItems.Add( _
"Strict &ReadOnlyMode")
AddInMenuLine.Checked = ThisInstance.ReadOnlyMode
AddInID = AddInMenuLine.ConnectEvents(Me)
End Sub
Public Sub DisconnectAddIn(Mode As Integer)
AddInMenuLine.DisconnectEvents AddInID
ThisInstance.AddInMenu.MenuItems.Remove AddInMenuLine
End Sub
Public Sub AfterClick()
ThisInstance.ReadOnlyMode = ThisInstance.ReadOnlyMode Xor 1
AddInMenuLine.Checked = ThisInstance.ReadOnlyMode
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Value
----------------------------------------
Startup Form Sub Main
Project Name ReadOnlyMode
StartMode OLE Server
Error Trapping Break in Class Module
Additional query words: Addin Addins VBIDE ssafe
Keywords: kbinfo kbenv KB143044