| Autor |
Beitrag |
adri12
Hält's aus hier
Beiträge: 10
|
Verfasst: Fr 16.02.07 12:34
Hi Leute!
Ich versuche gerade meinem kleinen Bruder ein Flaggenprogramm zu basteln.
Bei diesem soll man zuerst einmal über eine Combobox verschiedene Erteile auswählen können. Dann sollen die Länder dieses Erteils in einer Radiogroup zu sehen sein, jeweils mit einem Radiobutton.(Bis dahin habe ich es noch) Dann soll man, wenn man als Erdteil Europa ausgewählt hat und den ersten Radiobutton angeklickt hat etwas anderes Bild, das in der mitte der form ist, erscheinen, als wenn man als Erdteil Nordamerika ausgewählt hat und das erste Land angeklickt ist. Das was ich bisher habe habe ich mal hier beigefügt: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65:
| unit flaggen1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) ComboBox1: TComboBox; RadioGroup1: TRadioGroup; GroupBox1: TGroupBox; Image1: TImage; procedure ComboBox1Change(Sender: TObject); private public end; const a= 'numa.txt'; b= 'k.txt'; c= 's.txt'; d= 'wsus.txt'; e= 'nume.txt'; f= 'ouse.txt'; g= 'va.txt'; h= 'wusa.txt'; i= 'ousoa.txt'; j= 'na.txt'; k= 'wa.txt'; l= 'zuoa.txt'; m= 'sa.txt'; n= 'oua.txt';
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ComboBox1Change(Sender: TObject); begin
case ComboBox1.ItemIndex of 0: Form1.RadioGroup1.Items.LoadFromFile(a); 1: Form1.RadioGroup1.Items.LoadFromFile(b); 2: Form1.RadioGroup1.Items.LoadFromFile(c); 3: Form1.RadioGroup1.Items.LoadFromFile(d); 4: Form1.RadioGroup1.Items.LoadFromFile(e); 5: Form1.RadioGroup1.Items.LoadFromFile(f); 6: Form1.RadioGroup1.Items.LoadFromFile(g); 7: Form1.RadioGroup1.Items.LoadFromFile(h); 8: Form1.RadioGroup1.Items.LoadFromFile(i); 9: Form1.RadioGroup1.Items.LoadFromFile(j); 10:Form1.RadioGroup1.Items.LoadFromFile(k); 11:Form1.RadioGroup1.Items.LoadFromFile(l); 12:Form1.RadioGroup1.Items.LoadFromFile(m); 13:Form1.RadioGroup1.Items.LoadFromFile(n); end; end; end. |
|
|
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Fr 16.02.07 12:45
Ja, und wo ist das Problem
Du kannst z.B. das machen:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68:
| unit flaggen1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) ComboBox1: TComboBox; RadioGroup1: TRadioGroup; GroupBox1: TGroupBox; Image1: TImage; procedure ComboBox1Change(Sender: TObject); private public end;
const a= 'numa.txt'; b= 'k.txt'; c= 's.txt'; d= 'wsus.txt'; e= 'nume.txt'; f= 'ouse.txt'; g= 'va.txt'; h= 'wusa.txt'; i= 'ousoa.txt'; j= 'na.txt'; k= 'wa.txt'; l= 'zuoa.txt'; m= 'sa.txt'; n= 'oua.txt';
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ComboBox1Change(Sender: TObject); begin
case ComboBox1.ItemIndex of 0: Form1.RadioGroup1.Items.LoadFromFile(a); 1: Form1.RadioGroup1.Items.LoadFromFile(b); 2: Form1.RadioGroup1.Items.LoadFromFile(c); 3: Form1.RadioGroup1.Items.LoadFromFile(d); 4: Form1.RadioGroup1.Items.LoadFromFile(e); 5: Form1.RadioGroup1.Items.LoadFromFile(f); 6: Form1.RadioGroup1.Items.LoadFromFile(g); 7: Form1.RadioGroup1.Items.LoadFromFile(h); 8: Form1.RadioGroup1.Items.LoadFromFile(i); 9: Form1.RadioGroup1.Items.LoadFromFile(j); 10:Form1.RadioGroup1.Items.LoadFromFile(k); 11:Form1.RadioGroup1.Items.LoadFromFile(l); 12:Form1.RadioGroup1.Items.LoadFromFile(m); 13:Form1.RadioGroup1.Items.LoadFromFile(n); end; end;
Image1.Picture.LoadFromFile(RadioGroup1.Items[RadioGroup1.ItemIndex].'jpg'); |
end.
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
JayEff
      
Beiträge: 2971
Windows Vista Ultimate
D7 Enterprise
|
Verfasst: Fr 16.02.07 12:53
Hallo und  in der Entwickler-Ecke!
Freut mich, dass du zu uns gefunden hast.
Eins vorne weg, deine Formatierung ist grauenhaft unübersichtlich, du solltest dir dringend Absätze angewöhnen, da du sonst schnell den Überblick verlierst. Ich werde mal deinen Code überarbeiten, so dass er kürzer und praktischer ist.
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| Const txts: Array[0..13] Of String = ('numa.txt', 'k.txt', 's.txt', 'wsus.txt', 'nume.txt', 'ouse.txt', 'va.txt', 'wusa.txt', 'ousoa.txt', 'na.txt', 'wa.txt', 'zuoa.txt', 'sa.txt', 'oua.txt'); Implementation
{$R *.dfm}
Procedure TForm1.ComboBox1Change(Sender: TObject); Begin Form1.RadioGroup1.Items.LoadFromFile(txts[ComboBox1.ItemIndex]); End; |
Ansonsten hat ja Marco schon in der letzten Zeile seines Codes einen Vorschlag gemacht.
Als kleinen Tipp für die Formatierung empfehle ich dir DELFOREXP, ein Programm, das sich in die Delphi IDE einfügt und dort per STRG+D aufrufbar ist. Es kann deinen Quelltext völlig automatisch Formatieren und dir Arbeit abnehmen - denk aber daran, dass du auch selbst fähig sein solltest, sinnvoll zu formatieren!
|
|
adri12 
Hält's aus hier
Beiträge: 10
|
Verfasst: Fr 16.02.07 13:21
Titel: Vielen Dank
Es funktioniert, jedoch nur mit Bitmaps.
(ich musste den code umändern in Image1.Picture.LoadFromFile(RadioGroup1.Items[RadioGroup1.ItemIndex]+'.bmp');)
Aber trotzdem vielen Dank für die schnelle Hilfe.
|
|
JayEff
      
Beiträge: 2971
Windows Vista Ultimate
D7 Enterprise
|
Verfasst: Fr 16.02.07 13:23
Um JPGs zu verwenden, musst du lediglich unter uses die Unit jpeg einbinden.
_________________ >+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
|
|
|