home *** CD-ROM | disk | FTP | other *** search
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- END
- Attribute VB_Name = "Application"
- Attribute VB_Creatable = True
- Attribute VB_Exposed = True
- Option Explicit
- Private mnuitRegedit As Object
- Private mvbApp As Object
- Private mParent As Object
- #If Win16 Then
- Private mAppHandle As Integer
- #Else
- Private mAppHandle As Long
- #End If
-
- ' Declarations for functions used by DisconnectAddIn
- #If Win16 Then
- Private Declare Function PostAppMessage Lib "User" _
- (ByVal htask As Integer, _
- ByVal wMsg As Integer, _
- ByVal wParam As Integer, _
- lParam As Any) _
- As Integer
- Private Declare Function IsTask Lib "KERNEL" _
- (ByVal htask As Integer) _
- As Integer
- #Else
- ' Under Win32, ending an application is very different.
- Private Declare Function OpenProcess Lib "KERNEL32" _
- (ByVal dwDesiredAccess As Long, _
- ByVal bInheritHandle As Long, _
- ByVal dwProcessId As Long) As Long
- Private Declare Function TerminateProcess Lib "KERNEL32" _
- (ByVal hProcess As Long, _
- ByVal uExitCode As Long) As Long
- Const TERMINATE_PROCESS = &H1
- #End If
- Const WM_QUIT = &H12
-
-
-
-
- Public Sub ConnectAddIn(objApplication As Object)
- ' Establish a reference to the VB application.
- Set mvbApp = objApplication
- Set mnuitRegedit = mvbApp.addinmenu.MenuItems.Add("&Registration Info Editor")
- mnuitRegedit.ConnectEvents Me
- ' Shows how to add submenus.
- ' Dim mnuSub1 As Object, mnuSub2 As Object, mnuSub3 As Object
- ' Set mnuSub1 = mvbApp.addinmenu.MenuItems.AddMenu("&Submenu1")
- ' mnuSub1.MenuItems.Add ("&MenuItem1")
- ' Set mnuSub2 = mnuSub1.MenuItems.AddMenu("&Submenu2")
- ' mnuSub1.MenuItems.Add ("M&enuItem2")
- ' mnuSub1.MenuItems.Add ("Me&nuItem3")
- ' Set mnuSub3 = mnuSub2.MenuItems.AddMenu("&Submenu3")
- End Sub
-
- Public Sub DisconnectAddIn(iConnect As Integer)
- Dim iWorked As Integer
- ' Check if RegEdit is still running.
- #If Win16 Then
- If IsTask(mAppHandle) Then
- ' Tell RegEdit to close
- iWorked = PostAppMessage(mAppHandle, WM_QUIT, 0, 0)
- End If
- #Else
- iWorked = OpenProcess(TERMINATE_PROCESS, _
- 0, mAppHandle)
- If iWorked Then
- iWorked = TerminateProcess(iWorked, 0)
- End If
- #End If
- Select Case iConnect
- ' Addin disconnected because VB closed.
- Case 0
- ' No extra work.
- ' Addin disconnected because user deselected its
- ' check box in the Addin manager.
- Case 1
- ' Remove menu item.
- mnuitRegedit.Parent.Remove mnuitRegedit
- End Select
- ' End AddIn
- End
- End Sub
-
- Public Sub afterclick()
- mAppHandle = Shell("REGEDIT /V", 1)
- End Sub
-
- ' Parent property (read always/write once).
- Public Property Get Parent() As Object
- ' Return the parent object.
- Set Parent = mParent
- End Property
-
- Public Property Set Parent(objSetting As Object)
- If TypeName(mParent) = "Nothing" Then
- Set mParent = objSetting
- Else
- ' Can't reset.
- Err.Raise 383, "Application object", "Parent property is read-only."
- End If
- End Property
-
-
-