Autor Beitrag
Cix6
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Sa 17.06.06 14:40 
hallo,


ich habe eine combobox mit mehreren einträgen,

jetzt möchte ich nicht sichtbar jeden eintrag dieser combobox mit einer url versehen, wie kann ich das tun?
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Sa 17.06.06 14:50 
du meinst, dass, wenn man einen Eintrag auswählt, eine Seite geöffnet wird?
hoffe ich hab dich richtig verstanden :roll:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ComboBox1Click(Sender: TObject);
const
 AURL: Array[0..2of String = ('www.google.de','www.wikipedia.de','www.delphi-forum.de');
begin
 Shellexecute(Handle,'open',PChar(AURL[Combobox1.ItemIndex]),nil,nil,SW_SHOW);
end;
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Sa 17.06.06 14:58 
ja, aber ich weiß die werte nicht, die werden dynamisch eingetragen...sie müssen auch global verfügbar sein, wie die items der combobox...mit nem array würde es zwar gehen, aber dann müsste ich es global machen.
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Sa 17.06.06 15:02 
also wie gesagt, ich fülle die combobox mit daten die ich nicht kenne..also die anzahl der einträge ist dynamisch...jetzt möchte ich zu jedem eintrag noch nen wert zuweisen, der zwar in der combobox nicht angezeigt wird, aber dazugehört.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Sa 17.06.06 15:08 
woraus ergeben sich denn die werte? mit einem dynamischen array wirst du ja vermutlich auf alle fälle arbeiten müssen.
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Sa 17.06.06 16:02 
Dafür gibts die EIgenschaft Objects in TStringList! In etwa so musst du die Werte hinzufügen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  PString = ^string;

procedure TForm1.AddToList(Anzeige, URL: string);
var
  ptrString     : PString;
begin
  New(ptrString);
  ptrString^ := URL;
  ComboBox1.Items.AddObject(Anzeige, TObject(ptrString));
end;


Auslesen kannst du sie dann mit:

ausblenden Delphi-Quelltext
1:
  showmessage(pString(ComboBox1.Items.Objects[ComboBox1.ItemIndex])^);					



MrSaint


EDIT: Natürlich nicht vergessen, die Strings wieder freizugeben!

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Fr 30.06.06 12:40 
Wie gibt man die Strings wieder frei

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 30.06.06 13:39 
mit Dispose(); ;)
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Fr 28.07.06 16:26 
Ich habe auch die Lösung von MrSaint ebenfalls mal benötigt. Bei meinem unsichtbaren Eintrag handelt es sich um eine ID.

Jetzt habe ich diese ID als String. Möchte jetzt den Eintrag auswählen der mit dem unsichtbaren Eintrag in der Combobox und meiner String-Variablen übereinstimmt.

Wie mach ich das denn jetzt.

Habe mal folgendes versucht aber ohne Erfolg:
ausblenden Delphi-Quelltext
1:
Combobox2.Items.Objects[ComboBox2.ItemIndex] := StrToInt(ID);					

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: So 30.07.06 13:27 
Weiß niemand wie das funktioniert

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Peinhard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39



BeitragVerfasst: So 30.07.06 15:44 
Objects nimmt keinen Integer, sondern ein TObject - und das ist 'in Wahrheit' ein Zeiger auf das Objekt - an. Du mußt also einmal mehr 'casten':

ausblenden Delphi-Quelltext
1:
Combobox2.Items.Objects[ComboBox2.ItemIndex] := Pointer(StrToInt(ID));					


Auslesen mit

ausblenden Delphi-Quelltext
1:
ID := IntToStr(LongInt(Combobox2.Items.Objects[ComboBox2.ItemIndex]));					


Der Typecast funktioniert, weil beides Strukturen der Größe 4 (byte) sind und sich so Zeiger und Integer aufeinander abbilden lassen. Da Delphi bzw Pascal aber strenge Typprüfungen durchführen, muß diese Abbildung durch den Typecast explizit gemacht werden, da ansonsten der Compiler die Arbeit verweigert ('Inkompatible Typen - Integer und TObject').
SnuffMaster23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 02.08.06 14:48 
Wieso nicht einfach die Combobox mit den sichtbaren Texten und eine TStringList für die URLs?
Dann hast du fast den gleichen Code für die Combobox und die URL-Liste um Einträge hinzuzufügen/entfernen.

_________________
Nichts ist wahr - Alles ist erlaubt