Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#9

AW: Constant expression expected

  Alt 18. Mai 2019, 11:03
Zitat:
Du hast da einen Fehler im Design.
Ich denke du hast einen Fehler im Verständnis.

Das Problem ist bereits behoben.

Du siehst die DLL weis sehr wohl was DlgItemID darstellt.
Aber extra nochmal für dich!
ANWENDUNG
Delphi-Quellcode:
{$REGION 'Interface ISkinColorPicker'}
  ISkinColorPicker = interface
    ['{EF99A6D4-16F9-4675-B006-CF7D0AAA0065}']
    {$REGION 'Getter+Setter'}
    function GetHandle: HWND;
    function GetHeight: Integer;
    procedure SetHeight(const Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(const Value: Integer);
    function GetTop: Integer;
    procedure SetTop(const Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(const Value: Integer);
    function GetDlgItemID: DWord;
    procedure SetDlgItemID(const Value: DWord);
    function GetColorLabel: string;
    procedure SetColorLabel(const Value: string);
    function GetUseColor: string;
    procedure SetUseColor(const Value: string);
    function GetDropDownImg: WideString;
    procedure SetDropDownImg(const Value: WideString);
    function GetColorImg: WideString;
    procedure SetColorImg(const Value: WideString);
    function GetPipetteCursor: WideString;
    procedure SetPipetteCursor(const Value: WideString);
    {$ENDREGION}
    function CreateWindow(ParentHandle: hWnd): HWND;
    procedure DestroyWindow;
    property Handle: HWND read GetHandle;
    property Left: Integer read GetLeft write SetLeft;
    property Top: Integer read GetTop write SetTop;
    property Width: Integer read GetWidth write SetWidth;
    property Height: Integer read GetHeight write SetHeight;
    property DlgItemID: DWord read GetDlgItemID write SetDlgItemID;
    property ColorLabel: string read GetColorLabel write SetColorLabel;
    property UseColor: string read GetUseColor write SetUseColor;
    property DropDownImg: WideString read GetDropDownImg write SetDropDownImg;
    property ColorImg: WideString read GetColorImg write SetColorImg;
    property PipetteCursor: WideString read GetPipetteCursor write SetPipetteCursor;
  end;
{$ENDREGION}
Delphi-Quellcode:
// ColorPicker
function CTRL_ColorPickerCreate(): ISkinColorPicker; stdcall; external dllfile;
Delphi-Quellcode:
        ColorPicker := CTRL_ColorPickerCreate;
        ColorPicker.ColorLabel := SKAERO_COLORLABEL;
        ColorPicker.Left := 20;
        ColorPicker.Top := 130;
        ColorPicker.Width := 200;
        ColorPicker.Height := 21;
        ColorPicker.DlgItemID := ID_COLORPICK; // SIEHE hier!
        SKAERO_SplitColorARGB(SKAERO_AEROCOLOR, Alpha, Red, Green, Blue);
        ColorPicker.UseColor := SKAERO_RGBtoHex(RGB(Red, Green, Blue));
        ColorPicker.DropDownImg := SKAERO_FOLDER + 'ColorPicker\BTN_DropDown.png';
        ColorPicker.ColorImg := SKAERO_FOLDER + 'ColorPicker\Color190.png';
        ColorPicker.PipetteCursor := SKAERO_FOLDER + 'ColorPicker\pipette.cur';
        ColorPicker.CreateWindow(TabHandle);
        SKAERO_SetAnchorMode(ColorPicker.Handle, ANCHOR_CENTER_HORZ_BOTTOM);
        SKAERO_SetZorder(ColorPicker.Handle, HWND_TOP);
DLL
Delphi-Quellcode:
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;
Delphi-Quellcode:
function ColorProc(WinHandle: HWND; Msg: UINT; wP: WParam; lP: LParam)
  : LRESULT; stdcall;
var
  PMis: PMeasureItemStruct absolute lP;
  PDis: PDrawItemStruct absolute lP;
  ClassName: array [0 .. 128] of Char;
  ps: TPaintstruct;
  hDCpaint, DC: HDC;
  wText: WideString;
  rc: TRect;
  imgW, imgH: Cardinal;
  p1, p2: TGPPoint;
  p: TPoint;
  strItem: string;
  Item: Integer;
  RGBcolor, Color: ColorRef;
begin
  FillChar(ClassName, SizeOf(ClassName), 0);

  case Msg of

    WM_MEASUREITEM:
      begin
        PMis := Pointer(lP);
        if PMis.CtlType = ODT_COMBOBOX then
        begin
          PMis.itemHeight := 16;
          Result := 1;
          Exit;
        end;
      end;

    WM_DRAWITEM:
      begin
        PDis := Pointer(lP);
        case PDis^.CtlType of

          ODT_COMBOBOX:
            begin

              SetBkMode(PDis.HDC, TRANSPARENT);
              if (PDis^.CtlID = SkinColorPicker.DlgItemID) then // Problem behoben! Was gibt es nun noch zu diskutieren?

Oh und Wunder es funktioniert sogar!

gruss

Geändert von EWeiss ( 9. Jul 2019 um 08:31 Uhr)
  Mit Zitat antworten Zitat