Autor Beitrag
Killi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Sa 05.10.02 01:53 
Hi!

Ich hab n kleines Problem...ich wollte mir (faul wie ein Programmierer ist) ein Programm machen, das per Autostrat immer mitläuft, so groß wie mein Desktop ist und mir per ZUFALL schöne Bildchen von weiblichen Gestalten per Canvas.Draw bringt - also wie der normale Desktop ("als Webseite, ohne Symbole") - jetzt hab ich nur das Problem, dass bei Programm-AUFRUF zwar die Zufallszahl angezeigt wird (zum Test), das Bild aber nicht gezeichnet wird - per Doppelklick gehts dann (wollte, dass sich das Bild bei nicht gefallen per Doppelklick wieder ändert) - hier der ganze Code:

ausblenden volle Höhe Quelltext
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:
var
  FDesktop: TFDesktop;
  Bitmap: TBitmap;

implementation

{$R *.DFM}

procedure TFDesktop.Draw;
var
   i: integer;
begin
     // Bild per Zufall aussuchen und anzeigen
     Randomize;
     i:= Random(5);
     Label1.Caption:= IntToStr(i);
     Bitmap.LoadFromFile('C:\' + IntToStr(i) + '.bmp');
     Canvas.Draw(0, 0, Bitmap);
end;

procedure TFDesktop.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     // Speicherplatz freigeben
     Bitmap.Free;
end;

procedure TFDesktop.FormDblClick(Sender: TObject);
begin
     // Bei Doppelklick auf Desktop anderes Bild anzeigen lassen
     Draw;
end;

procedure TFDesktop.FormShow(Sender: TObject);
var i:integer;
begin
     // Wenn Programm startet, Bild anzeigen
     Draw;
end;

procedure TFDesktop.FormCreate(Sender: TObject);
begin
     Bitmap:= TBitmap.Create;
end;


Was mach ich am Anfang falsch??? Wieso wird es beim 1. Starten nicht angezeigt?
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Sa 05.10.02 10:04 
versuchs doch mla mit 'draw'in formcreate.
Killi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Sa 05.10.02 10:41 
Danke, schon probiert - dann steht in FormCreate
ausblenden Quelltext
1:
2:
     Bitmap:= TBitmap.Create;
     Draw;

und es geht trotzdem nicht...ich blick nicht, warum! Die TBitmap ist doch schon erzeugt worden usw, wieso zeigt er es mir dann nicht?
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Sa 05.10.02 13:52 
bei mei funzt es, wenn ich zusätzlich noch ne onPaint Prozedure mit 'draw' dareinsetzte.

probiers mal :-)