Color dialog box: – The common dialog control provides color dialog box. The show color method is used for calling color dialog box from common dialog control. Syntax of the ShowColor method is –

                <Control Name>.ShowColor

We use the common dialog control’s color property to retrieve the color selected by the user. The property holds a long integer color code representing the color. The code can be use with any control property that designate color, such as forecolor and backcolor properties of the form. These properties are used with some other controls. Syntax of the forecolor and backcolor properties are as follows –

                <Control Name>.Color=<Label/Text Name>.ForeColor
                <Control Name>.Color=<Label/Text Name>.BackColor

Before using these color setting, we must set the flags property with intrinsic constant DLGCCRGBInit then we set the color properties to a color code. The following code can be use either with label box or text box control. An example with show color method, flag, four color, back color and color properties are as follows –

    DLGCommon.Flags = cdlCCRGBInit
    DLGCommon.Color = LBLMessage.ForeColor
    DLGCommon.ShowColor
    LBLMessage.ForeColor = DLGCommon.Color
Advertisements