ShowColorDialog – Show the standard color dialog

ShowColorDialog – Show the standard color dialog

Private Type ChooseColorStruct    lStructSize As Long    hwndOwner As Long    hInstance As Long    rgbResult As Long    lpCustColors As Long    flags As Long    lCustData As Long    lpfnHook As Long    lpTemplateName As StringEnd TypePrivate Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" _    (lpChoosecolor As ChooseColorStruct) As LongPrivate Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor _    As Long, ByVal lHPalette As Long, lColorRef As Long) As Long    Private Const CC_RGBINIT = &H1&Private Const CC_FULLOPEN = &H2&Private Const CC_PREVENTFULLOPEN = &H4&Private Const CC_SHOWHELP = &H8&Private Const CC_ENABLEHOOK = &H10&Private Const CC_ENABLETEMPLATE = &H20&Private Const CC_ENABLETEMPLATEHANDLE = &H40&Private Const CC_SOLIDCOLOR = &H80&Private Const CC_ANYCOLOR = &H100&Private Const CLR_INVALID = &HFFFF' Show the common dialog for choosing a color.' Return the chosen color, or -1 if the dialog is canceled'' hParent is the handle of the parent form' bFullOpen specifies whether the dialog will be open with the Full style ' (allows to choose many more colors)' InitColor is the color initially selected when the dialog is open' Example:'    Dim oleNewColor As OLE_COLOR'    oleNewColor = ShowColorsDialog(Me.hwnd, True, vbRed)'    If oleNewColor <> -1 Then Me.BackColor = oleNewColorFunction ShowColorDialog(Optional ByVal hParent As Long, _    Optional ByVal bFullOpen As Boolean, Optional ByVal InitColor As OLE_COLOR) _    As Long    Dim CC As ChooseColorStruct    Dim aColorRef(15) As Long    Dim lInitColor As Long      ' translate the initial OLE color to a long value    If InitColor <> 0 Then        If OleTranslateColor(InitColor, 0, lInitColor) Then            lInitColor = CLR_INVALID        End If    End If        'fill the ChooseColorStruct struct    With CC        .lStructSize = Len(CC)        .hwndOwner = hParent        .lpCustColors = VarPtr(aColorRef(0))        .rgbResult = lInitColor        .flags = CC_SOLIDCOLOR Or CC_ANYCOLOR Or CC_RGBINIT Or IIf(bFullOpen, _            CC_FULLOPEN, 0)    End With        ' Show the dialog    If ChooseColor(CC) Then        'if not canceled, return the color        ShowColorDialog = CC.rgbResult    Else        'else return -1        ShowColorDialog = -1    End IfEnd Function

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