PickColor
Displays a dialog that allows you to choose a color
Download

PickColor.zip (35 KB)

IMPORTANT
For use of this function the Palm SDK 4.0 must be installed on your windows system! 

You have to do the following steps:
1. Download skd40.zip from the palm pages
2. Run "PALM OS SDK 4.0.exe".
3. Rename the existing c:\palmdev\sdk directory to sdk-old
4. Rename the c:\palmdev\sdk-4 directory to sdk

Functions definition

external "CASL_PickColor";

#---------------------------------------------------------
# private function
function xPickColor  
# displays a dialog that allows the user to choose a color
# Funktion returns the choosen rgb-alue as csv string "r,g,b", 
# for example "0,255,0" -> green color

(
numeric
rval, # default red value
numeric
gval, # default green value
numeric
bval, # default blue value
numeric
rgbmode, # kind of dialog (0=rgb, 1=palette)
string
rgbTitle # Title of pick dialog
)
as string; 

end_external;

#---------------------------------------------------------
# public function
function
PickColor (numeric rgbValue, numeric rgbMode,
                    string
rgbTitle) as numeric;

variables;
  string
rgb_Str;
  numeric r;
  numeric
g;
  numeric
b;
  numeric
i;
  numeric
Pos;
  numeric
rgbList[3];
end;

# get the red, green and blue value out of the rgb-value
 
i = rgbValue;
  r = i and 255;
  g = (i and 65280)/256;
  b = (i and 16711680)/65536;

# call the pick dialog
 
rgb_Str = xPickColor(r,g,b, rgbMode, rgbTitle);

# separate the string in its components
  for i=0,i<3;
    rgbList[i] = 0;
    Pos = find(",", rgb_Str,0);
    if Pos > 0;
      rgbList[i] = value(left(rgb_Str,Pos));
      rgb_Str = right(rgb_Str,length(rgb_Str)-Pos-1);
    else;
      rgbList[i] = value(rgb_Str);
    end_if;
  next i+1;
# make the rgb-value and return
  PickColor = rgb(rgbList[0], rgbList[1], rgbList[2]);
end;
 

  © 2005 Ulrich Riepert / Authorized for posting at CASLSoft.com