TsCombobox

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #45584
    QStorm
    Participant

      No ideas?

      I would like to hightlight the selected / focused item using the current Alpha Skin properties.

      Thanks 🙂

      #45581
      QStorm
      Participant

        Hi again,

        Does anybody know how to get the styling properties (color, transparence etc.) from the current Alpha Skin?

        It's very urgent, I need a solution as soon as possible.

        Thanks 🙂

        Best regards

        QStorm

        #45653
        Support
        Keymaster

          Hello and I'm sorry for a delay.

          Why you not uses the TsFontComboBox component? Some features are not exists there?

          Here is a code of items drawing from TsFontComboBox :

          Code:
          procedure TsFontComboBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
          var
          Bmp, fBmp : TBitmap;
          aRect, BRect : TRect;
          TmpColor : TColor;
          TmpFontClass : TFontClass;
          ts : TSize;
          sNdx : integer;
          CI : TCacheInfo;
          DrawStyle : longint;
          begin
          TmpFontClass := nil;
          Bmp := nil;
          if (Index >= 0) and (Index < Items.Count) and (Items.Objects[Index] nil) then begin
          TmpFontClass := TFontClass(Items.Objects[Index]);
          fBmp := FBitmaps[ord(TmpFontClass.FntType)];
          fBmp.Transparent := True;
          aRect := Classes.Rect(0, 0, fBmp.Height, fBmp.Width);
          end
          else fBmp := nil;
          if SkinData.Skinned then begin
          Bmp := CreateBmp32(WidthOf(Rect), HeightOf(Rect));
          Bmp.Canvas.Font.Assign(Font);
          if odComboBoxEdit in State then CI := MakeCacheInfo(SkinData.FCacheBmp, Rect.Left, Rect.Top) else begin
          CI.Bmp := nil;
          CI.Ready := False;
          CI.FillColor := Color;
          end;
          if (odSelected in State) then begin
          CI.Bmp := nil;
          CI.Ready := False;
          CI.FillColor := Color;
          sNdx := SkinData.SkinManager.GetSkinIndex(s_Selection);
          if sNdx < 0
          then FillDC(Bmp.Canvas.Handle, Classes.Rect(0, 0, Bmp.Width, Bmp.Height), SkinData.SkinManager.GetHighLightColor(odFocused in State))
          else PaintItem(sNdx, s_Selection, CI, True, integer(odFocused in State), Classes.Rect(0, 0, Bmp.Width, Bmp.Height), Point(0, 0), Bmp, SkinData.SkinManager)
          end
          else begin
          sNdx := -1;
          if CI.Ready
          then BitBlt(Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height, CI.Bmp.Canvas.Handle, CI.X, CI.Y, SRCCOPY)
          else FillDC(Bmp.Canvas.Handle, Classes.Rect(0, 0, Bmp.Width, Bmp.Height), Color);
          end;
          if Assigned(TmpFontClass) then begin
          brect := classes.Rect(0, 0, Bmp.Height, Bmp.Height);
          Bmp.Canvas.Draw(bRect.Left, bRect.Top, fBmp);
          aRect.Right := Bmp.Width;
          aRect.Left := brect.right;
          if DrawFont then Bmp.Canvas.Font.Name := TmpFontClass.FntName;
          DrawStyle := DT_NOPREFIX or DT_EXPANDTABS or DT_SINGLELINE or DT_VCENTER or DT_NOCLIP;
          InflateRect(aRect, -1, 0);
          if sNdx = -1 then begin
          if odSelected in State then Bmp.Canvas.Font.Color := SkinData.SkinManager.GetHighLightFontColor(odFocused in State) else begin
          if ControlIsActive(SkinData) and (SkinData.SkinManager.gd[SkinData.SkinIndex].States > 1)
          then Bmp.Canvas.Font.Color := SkinData.SkinManager.gd[SkinData.SkinIndex].HotFontColor[1]
          else Bmp.Canvas.Font.Color := SkinData.SkinManager.gd[SkinData.SkinIndex].FontColor[1];
          end;
          Bmp.Canvas.Brush.Style := bsClear;
          AcDrawText(Bmp.Canvas.Handle, TmpFontClass.FntName, aRect, DrawStyle);
          end
          else WriteTextEx(Bmp.Canvas, PChar(TmpFontClass.FntName), True, aRect, DrawStyle, sNdx, (odFocused in State), SkinData.SkinManager);
          end;
          BitBlt(Canvas.Handle, Rect.Left, Rect.Top, Bmp.Width, Bmp.Height, Bmp.Canvas.Handle, 0, 0, SRCCOPY);
          FreeAndNil(Bmp);
          end
          else begin
          if odSelected in State then TmpColor := ColorToRGB(clHighLight) else TmpColor := ColorToRGB(Color);
          FillDC(Canvas.Handle, Rect, TmpColor);
          if Assigned(TmpFontClass) then begin
          brect := classes.Rect(rect.left, rect.top, rect.bottom – rect.top + rect.left, rect.bottom);
          Canvas.Draw(bRect.Left, bRect.Top, fBmp);
          Rect.Left := Rect.Left + brect.right;
          if DrawFont then Canvas.Font.Name := TmpFontClass.FntName;
          if odSelected in State then Canvas.Font.Color := ColorToRGB(clHighlightText) else Canvas.Font.Color := Font.Color;

          GetTextExtentPoint32(Canvas.Handle, PChar(TmpFontClass.FntName), Length(TmpFontClass.FntName), ts);
          Canvas.Brush.Style := bsClear;
          Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + (HeightOf(Rect) – ts.cy) div 2, TmpFontClass.FntName);
          end;
          end;
          end;

          #54348
          Jimy
          Participant

            very thanks! 😐

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.