Jump to content
Developer Wiki and Function Reference Links ×

VS SetColorButton does not seem to work


Recommended Posts

Has anyone ever gotten SetColorButton() to work? It is advertised as being introduced in VW 9.0, but I could not get it to affect a color change on a Modern Dialog PushButton in VW 2019, VW2014, or VW 2009, which is as far back as I can test without switching computers.

 

Is it designed to work on a different kind of control? Documentation is sparse in both the HTML Script Function Reference and the online Developer's WIKI. If no one answers to the affirmative in a day I'll file a bug.

 

Thank you,

Raymond

Link to comment

Yes, in an old PIO. It still works in 2020. Here is the code:

 

Function GetColourIndex(CurrentIndex : INTEGER) : INTEGER;
VAR
    DialogID, DlogResult : INTEGER;

    Function Define_Dialog: INTEGER;
    VAR
        dialogID : INTEGER;
    BEGIN
        dialogID := CreateLayout('Choose Colour', False, 'OK', 'Cancel');
        CreateGroupBox(dialogID, 4, '', False);
        CreateControl(dialogID, 5, 2,'',0);
        SetFirstLayoutItem(dialogID, 4);
        SetBelowItem(dialogID, 4, 5, 5, 0);
        Define_Dialog := dialogID;
    END;

    Procedure Drive_Dialog(VAR item:LONGINT; data:LONGINT);
    VAR
        red, green, blue : LONGINT;
    BEGIN
        CASE item OF
            SetupDialogC: BEGIN
                ColorIndexToRGB(CurrentIndex, red, green, blue);
                SetColorButton(DialogID, 5, red, green, blue);
            END;
            1: BEGIN
                GetColorButton(DialogID, 5, red, green, blue);
                RGBToColorIndex(red, green, blue, GetColourIndex);
            END;
            2: GetColourIndex := CurrentIndex;
        END;
    END;

BEGIN
    DialogID := Define_Dialog;
    IF VerifyLayout(DialogID) THEN DlogResult := RunLayoutDialog(DialogID, Drive_Dialog);
END;

Link to comment

Hi Julian,

   That is not what I was hoping for. CreateControl(), option 2, creates a button to select a color from a system color palette. I was hoping to set the color of a PushButton, so I guess I mis-interpreted the function's use. 

 

   Thank you for clarifying it.

 

Raymond

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...