/*Poping color selection window.
Here is an interesting piece of code for poping color selection window.
*/
static void Jimmy_colorsChoose(Args _args)
{
    #DEFINE.COLORVALUE (64)
    int             r, g, b;
    container       chosenColor;
    Binary          customColors = new Binary(#COLORVALUE);
    CCColor         colorValue;
;
    chosenColor = WinAPI::chooseColor(infolog.hWnd(), r, g, b, customColors, true);
    if (chosenColor)
    {
        [r, g, b] = chosenColor;
        colorValue  = WinAPI::RGB2int(r, g, b);
        print (colorValue);
        pause;
    }
}
Wrote by Jimmy on July 16th 2010
1) Hexadecimal turn to Decimal (RGB 0-255) sytem custom functions.
static void Jimmy_hex2RGB(Args _args)//hexadecimal Converted to RGB
{
Container c;
Dialog Dialog
= new Dialog("Hex converted to RGB!");

DialogField dlgFex
= Dialog.addField(types::String,"hexadecimal format",'PS:FFBBAA');

int m;
str
20 ps,Fex;

Container hex2RGB(str
50 Hexstr)
{
Container con;
int len,i;
str
50 st;
;
st
= global::StrDelete(Hexstr,'#');
st
= global::strLRTrim(st);

st
= substr(st,1,6);
len
= strlen(st);
info(st
+ '..' + int2str(len)) ;

for(i = 1; i <= len; i += 2)
{
Con
+= [hex2Int(substr(st,i,2))];

}
return Con;
}
;

setprefix(
'RGB');
Dialog.doInit();
if(!Dialog.run())
return ;

Fex
= dlgFex.value();
c
= hex2RGB(Fex);
for(m = 1 ; m <= Conlen(c); m++)
{
if(!ps)
ps
= int2str(conpeek(c,m));
else
ps
+= ',' + int2str(conpeek(c,m));

}

info(strfmt(
"'%1' %2 '%3'",Fex, 'Turn to RGB is',ps));
}

相关文章: