Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Painting as 3D

How do I use 3D effects on message boxes and common dialogs?

Here is the code you need, in the form of two simple functions. Please note that this code will not work on standard forms. For that, I would recommend getting a control from one of the public FTP locations specified in the Internet Resources page at this site.

  1. First, put the following API declarations into your form or code module:
    Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer
    Declare Function Ctl3DAutoSubclass Lib "Ctl3Dv2.DLL" (ByVal hInst As Integer) As Integer
    Declare Function Ctl3DRegister Lib "Ctl3Dv2.DLL" (ByVal hInst As Integer) As Integer
    Declare Function Ctl3DUnregister Lib "Ctl3Dv2.DLL" (ByVal hInst As Integer) As Integer
    Const GWW_HINSTANCE = (-6)
  2. Next, create the following function to enable 3D effects.
    Function g_fnUse3DEffects (fInput As Form) As Integer
    Dim hInst As Integer
    Dim iRC As Integer
       hInst = GetWindowWord(fInput.hWnd, GWW_HINSTANCE)
       If hInst <> 0 Then
          iRC = Ctl3DRegister(hInst)
          iRC = Ctl3DAutoSubclass(hInst)
       End If
       g_fnUse3DEffects = hInst
    End Function
  3. Finally, create the following function to disable 3D effects.
    Sub g_sub3DDisable (hInst As Integer)
       Dim iRC As Integer
       iRC = Ctl3DUnregister(hInst)
    End Sub
  4. Here is the code you would use to create a 3D Message Box, for example, using these functions.
       Dim hInst As Integer
       hInst = g_fn3DEnable(ActiveForm)
       MsgBox "An error occurred.", MB_ICONEXCLAMATION, "Application Title"
       g_sub3DDisable hInst
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date