Autor Beitrag
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Fr 03.09.04 22:33 
Ich suche nach einer Möglichkeit einen Rahmen (weiß, 3 px stark) auf meinen Desktop zu zeichnen.

Genauer, ich bewege die Maus und der Cursor zeigt den Mittelpunkt eines z.B. 320 px breiten und 240 px hohen Rechtecks. Nun möchte ich, dass beim Bewegen der Maus ein Rahmen mir dieses Rechteck anzeigt und dabei nur an jeder Seite 3 px verdeckt, d.h. Innen ein 314 px x 234 px transparentes Rechteck vorhanden ist.

Kann mir jemand sagen, wie ich das am sinnvollsten machen kann?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Sa 04.09.04 10:35 
Sorry, aber ich verstehe nur den ersten Absatz deiner Frage (ist noch soo früh ;)). Also auf den Desktop zeichnen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var Canvas:TCanvas;
    H:HDC;
begin
 H:=CreateDC('DISPLAY',nil,nil,nil);
 Canvas:=TCanvas.Create;
 try
  Canvas.Handle:=H;

  Canvas.FillRect(Rect(0,0,Screen.Width,3)); //Oben
  Canvas.FillRect(Rect(0,0,3,Screen.Height)); // Links
  Canvas.FillRect(Rect(Screen.Width-3,0,Screen.Width,Screen.Height)); // Rechts
  Canvas.FillRect(Rect(0,Screen.Height-3,Screen.Width,Screen.Height)); //Unten
 finally
  Canvas.Free;
  DeleteDC(H);
 end;
end;
Das Zeichnen geht natürlich auch einfacher, aber es fällt mir momentan nicht ein. Ich denke, dass für dich eigentlich nur der Ansatz wichtig ist.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Sa 04.09.04 16:32 
Danke erstmal.

Der zweite Absatz sagt aus, dass das Formular ausgeblendet wird und dass durch das Bewegen der Maus der Rahmen verschoben werden soll.

Das Rahmenzeichnen klappt, nur ich finde kein Ereignis, dass beim Bewegen der Maus über den Bildschirm ausgelöst wird.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
master cool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 32

Win XP Home
D3 Prof
BeitragVerfasst: Sa 04.09.04 16:44 
wie löscht man den gezeichneten rahmen wieder?
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 05.09.04 10:49 
Indem du einfach dem Desktop mitteilst, dass er neugezeichnet werden muss. Ich weiß allerdings nicht, ob es sowas wie WM_INVALIDATE gibt, die du an das Handle senden kannst.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Johannes Maier
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 173

Win XP
D7 Prof
BeitragVerfasst: So 05.09.04 11:34 
@derDoc:
Ich würde es so machen: (achja, läuft das Programm im Hintergrund, oder auf dem Screen?
Plaziere ein "TApplicationEvents" auf dem Formular, und geh in seine Methode OnIdle:
ausblenden Delphi-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:
var
  dc: hDC;  //vll. auch als Variable in Form1 deklarieren, kenn mich stilmäßig nicht so aus ;)
  tr: Boolean = True;
  Canvas: TCanvas;

procedure TForm1.FormCreate(Sender: TObject);
begin
  dc := CreateDC('DISPLAY'nilnilnil);
end;

procedure TForm1.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
var
  p: TPoint;
begin
  Canvas := TCanvas.Create;
  Canvas.Handle := dc;
  while tr do begin
    GetCursorPos(p);
    Canvas.Rectangle(p.x - 50, p.y - 50, p.x + 50, p.y + 50); //oder so ... dann könnte es gehen
    // mehr Code
  end;
end;

procedure TForm1.FormClose(Sender: TObject);
begin
  Canvas.Free;
  DeleteDC(dc);
end;


Ich glaube hierbei gibt es noch das Problem, dass die Rechtecke, wenn sie einmal gezeichnet wurden, nicht wieder gelöscht werden. Hab jetzt so spontan keine Lösung parat dafür ...

_________________
MfG
Johannes ehem. jbmaier