Autor Beitrag
Baphomet
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20


Delphi 7
BeitragVerfasst: So 17.09.06 11:52 
hey leute
also ich hab ein Zeichenprogramm in der Schule gemacht

gezeichnet wird in ein DrawGrid

Bei mir ist nun das Prob aufgetreten, dass das Programm, wenn ich eine Cell einfärben will, immer den den unteresten Pixel und den Pixel ganz rechts weglässt
Also, sagen wir meine Zelle ist 2 Pixel breit, dann lässt das Programm 3 Pixel weg, nämlich, den ganz unten, den unten links in der Ecke und den oben reches.

ich kann mir nicht vorstellen, an was es liegen könnte

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TMainForm.DrawGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var Zeile, Spalte, i, j : Integer;
begin
  //Zelle Färben
  If Button = MBLeft then
   begin

    If Form2.RBKaestchen.Checked = true then
    begin
     DrawGrid1.Canvas.Pen.Style:= psclear;
     DrawGrid1.Canvas.Brush.Color:= hgColor;
     DrawGrid1.Canvas.Brush.Style:= bsSolid;
     DrawGrid1.MouseToCell(X, Y, Spalte, Zeile); //Koordinaten der Zelle
     DrawGrid1.Canvas.Rectangle(DrawGrid1.CellRect(Spalte, Zeile)); //Einfärben der Zelle
     Farbbelegung[Spalte,Zeile]:= hgcolor; //Array
    end



wär cool wenn jemand die Antwort wüsste

greetz
Baphomet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20


Delphi 7
BeitragVerfasst: Mo 18.09.06 12:32 
weiß niemand ne antwort?

is wirklich wichtig!

und ich bekomms einfach net hin
falls es jemandem hilft, ich schick auch den ganzen programmtext...

greetz
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 18.09.06 12:42 
Moin!

Ich rate mal: es handelt sich um das Focus-Rechteck des Controls? :nixweiss:

Warum zeichnest du nicht einfach in ein TImage... ? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Baphomet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20


Delphi 7
BeitragVerfasst: Mo 18.09.06 13:37 
Also es soll ein Zeichenprogamm sein

und wir hatten die aufgabe (schule), das einem drawgrid zu verwirklichen

wenn man jetzt auf eine Zelle des drawgrid klickt, soll diese eingefärbt werden

die Zelle ist dann das Rechteck

ich hab halt das prob, dass immer die unterste Reihe und die ganz rechte Reihe von Pixeln weggelassen wird...

also ich hatte vor, die zelle 1 pixel hoch und ein pixel breit zu machen, aber das funktioniert nicht, weil dann gar nicht in die Zelle gezeichnet wird

ich hoffe dass ist jetzt verständlich ausgedrückt...

greet
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 18.09.06 14:50 
Hallo,

vergrößer doch das zu zeichnende Rechteck und übergib Rectangle die geänderten Koordinaten.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var aRect : TRect;
begin
//...
  aRect := DrawGrid1.CellRect(X, Y, Spalte, Zeile);
  DrawGrid1.Canvas.Rectangle(aRect.Left,aRect.Top,aRect.Right+1,aRect.Bottom+1);
//...


Und noch ein Tipp, zum Zeichnen im DrawGrid(StringGrid) ist das Ereignis OnDrawCell IMHO besser geeignet. Schau Dich mal hier im Forum danach um. :wink:

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Baphomet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20


Delphi 7
BeitragVerfasst: Mo 18.09.06 18:51 
hey

mit TRect funktioniert das aber net
:-(


greetz
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 19.09.06 08:51 
Hallo,

was funktioniert mit TRect nicht, bzw. wie wirkt sich die Fehlfunktion aus?

Wie sieht dein Code jetzt aus?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )