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.
- 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)
- 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
- Finally, create the following function to disable 3D effects.
Sub g_sub3DDisable (hInst As Integer) Dim iRC As Integer iRC = Ctl3DUnregister(hInst)End Sub
- 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