2 API funktioner laver kludder for hinanden
Jeg har et modul, som kan skjule access, det bygger på noget API. Derudover har jeg på en formular en funktion, som kan afspille en wav-fil, dette bygger også på noget API. Denne funktion på formularen gør dog at formularen forsvinder, når den åbnes og man kan kun få den tilbage ved at dobbeltklikke på mdb-filen...Så er der ikke en måde hvorpå jeg kan få begge funktioner til at virke, for de virker hver for sig!~)
Funktion:
Option Compare Database
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" Alias _
"PlaySoundA" (ByVal lpszName As String, ByVal hModule As _
Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000
Private Sub GodkendtAf_AfterUpdate()
On Error Resume Next
If Me.GodkendtAf = "me" Then
Call PlaySound("c:\lotus\flg\media\jubel.wav", 0, SND_ASYNC Or SND_FILENAME)
End If
End Sub
Modul, som er kaldt under opstart af database:
Option Compare Database
Option Explicit
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loform As Form
On Error Resume Next
Set loform = Screen.ActiveForm
If Err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox "Cannot hide Access unless " _
& "a form is on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
Else
If nCmdShow = SW_SHOWMINIMIZED And loform.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loform.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loform.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loform.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End Function
'************ Code End **********
