Saving the Position of a Designer Widgets’ Dockable Toolbar

Saving the Position of a Designer Widgets’ Dockable Toolbar

The best way to save information about an application’s options, suchas toolbar positioning, is to write the settings to an INI file. To doso, two Windows API functions must be used: GetPrivateProfileInt and WritePrivateProfileString.Here are two functions that load and save settings to and from an INI file:

 'These two Declare statements go in the 'Declarations section of a module Declare Function GetPrivateProfileInt Lib "Kernel" _ (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, ByVal nDefault _ As Integer, ByVal lpFileName As String) As Integer Declare Function WritePrivateProfileString _ Lib "Kernel" (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, ByVal lpString _ As String, ByVal lplFileName As String) _ As Integer Sub LoadToolbarInfo (Tb As Control, _ Section As String, ININame As String) Tb.DockRank = GetPrivateProfileInt(Section, _ "DockRank", Tb.DockRank, ININame) Tb.DockRankSeq = GetPrivateProfileInt(Section, _ "DockRankSeq", Tb.DockRankSeq, ININame) Tb.FloatingLeft = GetPrivateProfileInt(Section, _ "FloatingLeft", Tb.FloatingLeft, ININame) Tb.FloatingTop = GetPrivateProfileInt(Section, _ "FloatingTop", Tb.FloatingTop, ININame) Tb.FloatingWidthInBtns = _ GetPrivateProfileInt(Section, _ "FloatingWidthInBtns",Tb.FloatingWidthInBtns, _ ININame) Tb.DockStatus = GetPrivateProfileInt(Section, _ "DockStatus", Tb.DockStatus, ININame) End Sub Sub SaveToolbarInfo (Tb As Control, _ Section As String, ININame As String) Dim rc% rc = WritePrivateProfileString(Section, _ "DockStatus", CStr(Tb.DockStatus), ININame) rc = WritePrivateProfileString(Section, _ "DockRank", CStr(Tb.DockRank), ININame) rc = WritePrivateProfileString(Section, _ "DockRankSeq", CStr(Tb.DockRankSeq), ININame) rc = WritePrivateProfileString(Section, _ "FloatingLeft", CStr(Tb.FloatingLeft), ININame) rc = WritePrivateProfileString(Section, _ "FloatingTop", CStr(Tb.FloatingTop), ININame) rc = WritePrivateProfileString(Section, _ "FloatingWidthInBtns", _ CStr(Tb.FloatingWidthInBtns), ININame) End Sub

This code can be found in the SAMPLESTBARSAVE directory that’sincluded with Designer Widgets.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

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