1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| ' PROJECT_NAME : VBIDE_Maximize (Addin pour IDE VB6) '
''
' < UTILISATION > '
' Modifiez les clés de registre «WSMode/WSDesigners/WSMain» situées dans '
' «HKEY_CURRENT_USER\Software\VB and VBA Program Settings\...\Prefers\» '
' en fonction du résultat désiré '
'======================================================================================='
Option Explicit
'___________________________________________________________________'
Private WithEvents VBPs As VBProjects
Private Const Section As String = "Prefers"
Private Const key1 As String = "WSMode" ' WindowState '
Private Const key2 As String = "WSDesigners"
Private Const key3 As String = "WSMain"
Private Const key4 As String = "ScreenStandart"
Private Const key5 As String = "ScreenDesigner"
Private Const key6 As String = "ScreenClass"
' Valeurs par défaut '
Private Const defkey1 As String = "2" ' WindowState: Maximize '
Private Const defkey2 As String = "0" ' Ne pas appliquer aux designers '
Private Const defkey3 As String = "1" ' Module principal au 1er plan '
Private Const defkey4 As String = "3" ' Ecran destination pour mod Standart '
Private Const defkey5 As String = "2" ' Ecran desti. pour designer (0=rien) '
Private Const defkey6 As String = "2" ' Ecran destination pour mod de classe '
'======================================================================================='
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
GetMonitorInfos
Set VBPs = Application.VBProjects
End Sub
Private Sub VBPs_ItemActivated(ByVal VBProject As VBIDE.VBProject): Maximise VBProject: End Sub
Private Sub VBPs_ItemAdded(ByVal VBProject As VBIDE.VBProject): Maximise VBProject: End Sub
Private Sub Maximise(vbp As VBProject)
Dim vbc As Object, pVbc As VBComponent
Dim ret As String, AppName As String
Dim S1 As Long, S2 As Boolean, S3 As Boolean, S4 As Long, S5 As Long, S6 As Long
On Error Resume Next
AppName = App.EXEName
' Récupérer les préférences '
'---------------------------------------------------'
' WindowState : 0/Normal, 1/Minimize, 2/Maximize '
ret = GetSetting(AppName, Section, key1)
If ret = "" Or Val(ret) > 2 Or Val(ret) < 0 Then
S1 = CLng(Val(defkey1))
SaveSetting AppName, Section, key1, defkey1
Else
S1 = CLng(Val(ret))
End If
' Seulement les modules de code et ? designers '
ret = GetSetting(AppName, Section, key2)
If ret = "" Then
S2 = CBool(Val(defkey2))
SaveSetting AppName, Section, key2, defkey2
Else
S2 = CBool(Val(ret))
End If
' Code de l'object de démarrage au premier plan '
ret = GetSetting(AppName, Section, key3)
If ret = "" Then
S3 = CBool(Val(defkey3))
SaveSetting AppName, Section, key3, defkey3
Else
S3 = CBool(Val(ret))
End If
If VBPs.VBE.DisplayModel = vbext_dm_SDI Then
' Ecrans de destination '
ret = GetSetting(AppName, Section, key4)
If ret = "" Then
S4 = CLng(Val(defkey4))
SaveSetting AppName, Section, key4, defkey4
Else
If CLng(Val(ret)) <= MonitorCount Then S4 = CLng(Val(ret))
End If
ret = GetSetting(AppName, Section, key5)
If ret = "" Then
S5 = CLng(Val(defkey5))
SaveSetting AppName, Section, key5, defkey5
Else
If CLng(Val(ret)) <= MonitorCount Then S5 = CLng(Val(ret))
End If
ret = GetSetting(AppName, Section, key6)
If ret = "" Then
S6 = CLng(Val(defkey6))
SaveSetting AppName, Section, key6, defkey6
Else
If CLng(Val(ret)) <= MonitorCount Then S6 = CLng(Val(ret))
End If
' Appliquer les préférences en mode SDI '
'---------------------------------------------------'
For Each vbc In vbp.VBComponents
If vbc.Type = vbext_ct_StdModule And S4 > 0 And S4 <= MonitorCount Then
vbc.CodeModule.CodePane.Window.Left = Monitors(S4).Left
vbc.CodeModule.CodePane.Window.Top = Monitors(S4).Top
ElseIf vbc.Type = vbext_ct_ClassModule And S6 > 0 And S6 <= MonitorCount Then
vbc.CodeModule.CodePane.Window.Left = Monitors(S6).Left
vbc.CodeModule.CodePane.Window.Top = Monitors(S6).Top
ElseIf S5 > 0 And S5 <= MonitorCount Then
vbc.CodeModule.CodePane.Window.Left = Monitors(S5).Left
vbc.CodeModule.CodePane.Window.Top = Monitors(S5).Top
End If
If vbc.HasOpenDesigner And S2 Then vbc.DesignerWindow.WindowState = S1
vbc.CodeModule.CodePane.Window.WindowState = S1
Next
End If
' Module principal au premier plan '
'---------------------------------------------------'
If TypeName(vbp.VBComponents.StartUpObject) <> "Long" And S3 Then
Set vbc = vbp.VBComponents.StartUpObject
vbc.CodeModule.CodePane.Window.SetFocus
ElseIf S3 Then
If vbp.VBComponents.StartUpObject = 0 Then
' rechercher le module contenant la procédure Main
For Each pVbc In vbp.VBComponents
If pVbc.Type = vbext_ct_StdModule Then
If pVbc.CodeModule.ProcBodyLine("Main", vbext_pk_Proc) > 0 Then
pVbc.CodeModule.CodePane.Window.SetFocus
Exit Sub
End If
End If
Next
End If
End If
End Sub |
Partager