Accueil > > > ACCESS : CACHER LA FENÊTRE PRINCIPALE DE L'APPLICATION
ACCESS : CACHER LA FENÊTRE PRINCIPALE DE L'APPLICATION
Information sur la source
Description
Comment cacher la fenêtre principale d'Access ??? J'ai trouvé une solution par hasard... C'est une bidouille, c'est pas beau, ça utilise certainement une erreur de chez microsoft... mais ça marche ! Déclarer les API suivantes dans un module (ApiWindows) Ecrire les deux fonctions HideApplicationForm et ShowApplicationForm (dans un autre module par ex). Appeler HideApplicationForm dans l'Open du formulaire de démarrage. Appeler ShowApplicationForm à partir d'un bouton ou d'un code touche pour faire réapparaître la fenêtre principale (sinon plus d'accès aux menus Access).
Source
- '********************************************************************************************
- '* ApiWindows : Déclaration des API Windows *
- '********************************************************************************************
- Option Compare Database
- Option Explicit
-
- ' GetDesktopWindow : Donne le pointeur de la fenêtre du bureau
- Public Declare Function GetDesktopWindow Lib "user32" ( _
- ) As Long
-
- ' GetParent : Donne le pointeur de la fenêtre parent
- Public Declare Function GetParent Lib "user32" _
- (ByVal hwnd As Long _
- ) As Long
-
- ' GetWindow : Donne le pointeur d'une fenêtre
- Public Declare Function GetWindow Lib "user32" _
- (ByVal hwnd As Long _
- , ByVal wCmd As Long _
- ) As Long
- Public Const GW_HWNDFIRST = 0 ' Pointeur de la première fenêtre
- Public Const GW_HWNDNext = 2 ' Pointeur de la fenêtre suivante
-
- ' GetWindowRect : Donne le rectangle d'affichage de la fenêtre
- Public Declare Function GetWindowRect Lib "user32" _
- (ByVal hwnd As Long _
- , lpRect As RECT _
- ) As Long
- Public Type RECT ' Rectangle d'affichage de la fenêtre
- left As Long
- top As Long
- right As Long
- bottom As Long
- End Type
-
- ' MoveWindow : Positionne et dimensionne la fenêtre
- Public Declare Function MoveWindow Lib "user32" _
- (ByVal hwnd As Long _
- , ByVal x As Long _
- , ByVal y As Long _
- , ByVal nWidth As Long _
- , ByVal nHeight As Long _
- , ByVal bRepaint As Long _
- ) As Long
-
- ' ShowWindow : Défini le mode d'affichage de la fenêtre
- Public Declare Function ShowWindow Lib "user32" _
- (ByVal hwnd As Long _
- , ByVal nCmdShow As Long _
- ) As Long
-
- '********************************************************************************************
- '* CommonFunctions : Fonctions communes du projet *
- '********************************************************************************************
- Option Compare Database
- Option Explicit
-
- '===== HideApplicationForm : Cacher la fenêtre application ==================================
- Function HideApplicationForm(FormId As Form)
- On Error GoTo Err_HideApplicationForm
- Dim hwndApplication As Long ' Fenêtre de l'application
- Dim lRect As RECT ' Dimension du bureau
- Dim wWidth As Long ' Largeur du formulaire
- Dim wHeight As Long ' Hauteur du formulaire
-
- ' Stocker le pointeur de le fenêtre principale
- '---------------------------------------------
- Application.Echo False
- hwndApplication = GetParent(GetParent(GetWindow(FormId.hwnd, GW_HWNDFIRST)))
-
- ' Maximiser la fenêtre principale
- '--------------------------------
- ShowWindow hwndApplication, 3
-
- ' Restore du formulaire
- '-----------------------
- DoCmd.Restore
-
- ' Stocker les dimensions du formulaire
- '-------------------------------------
- wWidth = FormId.WindowWidth
- wHeight = FormId.WindowHeight
-
- ' Cacher puis restorer la fenêtre principale
- '-------------------------------------------
- ShowWindow hwndApplication, 0
- ShowWindow hwndApplication, 1
-
- ' Stocker les dimensions du bureau
- '---------------------------------
- GetWindowRect GetDesktopWindow, lRect
-
- ' Dimensionner et centrer la fenêtre principale
- '----------------------------------------------
- If CurrentDb.Properties("StartUpShowStatusBar") = False Then
- MoveWindow hwndApplication _
- , (lRect.right - (wWidth / 15)) / 2 _
- , (lRect.bottom - (wHeight / 15)) / 2 _
- , wWidth / 15, wHeight / 15 _
- , 1
- Else
- MoveWindow hwndApplication _
- , (lRect.right - (wWidth / 15)) / 2 _
- , (lRect.bottom - (wHeight / 15)) / 2 _
- , (wWidth / 15), 20 + (wHeight / 15) _
- , 1
- End If
-
- ' Maximiser le formulaire
- '------------------------
- DoCmd.Maximize
-
- ' Sortie et Gestion des Erreurs
- '------------------------------
- Exit_HideApplicationForm:
- Application.Echo True
- Exit Function
- Err_HideApplicationForm:
- Select Case Err.Number
- Case Else
- MsgBox Err.Number & " " & "CommonFunctions" & " " _
- & "HideApplicationForm" & " :" & vbLf _
- & Nz(Err.Description, "") & vbLf _
- & "Values : " & FormId.Name
- End Select
- Resume Exit_HideApplicationForm
- End Function
-
- '===== ShowApplicationForm : Rétablir la fenêtre application =================================
- Function ShowApplicationForm(FormId As Form)
- On Error GoTo Err_ShowApplicationForm
- Dim hwndApplication As Long ' Fenêtre de l'application
-
- ' Stocker le pointeur de le fenêtre principale
- '---------------------------------------------
- Application.Echo False
- hwndApplication = GetParent(GetParent(GetWindow(FormId.hwnd, GW_HWNDFIRST)))
-
- ' Cacher, afficher puis maximiser la fenêtre principale
- '------------------------------------------------------
- ShowWindow hwndApplication, 0
- ShowWindow hwndApplication, 1
- ShowWindow hwndApplication, 3
-
- ' Restore du formulaire
- '-----------------------
- DoCmd.Restore
-
- ' Sortie et Gestion des Erreurs
- '------------------------------
- Exit_ShowApplicationForm:
- Application.Echo True
- Exit Function
- Err_ShowApplicationForm:
- Select Case Err.Number
- Case Else
- MsgBox Err.Number & " " & "CommonFunctions" & " " _
- & "ShowApplicationForm" & " :" & vbLf _
- & Nz(Err.Description, "") & vbLf _
- & "Values : " & FormId.Name
- End Select
- Resume Exit_ShowApplicationForm
- End Function
-
- '===== Form_Open : Ouverture du formulaire ==================================================
- Private Sub Form_Open(Cancel As Integer)
- On Error GoTo Err_Form_Open
-
- ' Cacher la fenêtre de l'application
- '-----------------------------------
- HideApplicationForm Me.Form
-
- Exit_Form_Open:
- Exit Sub
- Err_Form_Open:
- Select Case Err.Number
- Case Else
- MsgBox "Form_Open : Erreur n° " & Err.Number & " > " & Err.Description
- End Select
- Resume Exit_Form_Open
- End Sub
-
- '===== Form_KeyDown : Touche appuyée ========================================================
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- On Error GoTo Err_Form_KeyDown
-
- ' CTRL A : Restorer la fenêtre de l'application
- '----------------------------------------------
- If KeyCode = vbKeyA And (Shift And acCtrlMask) > 0 Then
- ShowApplicationForm Me.Form
- KeyCode = 0
- GoTo Exit_Form_KeyDown
- End If
-
- Exit_Form_KeyDown:
- Exit Sub
- Err_Form_KeyDown:
- Select Case Err.Number
- Case Else
- MsgBox "Form_KeyDown : Erreur n° " & Err.Number & " > " & Err.Description
- End Select
- Resume Exit_Form_KeyDown
- End Sub
'********************************************************************************************
'* ApiWindows : Déclaration des API Windows *
'********************************************************************************************
Option Compare Database
Option Explicit
' GetDesktopWindow : Donne le pointeur de la fenêtre du bureau
Public Declare Function GetDesktopWindow Lib "user32" ( _
) As Long
' GetParent : Donne le pointeur de la fenêtre parent
Public Declare Function GetParent Lib "user32" _
(ByVal hwnd As Long _
) As Long
' GetWindow : Donne le pointeur d'une fenêtre
Public Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long _
, ByVal wCmd As Long _
) As Long
Public Const GW_HWNDFIRST = 0 ' Pointeur de la première fenêtre
Public Const GW_HWNDNext = 2 ' Pointeur de la fenêtre suivante
' GetWindowRect : Donne le rectangle d'affichage de la fenêtre
Public Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long _
, lpRect As RECT _
) As Long
Public Type RECT ' Rectangle d'affichage de la fenêtre
left As Long
top As Long
right As Long
bottom As Long
End Type
' MoveWindow : Positionne et dimensionne la fenêtre
Public Declare Function MoveWindow Lib "user32" _
(ByVal hwnd As Long _
, ByVal x As Long _
, ByVal y As Long _
, ByVal nWidth As Long _
, ByVal nHeight As Long _
, ByVal bRepaint As Long _
) As Long
' ShowWindow : Défini le mode d'affichage de la fenêtre
Public Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long _
, ByVal nCmdShow As Long _
) As Long
'********************************************************************************************
'* CommonFunctions : Fonctions communes du projet *
'********************************************************************************************
Option Compare Database
Option Explicit
'===== HideApplicationForm : Cacher la fenêtre application ==================================
Function HideApplicationForm(FormId As Form)
On Error GoTo Err_HideApplicationForm
Dim hwndApplication As Long ' Fenêtre de l'application
Dim lRect As RECT ' Dimension du bureau
Dim wWidth As Long ' Largeur du formulaire
Dim wHeight As Long ' Hauteur du formulaire
' Stocker le pointeur de le fenêtre principale
'---------------------------------------------
Application.Echo False
hwndApplication = GetParent(GetParent(GetWindow(FormId.hwnd, GW_HWNDFIRST)))
' Maximiser la fenêtre principale
'--------------------------------
ShowWindow hwndApplication, 3
' Restore du formulaire
'-----------------------
DoCmd.Restore
' Stocker les dimensions du formulaire
'-------------------------------------
wWidth = FormId.WindowWidth
wHeight = FormId.WindowHeight
' Cacher puis restorer la fenêtre principale
'-------------------------------------------
ShowWindow hwndApplication, 0
ShowWindow hwndApplication, 1
' Stocker les dimensions du bureau
'---------------------------------
GetWindowRect GetDesktopWindow, lRect
' Dimensionner et centrer la fenêtre principale
'----------------------------------------------
If CurrentDb.Properties("StartUpShowStatusBar") = False Then
MoveWindow hwndApplication _
, (lRect.right - (wWidth / 15)) / 2 _
, (lRect.bottom - (wHeight / 15)) / 2 _
, wWidth / 15, wHeight / 15 _
, 1
Else
MoveWindow hwndApplication _
, (lRect.right - (wWidth / 15)) / 2 _
, (lRect.bottom - (wHeight / 15)) / 2 _
, (wWidth / 15), 20 + (wHeight / 15) _
, 1
End If
' Maximiser le formulaire
'------------------------
DoCmd.Maximize
' Sortie et Gestion des Erreurs
'------------------------------
Exit_HideApplicationForm:
Application.Echo True
Exit Function
Err_HideApplicationForm:
Select Case Err.Number
Case Else
MsgBox Err.Number & " " & "CommonFunctions" & " " _
& "HideApplicationForm" & " :" & vbLf _
& Nz(Err.Description, "") & vbLf _
& "Values : " & FormId.Name
End Select
Resume Exit_HideApplicationForm
End Function
'===== ShowApplicationForm : Rétablir la fenêtre application =================================
Function ShowApplicationForm(FormId As Form)
On Error GoTo Err_ShowApplicationForm
Dim hwndApplication As Long ' Fenêtre de l'application
' Stocker le pointeur de le fenêtre principale
'---------------------------------------------
Application.Echo False
hwndApplication = GetParent(GetParent(GetWindow(FormId.hwnd, GW_HWNDFIRST)))
' Cacher, afficher puis maximiser la fenêtre principale
'------------------------------------------------------
ShowWindow hwndApplication, 0
ShowWindow hwndApplication, 1
ShowWindow hwndApplication, 3
' Restore du formulaire
'-----------------------
DoCmd.Restore
' Sortie et Gestion des Erreurs
'------------------------------
Exit_ShowApplicationForm:
Application.Echo True
Exit Function
Err_ShowApplicationForm:
Select Case Err.Number
Case Else
MsgBox Err.Number & " " & "CommonFunctions" & " " _
& "ShowApplicationForm" & " :" & vbLf _
& Nz(Err.Description, "") & vbLf _
& "Values : " & FormId.Name
End Select
Resume Exit_ShowApplicationForm
End Function
'===== Form_Open : Ouverture du formulaire ==================================================
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
' Cacher la fenêtre de l'application
'-----------------------------------
HideApplicationForm Me.Form
Exit_Form_Open:
Exit Sub
Err_Form_Open:
Select Case Err.Number
Case Else
MsgBox "Form_Open : Erreur n° " & Err.Number & " > " & Err.Description
End Select
Resume Exit_Form_Open
End Sub
'===== Form_KeyDown : Touche appuyée ========================================================
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Form_KeyDown
' CTRL A : Restorer la fenêtre de l'application
'----------------------------------------------
If KeyCode = vbKeyA And (Shift And acCtrlMask) > 0 Then
ShowApplicationForm Me.Form
KeyCode = 0
GoTo Exit_Form_KeyDown
End If
Exit_Form_KeyDown:
Exit Sub
Err_Form_KeyDown:
Select Case Err.Number
Case Else
MsgBox "Form_KeyDown : Erreur n° " & Err.Number & " > " & Err.Description
End Select
Resume Exit_Form_KeyDown
End Sub
Conclusion
Vu les remarques et messages reçus, je joins un zip contenant un mdb exemple très simple qui je pense sera assez explicite sur la façon de déclarer les fonctions décrites. En créant cet exemple, j'ai remarqué qu'il y avait des disfonctionnements lorsque le style de bordure du formulaire n'est pas de type fixe (trait simple fixe ou trait double fixe).
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[WP7] UTILISER UN WRAPPANEL DANS UNE APPLICATION WINDOWS PHONE 7[WP7] UTILISER UN WRAPPANEL DANS UNE APPLICATION WINDOWS PHONE 7 par Audrey
Lors de la réalisation de ma 2ème application Windows Phone 7, j'ai souhaité utiliser un WrapPanel pour afficher plusieurs photos. Mais le contrôle WrapPanel ne fait pas parti de la liste des contrôles inclus dans le SDK de la version Beta des outils pour...
Cliquez pour lire la suite de l'article par Audrey [WP7] BESOIN D'AVOIR DES DONNéES EN CACHE[WP7] BESOIN D'AVOIR DES DONNéES EN CACHE par Nicolas
Les développeurs ASP.NET ont l'habitude de mettre des données en cache pour éviter de requêter a chaque fois la base de données. Et il est toujours utilie de penser que vos utilisateurs mobiles n'ont pas troujours une super connexion 3G/WIFI et un for...
Cliquez pour lire la suite de l'article par Nicolas [TFS] COMMENT FORCER LA SAISIE D'UN AREA OU ITERATION[TFS] COMMENT FORCER LA SAISIE D'UN AREA OU ITERATION par cyril
Lorsque l'on créé un Work Item dans TFS, il est possible de le classer dans un "area" et dans une "iteration". Dans la plupart des types de projet, un "area" correspond à une catégorie, une "iteration" à un numéro de version. Il est possible de cré...
Cliquez pour lire la suite de l'article par cyril SQL : FONCTIONS D'AGRéGATION MIN/MAX ET VALEURS NULLSQL : FONCTIONS D'AGRéGATION MIN/MAX ET VALEURS NULL par coq
Les fonctions d'agrégation comme MIN et MAX ignorent les valeurs NULL présentes dans le jeu de données sur lequel porte leur calcul, d'où le fameux message d'avertissement : Warning: Null value is eliminated by an aggregate or other SET operation...
Cliquez pour lire la suite de l'article par coq VOTEZ POUR WARNYGOVOTEZ POUR WARNYGO par Nicolas
La vidéo du projet Warnygo est disponible sur facebook et attend vos votes ! Pour rappel: Warnygo est une application Windows Phone 7 qui permet d'alerter tous utilisateurs inscrits qui se trouve dans la zone où se passe l'...
Cliquez pour lire la suite de l'article par Nicolas
Logiciels
sDEVIS-FACTURES vlPRO (3.8.0)SDEVIS-FACTURES VLPRO (3.8.0)sDEVIS-FACTURES vlPRO a été mis au point pour permettre besoins des particuliers, créateurs, entr... Cliquez pour télécharger sDEVIS-FACTURES vlPRO LettresFaciles (5.6.0)LETTRESFACILES (5.6.0)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles MyPlanning 2010 (5.6.0)MYPLANNING 2010 (5.6.0)MyPlanning 2010 permet de créer des plannings sous la représentation de diagrammes. Plannings pré... Cliquez pour télécharger MyPlanning 2010 Emicsoft Mac DVD en iPad Convertisseur (3.1.16)EMICSOFT MAC DVD EN IPAD CONVERTISSEUR (3.1.16)Emicsoft Mac DVD en iPad Convertisseur, logiciel professionnel de convertir les fichiers DVD en i... Cliquez pour télécharger Emicsoft Mac DVD en iPad Convertisseur Emicsoft ipad ménager pour mac (3.1.08)EMICSOFT IPAD MéNAGER POUR MAC (3.1.08)Emicsoft ipad ménager pour mac est spécialement conçu pour les utilisateurs Mac pour copier des f... Cliquez pour télécharger Emicsoft ipad ménager pour mac
|