Microsoft Access 2010 Bible

(Rick Simeone) #1

Part IV: Professional Database Development


960


RetVal = _
apiGetSystemDirectory(ReturnBuffer, BufferSize)
GetSystemDirectory = _
Left$(ReturnBuffer, RetVal)
End Function

Going over general-purpose Windows API functions
The Win32 API has many functions to manipulate individual windows within applications like
Access. A few of these functions are discussed in the following sections. The DisplayTitle()
function under Listing 27.5 and Listing 27.6 uses several of the API functions as an example.

GetParent
The GetParent function returns a handle to a window’s parent. You might use this call to get a
handle on an Access application’s parent window.

Declare Function apiGetParent _
Lib “User32” Alias “GetParent”( _
ByVal hWnd As Long) As Long

When passed a valid window handle, GetParent retrieves the handle (hwnd) of the child win-
dow’s parent. The function returns a Null value if it’s unsuccessful.

GetWindowTextA
GetWindowTextA returns the title-bar text of a window, given its hwnd property.

Declare Function apiGetWindowText _
Lib “User32” _
Alias “GetWindowTextA”( _
ByVal hwnd As Long, _
ByVal lpszCaption As String, _
ByVal CaptionSize As Long) As Long

Occasionally, you may want to capture the text that appears in the title bar of a particular window
or the text displayed on a control. GetWindowTextA captures the text of the handle of the win-
dow or control that has been passed and places it in the lpszCaption argument.

GetClassNameA
GetClassNameA returns the class of the specified window.

Declare Function apiGetClassName _
Lib “User32” _
Alias “GetClassNameA”( _
ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal ClassSize As Long) As Long
Free download pdf