I am new to VBA therefore please excuse me in advance if my question is silly. That said, I have the following Windows API:
Private Declare PtrSafe Function IsIconic Lib "user32" (ByVal hWnd As LongPtr) As Integer
and inside the module where we have declared the API I have the following function:
Function IsMinimized(hWndAccessApp As Long) As Boolean
IsMinimized = IsIconic(hWndAccessApp) * -1
End Function
In addition to that I also have a form that has a button and a click event on that button that looks like:
Private Sub btn_one_Click()
Dim test As Boolean
test = IsMinimized(hWndAccessApp)
MsgBox test
End Sub
And everything is working perfectly. However, I was wondering if there is a way to skip the function inside the module and call the "IsIconic" API directly from the Private Sub associated with the button inside the form?
Dim test As Boolean
andtest = IsIconic(hWndAccessApp) * -1
it gives me thatIsIconic Sub or Function is not defined
and I am not sure how to define it further than addingPrivate Declare PtrSafe Function IsIconic...
inside a module. To be completely honest I agree with you, but there is not really a real case behind this. I am just playing around with functions and subs as an exercise more than anything else.