Autor Beitrag
cerebrum
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 01.10.02 13:33 
Hallo!
Wie kann ich die Pen-Styles des Canvas-Objekts in eine ComboBox einfügen, so dass der Benutzer diese auswählen kann?
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 01.10.02 14:09 
Hi
nimm eine ComboBox und füge als Items die zahlen 0 bis 4 ein. Style der ComboBox muss csOwnerDrawFixed sein.
Dann erstellst du eine Ereignisroutine für OnDrawItem:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TfrmMain.cbxDrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
   with (Control as TcomboBox).Canvas do begin
       case Index of
           0: Pen.Style := psSolid;
           1: Pen.Style := psDash;
           2: Pen.Style := psDot;
           3: Pen.Style := psDashDot;
           4: Pen.Style := psDashDotDot;
       end;
       if  odSelected in State then
           Pen.Color := clHighLightText
       else
           Pen.Color := clWindowText;
       FillRect(rect);
       MoveTo(Rect.Left,Rect.Bottom - ((Rect.Bottom - Rect.Top) div 2));
       LineTo(Rect.Right, Rect.Bottom - ((Rect.Bottom - Rect.Top) div 2));
   end;
end;


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
cerebrum Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 01.10.02 15:25 
Danke, klappt einwandfrei!! :dance2: