PRB: Invalid Handle Message Using Static Version of CTL3D

Last reviewed: July 22, 1997
Article ID: Q111752
1.00 1.50 WINDOWS kbprg kbprb

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

The Microsoft Developer Network (MSDN) CD provides a tool, CTL3D, that can be used with applications to give Windows controls a three-dimensional (3- D) look. The tool is provided as a dynamic-link library (DLL) (CTL3D.DLL) and as a static library (CTL3DS.LIB). When using the static library with an Microsoft Foundation Class (MFC) application, the controls do not appear as 3-D and the following debug error messages appear when the Ctl3dRegister() function is called:

   err CTLTST 0117:0138: Invalid HANDLE: 0000
   err CTLTST 0117:0197: Invalid global handle: 0000

CAUSE

The problem occurs when the .RC file does not include CTL3D.H. The include file, CTL3D.H, is needed to associate a resource ID with the 3-D bitmaps. When using the static version of CTL3D, the .RC file includes 3DCHECK.BMP, which is a bitmap used for the 3-D effects. For example,

   CTL3D_3DCHECK             BITMAP  DISCARDABLE     "3DCHECK.BMP"

In CTL3D.H, the resource ID CTL3D_3DCHECK is associated with a number as shown below:

   /* Resource ID for 3dcheck.bmp (for .lib version of ctl3d) */
   #define CTL3D_3DCHECK 26567

The association is needed if the library is to successfully load 3DCHECK.BMP. If the CTL3D.H header file is not included in the resource file, the necessary association is not made. The bitmap is assigned the string name "CTL3D_3DCHECK" instead of the expected resource number, and the CTL3D library fails to load the bitmap.

RESOLUTION

The problem can be corrected by including CTL3D.H in the .RC file. To include CTL3D.H, open App Studio and choose Set Includes from the File menu. To the Read-Only Symbol Directives box, add the following text:

   #include <ctl3d.h>

MORE INFORMATION

Below are the steps necessary to link to the static version of CTL3D, CTL3DS.LIB:

  1. Add CTL3DS to the list of input libraries. This can be done in Visual C++ by choosing Project from the Options menu, choosing Linker, highlighting the "Category:" Input, and adding ctl3ds to the list of libraries.

  2. Start App Studio and choose Set Includes from the File menu. To the Read-Only Symbol Directives box add the following:

          #include <ctl3d.h>
    

  3. Save the .RC file and reopen it so the IDs in CTL3D.H will be available in App Studio. This can be done from the File menu by choosing Save, choosing Close, choosing Open, and selecting the .RC file again.

  4. From the Resource menu, choose Import and enter 3DCHECK.BMP. Once the new bitmap resource is opened, change the ID of the bitmap to CTL3D_3DCHECK (which is already available). This can be done by choosing Properties from the Resource menu and clicking the down arrow of the ID list box. Scroll through the list box and select CTL3D_3DCHECK for the ID. This will add an entry to the project's RC file:

       CTL3D_3DCHECK           BITMAP  MOVEABLE PRE   "3DCHECK.BMP"
    
    
It is also necessary to add code to the application in order to use CTL3D. Refer to the documentation provided with the tool for further information about how to use the CTL3D functions.


Additional reference words: 1.00 1.50 2.00 2.50 ctrl3d ctl3ds listbox
KBCategory: kbprg kbprb
KBSubcategory: MfcMisc
Keywords : kb16bitonly
Technology : kbMfc


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: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.