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:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may