Modernize Your Toolbar Look

Modernize Your Toolbar Look

Using only a few Windows API calls, you can change the standard VB5 toolbar into an Office 97 look-alike. I’ve implemented two display styles for the toolbar. The first allows you to change the toolbar to an Office 97-style toolbar (similar to the one used by VB5), and the second allows you to change the toolbar to the Internet Explorer 4.0-style toolbar. If you want to use the second style, you must supply each button with some text in order to achieve the effect. In both cases, the button edges are flat and only appear raised when the mouse passes over the button. To implement it, add this code to a BAS module:

 Private Declare Function SendMessage Lib "user32" Alias _	"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _	ByVal wParam As Integer, ByVal lParam As Any) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias _	"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 _	As Long, ByVal lpsz1 As String, ByVal lpsz2 As _	String) As LongPrivate Const WM_USER = &H400Private Const TB_SETSTYLE = WM_USER + 56Private Const TB_GETSTYLE = WM_USER + 57Private Const TBSTYLE_FLAT = &H800Private Const TBSTYLE_LIST = &H1000Public Sub Office97Toolbar(tlb As Toolbar, _	tlbToolbarStyle As Long)	Dim lngStyle As Long	Dim lngResult As Long	Dim lngHWND As Long	' Find child window and get style bits	lngHWND = FindWindowEx(tlb.hwnd, 0&, _		"ToolbarWindow32", vbNullString)	lngStyle = SendMessage(lngHWND, _		TB_GETSTYLE, 0&, 0&)	' Use a case statement to get the effect	Select Case tlbToolbarStyle	Case 1:		' Creates an Office 97 like toolbar		lngStyle = lngStyle Or TBSTYLE_FLAT	Case 2:		' Creates an Explorer 4.0 like toolbar, 		' with text to the right		' of the picture. You must provide text 		' in order to get the effect.		lngStyle = lngStyle Or TBSTYLE_FLAT _			Or TBSTYLE_LIST	Case Else		lngStyle = lngStyle Or TBSTYLE_FLAT	End Select	' Use the API call to change the toolbar	lngResult = SendMessage(lngHWND, _		TB_SETSTYLE, 0, lngStyle)	' Show the effects	tlb.RefreshEnd Sub

Call this routine while a form with a toolbar is loading:

 Private Sub Form_Load()	Call Office97Toolbar(Me.Toolbar1, 2)	' whatever...End Sub
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