function TSkinColorPicker.CreateWindow(ParentHandle: HWND): HWND;
var
Font: HFont;
SetItem, K: Integer;
R, G, B, R1, G1, B1: Byte;
Count: Integer;
CLName, Color:
string;
Parse, ColorName: TSplitStrArray;
begin
FHColorPicker := CreateWindowX(0, '
/', WS_CHILD
or WS_VISIBLE, Left, Top,
Width, Height, ParentHandle, @ColorProc, DlgItemID);
FParentHandle := ParentHandle;
if FHColorPicker <> 0
then
begin
Img := SkinEngine.AddResource(ParentHandle, PWideChar(FColorImg));
LStyle := WS_CHILD
{or WS_VISIBLE} or WS_TABSTOP
or CBS_DROPDOWNLIST
or
CBS_HASSTRINGS
or CBS_DISABLENOSCROLL
or CBS_OWNERDRAWFIXED
or WS_VSCROLL
or CBS_NOINTEGRALHEIGHT;
HCombo := CreateWindowEx(0, '
COMBOBOX', PWideChar(ColorLabel), LStyle,
Width - 24, 0, 1, 152, FHColorPicker, DlgItemID, SkinEngine.skInstance,
nil);
Font := GetStockObject(ANSI_VAR_FONT);
SendMessage(HCombo, WM_SETFONT, Font, 0);
SkinColorPicker := self;
if ColorLabel > '
'
then
begin
SetItem := -1;
Parse := Split(ColorLabel, '
_');
Count := High(Parse);
SkinEngine.SplitColorARGB(SkinEngine.SK_AEROCOLOR, Alpha, Red, Green, Blue);
R1 := Red;
G1 := Green;
B1 := Blue;
for K := 0
to Count - 1
do
begin
// Get Color Name
ColorName := Split(Parse[K], '
,');
CLName := ColorName[Low(ColorName)];
// Remove first ' " ' char
if K = 0
then
CLName := MidStr(CLName, 2, Length(CLName));
SendMessage(HCombo, CB_ADDSTRING, 0, LParam(CLName));
// Get Color Value
Color := Trim(ColorName[High(ColorName)]);
R := StrToInt('
$' + Copy(Color, 2, 2));
G := StrToInt('
$' + Copy(Color, 4, 2));
B := StrToInt('
$' + Copy(Color, 6, 2));
SendMessage(HCombo, CB_SETITEMDATA, K, LParam(
RGB(R, G, B)));
if (R = R1)
and (G = G1)
and (B = B1)
then
SetItem := K;
end;
if SetItem > -1
then
SendMessage(HCombo, CB_SETCURSEL, SetItem, 0);
end;
if UseColor > '
'
then
begin
R := Byte(StrToInt('
$' + Copy(UseColor, 2, 2)));
G := Byte(StrToInt('
$' + Copy(UseColor, 4, 2)));
B := Byte(StrToInt('
$' + Copy(UseColor, 6, 2)));
end
else
begin
R := 255;
G := 255;
B := 255;
end;
SkinEngine.SetProperty(FHColorPicker, COLORPICK_COLOR, SkinEngine.ColorARGB
(255,
RGB(R, G, B)));
SkinEngine.SetProperty(FHColorPicker, COLORPICK_COMBO, HCombo);
btnDropDown := TSkinPushButton.Create();
btnDropDown.ImagePath := DropDownImg;
btnDropDown.Text := '
';
btnDropDown.Left := FWidth - 24;
btnDropDown.Top := 0;
btnDropDown.Width := 24;
btnDropDown.Height := Max(FHeight, 24);;
btnDropDown.DlgItemID := ID_COLORPICKBUTTON;
btnDropDown.TextCol := SKAERO_BTNTEXTCOLOR;
btnDropDown.Label3D := 1;
btnDropDown.TextAlligment := Center;
btnDropDown.ImageStateMax := 0;
btnDropDown.CreateWindow(FHColorPicker);
SkinEngine.SetAnchorMode(btnDropDown.Handle, ANCHOR_NONE);
SkinEngine.SetZorder(btnDropDown.Handle, HWND_TOP);
end;
Result := FHColorPicker;
end;