devxlogo

Painting as 3D

Painting as 3D

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

Answer:
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 IntegerDeclare Function Ctl3DAutoSubclass Lib “Ctl3Dv2.DLL” (ByVal hInst As Integer) As IntegerDeclare Function Ctl3DRegister Lib “Ctl3Dv2.DLL” (ByVal hInst As Integer) As IntegerDeclare Function Ctl3DUnregister Lib “Ctl3Dv2.DLL” (ByVal hInst As Integer) As IntegerConst GWW_HINSTANCE = (-6)
  2. Next, create the following function to enable 3D effects.
    Function g_fnUse3DEffects (fInput As Form) As IntegerDim hInst As IntegerDim iRC As Integer   hInst = GetWindowWord(fInput.hWnd, GWW_HINSTANCE)   If hInst <> 0 Then      iRC = Ctl3DRegister(hInst)      iRC = Ctl3DAutoSubclass(hInst)   End If   g_fnUse3DEffects = hInstEnd 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

See also  Who are the Modern GPU Cloud Providers?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist