HOWTO: Use CTL3D.DLL in Your Visual Basic Program

Last reviewed: February 13, 1997
Article ID: Q113898
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0, 3.0

SUMMARY

You can use CTL3D.DLL to add three-dimensional (3-D) effects to the common dialog boxes and message boxes for a Visual Basic application. However, CTL3D.DLL does not work currently for the controls on a Visual Basic form or for the form itself.

To get 3-D effects for the controls on a form, use the controls found in the THREED.VBX custom control.

MORE INFORMATION

To use CTL3D.DLL to enhance the common dialog boxes and message boxes from Visual Basic, follow these steps:

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add the following code to the form's general declarations section:

    Option Explicit Const GWW_HINSTANCE = (-6)

       ' Enter each declaration as one, single line:
       Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal
          nIndex As Integer) As Integer
       Declare Function Ctl3dAutoSubclass Lib "Ctl3D.DLL" (ByVal hInst As
          Integer) As Integer
       Declare Function Ctl3dRegister Lib "Ctl3D.DLL" (ByVal hInst As Integer)
          As Integer
       Declare Function Ctl3dUnregister Lib "Ctl3D.DLL" (ByVal hInst As
          Integer) As Integer
    
    

  3. Add the following code to the form's load event procedure:

       Sub Form_Load ()
         Dim hInst As Integer, ret As Integer
    
         hInst = GetWindowWord(Me.hWnd, GWW_HINSTANCE) ' Get Instance Handle
         ret = Ctl3dRegister(hInst)            ' Register program w/ Ctl3d.
         ret = Ctl3dAutoSubclass(hInst)        ' Subclass the program.
       End Sub
    
    

  4. Add the following code to the form's unload event procedure:

       Sub Form_Unload (Cancel As Integer)
         Dim hInst As Integer, ret As Integer
    
         hInst = GetWindowWord(Me.hWnd, GWW_HINSTANCE) ' Get Instance Handle
         ret = Ctl3dUnregister(hInst)          ' Unregister the program.
       End Sub
    
    

  5. Add a command button (Command1) to the form.

  6. In the Click event for Command1, add a MsgBox statement:

       Sub Command2_Click ()
          MsgBox "This is a 3-D Message Box"
       End Sub
    
    

  7. Press the F5 key to run the program. When you click the command button, a message box will appear in 3-D.

Important Note

If your program fails to unregister itself from CTL3D.DLL when your program ends, you may cause Windows to crash (stop operating). For example, if you place the Ctl3dUnregister() function in the Unload event and your program uses the End statement, Windows may crash because the End statement does not invoke the QueryUnload or Unload event.

REFERENCES

The information in this article is taken from the CTL3D.HLP help file.

You can find CTL3D.EXE (size: 402932 bytes) 
                      , a self-extracting file, on these services:

The following file is available for download from the Microsoft Software Library:

 ~ Ctl3d.exe (size: 402932 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from
               Online Services

REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q97361
   TITLE     : INF: Adding 3D Controls Using CTL3D.DLL


KBCategory: kbprg kbcode kbfile
KBSubcategory: APrgOther
Additional reference words: 3.00 softlib



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