Colour Selection in PB Apps
- New
- Advice
-
Chris Pollach @Appeon
- PowerBuilder
- Tuesday, 12 May 2026 06:05 PM UTC
Hi Everyone - John / Brad;
Sorry for the missing colour post but I realized that the RGB value for internal O/S mapping was wrong in my Colours App. There cannot be any value > 255 in either the R,G,B fields (as Brad pointed out). However, my calculation was based on how the PB documentation handles the RGB() method calculation, as follows: https://docs.appeon.com/pb2022/powerscript_reference/rGB_func.html
If you look at the formulae, they use: 65536 * Blue+ 256 * Green + Red to compute the Long value. In reverse, this would become...
IF ll_Colour_no > 65536 THEN // Blue Present?
li_no = ll_colour_no / 65536 // YES, Calc #
li_blue = li_no // Save BLUE #
ll_colour_no = ll_colour_no - (65536 * li_no) // Decrement
END IF
IF ll_Colour_no > 256 THEN // Green Present?
li_no = ll_colour_no / 256 // YES, Calc#
li_green = li_no // Save #
ll_colour_no = ll_colour_no - (256 * li_no) // Decrement
END IF
IF ll_Colour_no > 256 THEN // RED only?
Return -1 // NO, Return Error!
else
li_Red = ll_colour_no // Yes, Set #
END IF
However, I just realized that when you map MS-Windows based Colours, the Blue value would be calculated as a value > 255. So then, there is no way to use the RGB() command again to remap these internal colours. Hence, the only way forward would be to only use the Long colour value. So I changed the Colour App to detect this and not show the RGB for OS colour mappings (> 255) as follows:

I have uploaded the corrected app source code now to SourceForge. So when you download the Colour Selection App, it will now show "N/A" in the RGB SLE where any reversed colour value is > 255 based on the above reverse calculation. https://chrispollach.blogspot.com/2025/12/2025r1.html
Sorry for creating the missing response earlier. HTH
Regards .. Chris
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.