Accueil → WINDEV 24 → [WB23] - Picking a colour
[WB23] - Picking a colour
Débuté par JP, 21 juin 2018 17:46 - 8 réponses
Posté le 21 juin 2018 - 17:46
Hi All

WebDev 23 - Dynamic site.

Any easy, nice way to allow a user to pick a colour either from a pallete or from a preset list of colours (e.g. the WB colour constants) ?

Posté le 21 juin 2018 - 18:09

I did that a few years back with a cell and a series of boutons, each of the color to select... Took me a good 10 minutes.

Easy enough?

Best regards
Posté le 22 juin 2018 - 11:47

OK, sure - I was just checking there was no easy colour picker like in WinDev :)

However, using a cell and some coloured buttons is fine but how do I return the colour selected back to the calling routine so that it can process the colour selected?
Posté le 22 juin 2018 - 13:37

in the click of button code you set the chosen color in your result variable... But that is clearly too simple to be the answer to the REAL question that I didn't understand... :-(

Best regards
Posté le 22 juin 2018 - 15:49
Hello JP,

I do this with 3 sliders set from 1 to 255. (red,green and blue)
Then I have 3 edit controls to show the numbers EDT_Red , EDT_Green and EDT_blue.
Last I have a cell that I change the background color if the user changes the slider of types in a number in the edit controls

On the slider code for red slider
EDT_Red = MySelf lp_SetColor()
Code for any of the color edit controls

PROCEDURE lp_SetColor() //Calulates the color CELL_Color..BrushColor = RGB(EDT_Red,EDT_Green,EDT_Blue) //This is a edit field hidden for me only that shows the color hex EDT_Color_Hex = 65536 * EDT_Blue + 256 * EDT_Green + EDT_Red
Posté le 22 juin 2018 - 16:32

:) lol - I understand how to retrieve brushcolor and all that. My problem is a design / operational desire rather than a technical issue. I want to let the user choose a colour and, when he does so, it updates the button brushcolor which was used for selecting the colour picker and then auto update a chart with the selected colour. I have worked out a working solution using the cell option you suggested. Thanks!
Posté le 22 juin 2018 - 16:35

Thanks, a nice solution. I wonder also if one could display a colour chart (like in WinDev colour selector) and then reocrd the X,Y coordinates of a mouse click and figure out the colour of the pixel clicked on... :) But anyway, I got a working solution but might give your suggestion a go too.

Posté le 22 juin 2018 - 16:45
Hi JP,

Not out of the box, but it's a few minutes work to create a little multi-column looper, that only contains a 16 x 16 sized button. The button has a style without border/background.
In the looper you use an Attribute for the returned color and to set the background color of the button.

The click of a button returns the color.
I use the following code to offer some basic colors:
LooperAddLine(LOOP_Color,RGB(148,148,148)) FOR i=65 TO 215 STEP 75 LooperAddLine(LOOP_Color,RGB(255, i, 0)) END LooperAddLine(LOOP_Color,RGB(196, 196, 196)) FOR i=75 TO 195 STEP 60 LooperAddLine(LOOP_Color,RGB(i, 255, 0)) END LooperAddLine(LOOP_Color,RGB(160, 120, 120)) FOR i=105 TO 255 STEP 75 LooperAddLine(LOOP_Color,RGB(75, i, 255)) END LooperAddLine(LOOP_Color,iLightYellow) FOR i=75 TO 255 STEP 60 LooperAddLine(LOOP_Color,RGB(255, i, 255)) END Kind regards,
Posté le 13 février 2020 - 01:28
Always good answers from Fabrice. Very helpful resource when your mind goes blank. :)