Giving Forms a 3-D Look

Giving Forms a 3-D Look

It’s not widely known that you can use CTL3D.DLL (or CTL3DV2.DLL) togive your VB forms the same 3-D look of Microsoft’s Office suite of applications.First, your app must register with CTL3D at startup and deregisterbefore it ends. The Ctl3DInit and Ctl3DExit functions take care of thiswhen you pass them the hWnd property of any form in your program. To addthe 3-D effect to a form, call the Ctl3DForm subroutine with the form’sname as the parameter.
Ctl3DForm works its magic by calling GetWindowLong and SetWindowLongto set the form’s DS_MODALFRAME style bit. Then it calls Ctl3DSubclassDlgExto connect the form to CTL3D’s drawing routines:

 DefInt A-Z Option Explicit Global Const BUTTON_FACE = &H8000000F Global Const FIXED_DOUBLE = 3 Global Const DS_MODALFRAME = &H80& Global Const GWL_STYLE = (-16) Global Const GWW_HINSTANCE = (-6) Declare Function Ctl3dAutoSubclass Lib _ "CTL3D.DLL" (ByVal hInst) Declare Function Ctl3dSubclassDlgEx Lib _ "CTL3D.DLL" (ByVal hWnd, ByVal Flags&) Declare Function Ctl3dRegister Lib _ "CTL3D.DLL" (ByVal hInst) Declare Function Ctl3dUnregister Lib _ "CTL3D.DLL" (ByVal hInst) Declare Function GetWindowLong& Lib "User" _ (ByVal hWnd, ByVal nIndex) Declare Function GetWindowWord Lib "User" _ (ByVal hWnd, ByVal nIndex) Declare Function SetWindowLong& Lib "User" _ (ByVal hWnd, ByVal nIndex, ByVal dwNewLong&) Sub Ctl3DInit (hWnd As Integer) Dim hInst As Integer Dim iResult As Integer hInst = GetWindowWord(hWnd, GWW_HINSTANCE) iResult = Ctl3dRegister(hInst) iResult = Ctl3dAutoSubclass(hInst) End Sub Sub Ctl3DExit (hWnd As Integer) Dim hInst As Integer Dim iResult As Integer hInst = GetWindowWord(hWnd, GWW_HINSTANCE) iResult = Ctl3dUnregister(hInst) End Sub Sub Ctl3DForm (frm As Form) Dim hWnd As Integer Dim iResult As Integer Dim lStyle As Long hWnd = frm.hWnd If frm.BorderStyle = FIXED_DOUBLE Then frm.BackColor = BUTTON_FACE lStyle = GetWindowLong(hWnd, GWL_STYLE) lStyle = lStyle Or DS_MODALFRAME lStyle = SetWindowLong(hWnd, GWL_STYLE, lStyle) iResult = Ctl3dSubclassDlgEx(hWnd, 0) End If End Sub 

Ctl3DForm will only “3-D-ize” forms whose BorderStyleis 3 (FIXED_DOUBLE). You can achieve some, uh, unusual effects bytrying it on forms with other BorderStyles.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as