How to Send an HBITMAP to Windows API Function Calls from VB

Last reviewed: June 21, 1995
Article ID: Q71260
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

Several Windows API functions require the HBITMAP data type. Visual Basic for Windows does not have a HBITMAP data type. This article explains how to send the equivalent Visual Basic for Windows HBITMAP handle of a picture control to a Windows API function call.

MORE INFORMATION

This information is also included with the Microsoft Knowledge Base Help file provided with the Professional Edition of Microsoft Visual Basic version 3.0 for Windows. The HBITMAP data type represents a 16-bit index to GDIs physical drawing object. Several Windows API routines need the HBITMAP data type as an argument. Sending the [picture-control].Picture as an argument is the equivalent in Visual Basic for Windows.

The code sample below demonstrates how to send HBITMAP to the Windows API function ModifyMenu:

' Enter the following Declare statement as one, single line:
Declare Function SetMenuItemBitMaps% Lib "user" (ByVal hMenu%, ByVal nPos%,
   ByVal wFlag%, ByVal BitmapUnChecked%, ByVal hBitmapChecked%)

The SetMenuItemBitMap takes five arguments. The fourth and fifth arguments are HBITMAP data types.

The following code segment will associate the specified bitmap Picture1.Picture in place of the default check mark:

X% = SetMenuItemBitMap(hMenu%, menuID%,0,0, Picture1.Picture)


Additional reference words: 1.00 2.00 3.00
KBCategory: kbgraphic kbprg
KBSubcategory: APrgGrap


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.