home *** CD-ROM | disk | FTP | other *** search
-
- Windows API Utilities
-
- ========================================================================
-
- A number of Windows API are used in ORDENTRY.MDB, one of the Microsoft
- Access sample applications. While the use of the Windows API is not
- necessary to create powerful and robust applications with Microsoft
- Access, it can be useful in certain situations.
-
- Each of the Windows API calls used in ORDENTRY.MDB is briefly documented
- below. For examples, see the module "Windows API Utilities" in
- ORDENTRY.MDB
-
- ========================================================================
-
-
- CheckMenuItem, EnableMenuItem
-
- CheckMenuItem can be used to place or remove a check mark next to a given
- menu item. Similarly, EnableMenuItem can be used to enable or disable a
- menu item. These Windows functions can be called directly, but it might
- prove easier to call wu_SetMenuChecked and wu_SetMenuEnabled.
-
- Note that these functions cannot be called for a form during the form's
- OnOpen or OnMenu events, since the menu may not be completely initialized
- during these events.
-
-
- DrawMenuBar
-
- After modifying a menu (such as wu_SetMenuChecked and wu_SetMenuEnabled
- do), it is necessary to redraw the menu using DrawMenuBar. See either
- wu_SetMenuChecked or wu_SetMenuEnabled for an example.
-
-
- GetActiveWindow
-
- GetActiveWindow is used in the wu_GetCurrentDoc function to determine
- the window handle for the "active" or "current" Microsoft Access
- document. This allows wu_GetCurrentDoc to retrieve a handle to a table
- or query datasheet, or some other non-form window. This handle, then,
- can be passed to other functions such as wu_CenterDoc.
-
-
- GetClassName
-
- Without GetClassName, wu_CenterDoc would be slightly less flexible. The
- wu_CenterDoc function was written to be as generic as possible. To that
- end, the function will work with non-form windows, such as table and
- query datasheets, as well as forms. Still, forms present some special
- cases for centering, specifically in the case of pop-up forms. The
- GetClassName function is used to determine what type of object the
- wu_CenterDoc function is dealing with, in order to special case forms,
- both pop-up and non-pop-up.
-
-
- GetClientRect, GetWindowRect
-
- GetClientRect and GetWindowRect are used in wu_CenterDoc to determine
- the size of the MDI Client window and the Windows desktop, respectively.
- With this information stored as a rectangle, centering a form over one
- of these parent windows becomes a straightforward task.
-
-
- GetDC
-
- With so many different video devices available today, it is often
- necessary to query Windows for certain device dependent information,
- such as the number of pixels per inch. This is especially important
- when sizing a window to "3 inches by 2 inches." The custom tool palette
- used in ORDENTRY.MDB uses GetDC in this manner.
-
-
- GetDesktopWindow
-
- GetDesktopWindow is used by wu_GetScreenSize. The handle returned by
- this function is needed to determine the size of the screen in pixels.
-
-
- GetDeviceCaps
-
- This function allows wu_ConvertTwipsToPixels to accurately convert a
- measurement stored in twips (like all Microsoft Access size and position
- properties) to inches. GetDeviceCaps can also be used to retrieve the
- ratio of pixels to inches.
-
-
- GetFocus
-
- GetFocus plays a minor role in wu_GetCurrentDoc. It simply retrieves a
- handle to the current Windows window, whatever that may be.
-
-
- GetMenu, GetSubMenu
-
- Most of the menu functions (such as graying a menu item, or placing a
- check mark next to a menu item) require a handle to the menu or submenu
- to modify. GetMenu and GetSubMenu are frequently used in the menu
- functions wu_FMenuChecked, wu_FMenuEnabled, wu_SetMenuChecked, and
- wu_SetMenuEnabled.
-
-
- GetMenuState
-
- This menu utility function returns state information about a particular
- menu item. You will find it used in both wu_FMenuChecked and
- wu_FMenuEnabled.
-
-
- GetParent
-
- Calls to GetParent are made in wu_CenterDoc, to determine what to
- reference when centering the object. In the case of normal forms,
- GetParent returns a handle to the Microsoft Access MDI Client window,
- which is essentially the entire gray area behind the MDI windows. For
- pop-up windows, GetParent returns a handle to the Windows desktop.
-
-
- GetWindow
-
- The GetWindow function can be used by an application to query Windows
- for parent and/or sibling relationships for any given window. In
- ORDENTRY.MDB, GetWindow is used to find window handles for Microsoft
- Access, and the Microsoft Access toolbar.
-
-
- IsZoomed
-
- IsZoomed simply returns whether or not a given window is maximized.
- This function is used in wu_SetAccessSize. If wu_SetAccessSize
- determines that Microsoft Access is maximized, it first restores the
- window (using ShowWindow), and then calls MoveWindow to set the
- requested size and position.
-
-
- MoveWindow
-
- MoveWindow is used in wu_CenterDoc to center the document once the
- centered size and position have been calculated.
-
-
- SetFocus
-
- With a custom tool palette like the one in ORDENTRY.MDB, it is often
- necessary to switch back to Microsoft Access and the currently active
- (non-pop-up) form in order to perform some operation, like switching to
- Datasheet view. In order to do this in the most generic way possible,
- wu_GetCurrentDoc will first SetFocus back to Microsoft Access, thus
- removing the focus from the pop-up tool palette.
-
-
- ShowWindow
-
- If a window is maximized, you can use ShowWindow to restore it or
- minimize it. See IsZoomed for more information on how ShowWindow is
- used in ORDENTRY.MDB.
-
-