Use VB System Color Constants in API Calls

Visual Basic includes constants, such as vbActiveTitleBar and vbButtonFace, for Windows system colors, which the user might change through the Control Panel. (In VB3, these constants are defined in the file CONSTANT.TXT.) When you assign one of these constants to a VB color property, Visual Basic automatically translates it to the actual color the user has chosen for that item. You cannot, however, use VB’s system color constants directly with API functions, such as SetPixel, that expect a color as one of their parameters. VB’s system color constants are the same as those defined by the Windows API, except that VB’s constants have the high bit set. You can use this function to translate both VB and Windows system color constants into the corresponding RGB color value, suitable for use in API calls:

 ' 32-bitOption ExplicitDeclare Function GetSysColor Lib "User32" ( _	ByVal nIndex As Long) As LongPublic Function SysColor2RGB(ByVal lColor As Long) As Long	lColor = lColor And (Not &H80000000)	SysColor2RGB = GetSysColor(lColor)End Function

For 16-bit versions of VB, replace the GetSysColor declaration with this code:

 Declare Function GetSysColor Lib "User" ( _	ByVal nIndex As Integer) As Long
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

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