Supprimer le bouton de sortie
Au lieu de désactiver simplement le bouton de sortie d'Access, on peut souhaiter ne pas afficher du tout les boutons de cette barre.
Pour cela, on placera le code suivant dans un module général :
Option Compare Database Option Explicit '/ '/ A placer dans la partie déclarative '/ Private Const GWL_STYLE = (-16) Private Const WS_CAPTION = &HC00000 Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_MAXIMIZEBOX = &H10000 Private Const WS_SYSMENU = &H80000 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOZORDER = &H4 Public Const SWP_FRAMECHANGED = &H20 Private Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) As Long
La fonction :
Function fnButtons(Show As Boolean) As Long Dim hwnd As Long Dim nIndex As Long Dim dwNewLong As Long Dim dwLong As Long ' hwnd = hWndAccessApp nIndex = GWL_STYLE ' Const wFlags = SWP_NOSIZE + SWP_NOZORDER + SWP_FRAMECHANGED + SWP_NOMOVE Const FLAGS_COMBI = WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU ' dwLong = GetWindowLong(hwnd, nIndex) ' If Show Then dwNewLong = (dwLong Or FLAGS_COMBI) Else dwNewLong = (dwLong And Not FLAGS_COMBI) End If ' Call SetWindowLong(hwnd, nIndex, dwNewLong) Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, wFlags) End Function
Il suffira ensuite, par exemple, d'appeler la fonction à partir de l'événement "Sur chargement" du formulaire principal.
Private Sub Form_Open(Cancel As Integer) '// False ou True fnButtons False End Sub
Dernière modification : 18/03/2010 19:02
Catégorie : Les mémos - Vrac
Page lue 5283 fois