Autor Beitrag
Scotch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 6 Prof
BeitragVerfasst: Sa 24.12.05 02:06 
Hallo und Frohe Weihnachten an alle,

ich wollte mal fragen, ob jemand weiß, wie ich bei einem Grid (Strin bzw. Draw)
die Rahmenfarbe der selektierten Celle ändern kann?
Oder kennt jemand eine freie Komponente die das unterstützt?
Gruß Ingo
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: Sa 24.12.05 23:52 
Hallo,

einen Rahmen innerhalb des Focusrahmen kannst Du so in OnDrawcell zeichnen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if gdSelected in State then
    begin
    StringGrid1.Canvas.Pen.Color := clBlue;
    StringGrid1.Canvas.Rectangle(Rect.Left+1,Rect.Top+1,Rect.Right-1,Rect.Bottom-1);
    StringGrid1.Canvas.TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
    end;
end;

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


Delphi 6 Prof
BeitragVerfasst: Mo 26.12.05 15:25 
Hallo Lannes,

Danke für deine Antwort.
Leider habe ich schon Bilder in meinem Grid, ist einen Art 2d Level Editor.
Wenn ich deinen Code benutze habe ich einen Weißen Kasten mit blauen Rahmen.
Das währe auch schon so wie ich mir das vorgestellt habe, müße jetzt nur noch
Transparent sein so das mein Bild darunter angezeigt wird.
Die Drawgrid Kompo hat ja auch einen Focusrahmen leider ist der aber in grau
und bei meinen Bildern, die auch grau sind, sieht man den nicht.
In den Einstellungen habe ich auch nichts gefunden.
Ich habe auch schon dran gedacht mir einen eignen Komponenten zu erstellen,
die ich dann vom Drawgrid ableite würde, leider habe ich damit überhaupt keine
Erfahrung.

Gruß Ingo
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 26.12.05 23:58 
Hallo,

wie zeichnest Du die Bilder in das StringGrid?
Versuch mal den Code mit einzubauen:
ausblenden Delphi-Quelltext
1:
StringGrid1.Canvas.Brush.Style := bsClear;					

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


Delphi 6 Prof
BeitragVerfasst: Di 27.12.05 01:16 
Hallo Lannes,
ich benutzte mittlerweile das Drawgrid und zeichne mit folgendem Code meine Bilder ins Grid.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TDigiTrainAndCar.DrawGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var Bitmap_teil:TBitmap;
 begin
   Bitmap_teil:=TBitmap.Create;
   Teileliste.ImageList1.GetBitmap(spielfeld[Arow, Acol],Bitmap_teil);
   DrawGrid1.Canvas.Draw(Rect.Left,Rect.Top,Bitmap_teil);
   Bitmap_teil.Free;
end;

Wobei Spielfeld ein 2D Array of Integer ist, welches die zu zeichnenden Bild Nr. enthält.
Ich habe das Grid jetzt auch mal zwei Pixel größer gemacht und meine Bilder in die Mitte gezeichnet
und versucht deinen Beispielen einzubauen, hatte aber leider kein Erfolg.
Hier noch mal ein Bild wie es bei mir aussieht, in der Teileliste ist dein Erster Code mal eingebaut.
Wie man sieht ist das Feld nur grau eingefärbt und hat den blauen Rahmen.
Eigentlich müßte dort das Selbe Bild wie im Feld 1. links 6. v. oben sein.
user defined image
Im roten Kreis sieht man dass es bei DrawGrid Komponente einen gepunkteten Rahmen
für das Selektierte Feld gibt. Aber in rot oder blau würde das viel Besser aussehen.
Da ich später im Programm dann die Bilder je nach Programm Modus ändere, habe ich schon überlegt
fürs selektieren spezielle Bilder zu nehmen. Aber ich dachte ja dass es einfacher gehen müßte
Gruß Ingo
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 27.12.05 23:55 
Hallo,

den Focusrahmen im DrawGrid kannst du entfernen,
indem DefaultDrawing auf False gestellt wird.
Dann kann auch der blaue Rahmen an seine Stelle gezeichnet werden.
Damit das Bitmap bestehen bleibt musst Du es nach dem blauen Rahmen zeichnen.
Setzt Du dann noch GridLineWidth auf 0, dann müsste es passen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
   if gdSelected in State then
     begin
     Bitmap_teil:=TBitmap.Create;
     ImageList1.GetBitmap(MyArr[Arow, Acol],Bitmap_teil);
     DrawGrid1.Canvas.Pen.Color := clBlue;
     DrawGrid1.Canvas.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
     DrawGrid1.Canvas.Draw(Rect.Left+1,Rect.Top+1,Bitmap_teil);
     Bitmap_teil.Free;
     end
     else
       begin
       Bitmap_teil:=TBitmap.Create;
       ImageList1.GetBitmap(MyArr[Arow, Acol],Bitmap_teil);
       DrawGrid1.Canvas.Pen.Color := clWindow;
       DrawGrid1.Canvas.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
       DrawGrid1.Canvas.Draw(Rect.Left+1,Rect.Top+1,Bitmap_teil);
       Bitmap_teil.Free;
       end;

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


Delphi 6 Prof
BeitragVerfasst: Mi 28.12.05 22:51 
Danke damit geht es jetzt.
Gruß Ingo