Autor Beitrag
Apoc4lys3
Hält's aus hier
Beiträge: 7



BeitragVerfasst: So 12.12.04 19:02 
Hi,

kann man auf/in Komboboxen zeichnen :?: Wenn ja, wie mache ich das? Die Delphi-Hilfe hat mir bei dem Problem nicht geholfen. Ich will nämlich in die Felder der Kombobox mit verschiedenen Brush-Styles gezeichnete Rechtecke zeichnen. Hinterher soll der User einen auswählen.

Mfg Apoc4lyps3
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: So 12.12.04 19:28 
Nein, es ist nicht mölgich, in einer Combobox zu zeichen, da sie keine Canvas-Eigenschaft hat.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: So 12.12.04 19:35 
Aber der Vorfahre müsste eine haben (TCustomComboBox o.ä.) - soweit ich weiß

AXMD
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 12.12.04 19:40 
Zitat:
Nein, es ist nicht mölgich, in einer Combobox zu zeichen, da sie keine Canvas-Eigenschaft hat.
dann stimmt ja so nun gar nicht, die ComboBox hat sehr wohl ein Canvas-Objekt

Die Delphi-Hilfe hat folgendes geschrieben:
Wenn Style den Wert csOwnerDrawFixed oder csOwnerDrawVariable hat, tritt das Ereignis OnDrawItem ein. Wenn Style den Wert csOwnerDrawVariable hat, tritt zusätzlich das Ereignis OnMeasureItem ein.


mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: So 12.12.04 20:11 
na ja ok canvas hat sie doch sry hatte mich vertan, aba ich bekomme dann ne fehlermeldung dass 'Leinwand/Bild erlaubt kein Zeichnen'.....was ist das denn dann
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 12.12.04 20:15 
wann und wo (code?) bekommst du die Fehlermeldung (Style auf OwnerDraw?)

mfg
GSe

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Apoc4lys3 Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: So 12.12.04 20:21 
Nette Diskusion ;), helfen tut sie mir nur teilweise. Also wenn sie jetzt eine Canvas-Eigenschaft aht, wie bestimmte ich dann den Index auf welchen gezeichnet wird?
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: So 12.12.04 20:22 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
begin
with combobox1.canvas do
  begin
  moveto(0,0);
  lineto(10,10);
  end;
end;

dabei entsteht der obengenannte fehler
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 12.12.04 20:31 
imho kannst du nur im OnDrawItem Event zeichnen udn dazu muss der Style auf OwnerDraw sein

sollte beide Fragen beantworten

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Apoc4lys3 Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: So 12.12.04 21:42 
Hab in OnDrawItem
ausblenden Delphi-Quelltext
1:
2:
3:
4:
combobox2.canvas.brush.style:=bssolid;
combobox2.canvas.brush.COLOR:=CLRED;
Combobox2.Canvas.Rect(0,0,20,50);
//edit: war falsch, hab Combobox2.Canvas.Rectangle(0,0,20,50);

geschreiben, nichts passiert.

Wäre schön wenn mir einer etwas genauer sagen würde, wie ich das anstelle. Im gesammten Web scheint man dazu kein vernünftiges Beispiel zu finden. Oder kann mir jemand erklären, wie ich das jetzt anwende:

Zitat:
Die Methode DrawItem generiert das Ereignis OnDrawItem.

type TOwnerDrawState = set of (odSelected, odGrayed, odDisabled, odChecked odFocused);
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); virtual;

Beschreibung

Die Methode DrawItem wird immer dann aufgerufen, wenn ein Listeneintrag gezeichnet werden muß und Style auf csOwnerDrawFixed oder csOwnerDrawVariable gesetzt ist. Wenn eine Ereignisbehandlungsroutine für OnDrawItem definiert ist, generiert DrawItem das Ereignis OnDrawItem und übergibt die Parameter Index, Rect und State an die Ereignisbehandlungsroutine. Andernfalls füllt OnDrawItem das in Rect übergebene Rechteck und stellt den Text dar, der dem betreffenden Eintrag zugeordnet ist, wobei der Parameter State ignoriert wird.

Überschreiben Sie DrawItem, um die Listeneinträge in einer klassenspezifischen Weise zu zeichnen.
?

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.


Zuletzt bearbeitet von Apoc4lys3 am Mo 13.12.04 14:42, insgesamt 1-mal bearbeitet
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 12.12.04 22:12 
hast du den Style auf OwnerDraw?

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Apoc4lys3 Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mo 13.12.04 14:45 
Ja.

Wann wird das onDrawItem denn überhaupt ausgeführt? Muss ich das erst aufrufen? Wenn ich jetzt auf die Kombobox klicke wird nichts angezeigt, unabhängig von den größen des Rechtecks.