Autor Beitrag
Mr_T
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP, Fedora Core RC 1

BeitragVerfasst: Sa 12.07.03 22:42 
*so langsam verstehe, worum es geht*
Ich habe nune infach mal ne Mischung aus Mimi's und meinem Code gebacken und das ist dabei rausgekommen:
ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
function farbe (basisfarbe : integer; stufe :byte) : integer;
var
hexcol : string;
r,g,b : integer;
rn,gn,bn : integer;
const
factor = 10;
begin
hexcol := inttohex(basisfarbe,6);
r := strtoint('$'+copy(hexcol,5,2));
g := strtoint('$'+copy(hexcol,3,2));
b := strtoint('$'+copy(hexcol,1,2));
rn := r-(factor*stufe);
gn := g-(factor*stufe);
bn := b-(factor*stufe);
if rn < 0 then rn := 0;
if gn < 0 then gn := 0;
if bn < 0 then bn := 0;
result := strtoint('$' + inttohex(bn,2) + inttohex(gn,2) + inttohex(rn,2));
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
form2.show;
form3.show;
form4.show;

for i := 0 to screen.formcount-1 do
begin
 screen.Forms[i].Color := farbe(clInfoBK,i);
end;

end;


Wie man gut an der Buttonklick-Procedure erkennen kann, habe ich es (erfolgreich) mit 4 Forms getestet.... blos: das 4. formular (welches ja das Vorderste ist), wird am hellsten gezeichnet... also muss man (scheinbar) drauf achten, in welcher Reihenfolge die Fenster übereinander liegen....

_________________
Es gibt 10 Arten Binäre Zahlen zu interpretieren: 0 und 1
Wer nicht kämpft, hat schon verloren!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 12.07.03 23:00 
das anzeigen der formulare würde ich auch in der for schleife machen wenn er 250 forms so aufrufen sollten kann es länger dauern:)
daher liber ne for schleife, werde dein code mal ebend testen :)

_________________
MFG
Michael Springwald, "kann kein englisch...."
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 12.07.03 23:06 
seltsamm, habe es ebend getestet und nur mit folgenden code hat es funktioniert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure ShowForms;
var
  i:Integer;
begin
  Screen.Forms[0].Show;
  Screen.Forms[1].Show;
  Screen.Forms[2].Show;
  Screen.Forms[3].Show;
  Screen.Forms[4].Show;        
  
  for i:=Screen.FormCount -1 DownTo 0 do begin
    Screen.Forms[i].Show;
    Screen.Forms[i].Color:=farbe(clInfoBK,i); ;
  end;

end;

procedure TForm1.FormShow(Sender: TObject);
begin
  ShowForms
end;

Screen.Forms[i].Show;
irngewie funktioniert das .show nicht richtig.... teste einfach mal rum, aber ich glaube das ware ist das auch nicht Mr_T
nimm mal 6 fomulaer oder 250 dann siehst du es am besten, ich habe jetzt nur 6 genommen.

_________________
MFG
Michael Springwald, "kann kein englisch...."
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 13.07.03 10:33 
Ich will nicht 250 "Schattierungen". Die maximale Anzahl ist höchstens 10. Und das halt mit 25 Varianten. Probiere das da mal aus.

_________________
Gruß
Hansa
Mr_T
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP, Fedora Core RC 1

BeitragVerfasst: So 13.07.03 11:05 
weshalb das mit den screen.forms[i].show nicht funzt, kann ich mir denken....
das "array of tform" welches ja "screen.forms" ist, beinhält nur die geöffneten
Formulare, die zur anwendung gehören... alle verstecketen forms (welche wir ja alle anzeigen wollen) stehen da also noch nicht drinne in der Liste... da müssen wir uns was besseres einfallen lassen....

_________________
Es gibt 10 Arten Binäre Zahlen zu interpretieren: 0 und 1
Wer nicht kämpft, hat schon verloren!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 13.07.03 11:16 
eine andere lösung wärhe: alle forms in ein externen array zu speichern. z.b. so:
forms:array[0.249] of TForm.
das sollte dann funktionieren.

_________________
MFG
Michael Springwald, "kann kein englisch...."
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 13.07.03 12:56 
Mr_T hat folgendes geschrieben:
weshalb das mit den screen.forms[i].show nicht funzt, kann ich mir denken....


Ihr denkt an dem Thema vorbei. Habe mich jetzt nicht an den 250 Forms aufgehalten mit arrays, FOR usw., sondern Color und Show explizit aufgerufen, mit dem Code von Mr_T. Geht nicht. Weiß auch nicht warum.

Und nochmals zum Thema 8) : Form1 geht auf, mit Farbe clinfoBK, die Unterform wird auf Wunsch (Tastendruck,Mausklick) geöffnet. Diese hat wieder eine Unterform, die wiederum auf Wunsch geöffnet wird. Um zu sehen wie "tief" ich in dem Programm drin bin soll das etwas optisch sichtbar sein. Die nächste Unterform soll dann noch dunkler sein. Und das ganze brauche ich an 10 Stellen mit maximal 10 Ebenen. Im Endeffekt sind es mehr als 250 Forms. Da dies sehr mühselig ist, das von Hand einzustellen, habe ich eine eigene Form, die so umgebaut ist, daß ich im OI die "Ebene" einstellen kann.

Also nochmals im Klartext. Ich lege "MeineForm" in das Projekt, stelle die Ebene ein, z.B. 1,2,3,4,5.... und setze die Farbe in Abhängigkeit von den im OI eingestellten Ebene ein. z.B.:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
case Ebene of
  1 : MeineForm.Color := clInfoBK
  2 : MeineForm.Color := clInfoBK -+ ??????`
....
end;


Dann brauche ich im OI nur noch die Ebene zu definieren und fertig ist.

_________________
Gruß
Hansa
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 13.07.03 14:30 
Zitat:

Und nochmals zum Thema : Form1 geht auf, mit Farbe clinfoBK, die Unterform wird auf Wunsch (Tastendruck,Mausklick) geöffnet. Diese hat wieder eine Unterform

das machst du 250 mal ?
geht doch viel schneller wenn du das in einer for schleife machst.

Zitat:

Also nochmals im Klartext. Ich lege "MeineForm" in das Projekt, stelle die Ebene ein, z.B. 1,2,3,4,5.... und setze die Farbe in Abhängigkeit von den im OI eingestellten Ebene ein. z.B.:

davon reden wir doch die ganze zeit.....

_________________
MFG
Michael Springwald, "kann kein englisch...."
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 13.07.03 19:50 
Ihr versteht mich immer noch nicht. Ich gebe eine Zahl ein im OI in meiner Komponente. Da ist ein Feld "Ebene". Also 1 ist höchste und dann 2,3,4 ,5.... Ebene 1 = CLInfoBK, 2 dunkler, 3 noch dunkler, 4 noch etwas mehr. So weit, bis nichts mehr zu lesen ist.

_________________
Gruß
Hansa
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 13.07.03 20:39 
hansa hat folgendes geschrieben:
Ihr versteht mich immer noch nicht. Ich gebe eine Zahl ein im OI in meiner Komponente. Da ist ein Feld "Ebene". Also 1 ist höchste und dann 2,3,4 ,5.... Ebene 1 = CLInfoBK, 2 dunkler, 3 noch dunkler, 4 noch etwas mehr. So weit, bis nichts mehr zu lesen ist.

ok, Frank auch mal nen versuch unternimmt

ausblenden volle Höhe 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:
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:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
unit Unit23;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TPixelBMP24 = packed record
    R: byte;
    G: byte;
    B: byte;
end;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button2: TButton;
    Button1: TButton;
    procedure ListBox1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    Grundfarbe: longint;
    Ebene: integer;
    Procedure SetzeFormFarbe;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
function BMPRGBtoYUV(rgb: TPixelBMP24): TPixelBMP24;
//von der DSlibrary von delphi-source.de
var y,u,v:longint;
begin
  y := rgb.G*150 + rgb.B*29 + rgb.R*77// 0.587 x 256, 0.114 x 256, 0.299 x 256
  u := (rgb.B shl 8 - y) * 144;         // 0.564 x 256
  v := (rgb.R shl 8 - y) * 183;         // 0,713 x 256
  Result.G :=y shr 8;
  Result.B :=u shr 16 + $80;
  Result.R :=v shr 16 + $80;
end;

function BMPYUVtoRGB(yuv: TPixelBMP24): TPixelBMP24;
//von der DSlibrary von delphi-source.de
var temp: integer;
begin
  temp := yuv.G + (yuv.B - $80) * 256 div 144  ;
  if temp > 0 then Result.B:=temp else Result.B:=0;
  if temp > 255 then Result.B:=255;

  temp := yuv.G + (yuv.R - $80) * 256 div 183  ;
  if temp > 0 then Result.R:=temp else Result.R:=0;
  if temp > 255 then Result.R:=255;

  temp := (yuv.G shl 8 - Result.B*29 - Result.R*77div 150;
  if temp > 0 then Result.G:=temp else Result.G:=0;
  if temp > 255 then Result.G:=255;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  if Listbox1.ItemIndex<>-1 then
    begin
      ebene:=Listbox1.ItemIndex;
      SetzeFormFarbe;
    end;
end;

procedure TForm1.SetzeFormFarbe;
Var _rgb:TPixelBMP24;
    yuv : TPixelBMP24;
    temp:integer;
    y,u,v,r,g,b:byte;
begin

  //Fabrbe in RGB werte aufsplitten
  _rgb.r:=GetRValue(Grundfarbe);
  _rgb.g:=GetGValue(Grundfarbe);
  _rgb.b:=GetBValue(Grundfarbe);
  //Farbe in Yuv - werte ändern
  yuv:=BMPRGBtoYUV(_rgb);

  temp:=yuv.G-Ebene*20;  //Helligkeitsabstufung an hand der ebene
  if temp<0 then temp:=0;
  yuv.G:=temp;

  _rgb:=BMPYUVtoRGB(yuv); //und wieder zurück zu RGB
  //Formfarbe setzen
  Color := rgb(_rgb.R,_rgb.G,_rgb.B);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  //beispiel 1
  Grundfarbe:=rgb(255,255,0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  //beispiel 2
  Grundfarbe:=colortorgb(clInfoBk);
  //colortorgb ist wichtig, wenn du Tcolor werte verwendest
end;

procedure TForm1.FormCreate(Sender: TObject);
Var i:integer;
begin
  //zum ausprobieren
  for i:=0 to 9 do
    ListBox1.Items.Add('Ebene '+inttostr(i));
end;

end.

2 Buttons und eine Listbox auf Formular zum testen.
erst eine der Buttons anklicken um die Grundfarbe zu setzen, dann in der Listbox die Ebene wählen und die Formfarbe wird anhand der Ebene abgedunkelt

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 13.07.03 21:15 
@hansa
dann sende uns doch einfach mal dein projekt oder so, damit wir dich besser verstehen....

_________________
MFG
Michael Springwald, "kann kein englisch...."
TheD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 27



BeitragVerfasst: So 13.07.03 21:30 
@Keldorn,

willst Du jetzt den zweiten Weltkrieg simulieren oder hast Du was grösseres vor?
Wie wärs mit einer zwei zeilen Lösung?

ausblenden 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:
program Project1;

uses
  Forms, Windows, System,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2},
  Unit3 in 'Unit3.pas' {Form3},
  Unit4 in 'Unit4.pas' {Form4};

{$R *.res}

var
  i: Integer;
begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm4, Form4);

  for i := 1 to Screen.FormCount -1 do
  begin
    Screen.Forms[i].Color := RGB(i*10, i*20, i*30);
  end;

  Application.Run;
end.


Ciao...

_________________
Bis dannn... TheD!
Wer im Schlachthaus sitzt, sollte nicht mit Schweinen werfen! ;)
TheD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 27



BeitragVerfasst: So 13.07.03 21:32 
Für das immernoch zu hoch ist, das ist die Projektdatei, also die .dpr. ;)

Ciao...

_________________
Bis dannn... TheD!
Wer im Schlachthaus sitzt, sollte nicht mit Schweinen werfen! ;)
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 13.07.03 22:05 
Thx @ DerDoc

Das da geht jetzt soweit. Aber nur, wenn ich eine der RGB-Farben benutze. Was ist, falls der Wert über 255 hinausgeht ? Fängt das wieder bei Null an ?

_________________
Gruß
Hansa
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 14.07.03 09:03 
TheD hat folgendes geschrieben:
@Keldorn,

willst Du jetzt den zweiten Weltkrieg simulieren oder hast Du was grösseres vor?
Wie wärs mit einer zwei zeilen Lösung?

nee, historyline spiele ich nicht ;)

ich mach was ähnliches in meinem Projekten, in einer Listbox werden die items anhand einer grundfarbe abgedunkelt dargestellt.
wenn ich die RGB-Werte veringere, kommt irgendwann schwarz raus und die Zwischenschritte sind eher blaugrau statt dunkelblau.

wenn dir der Weg zu aufwendig ist, okay, aber die Ergebnisse sind besser finde ich,
kannst du auch gerne mal ausprobieren, die Farbverläufe sind unterschiedlich:
ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
procedure TForm1.Button1Click(Sender: TObject);
Var grundfarbe:longint;
    temp:integer;
    i:integer;
    _rgb:TPixelBMP24;
    yuv : TPixelBMP24;
begin
  Grundfarbe:=colortorgb(clBtnHighlight);
//  Grundfarbe:=rgb(255,200,0);

  //Variante 1 - yuv
  //Fabrbe in RGB werte aufsplitten
  _rgb.r:=GetRValue(Grundfarbe);
  _rgb.g:=GetGValue(Grundfarbe);
  _rgb.b:=GetBValue(Grundfarbe);
  //Farbe in Yuv - werte ändern
  yuv:=BMPRGBtoYUV(_rgb);

  for i:=255 downto 0 do
    begin
       //Helligkeitsabstufung an hand der ebene
      if yuv.G>0 then dec(yuv.G);
      _rgb:=BMPYUVtoRGB(yuv); //und wieder zurück zu RGB
      //Formfarbe setzen
      PaintBox1.Canvas.Pen.Color := rgb(_rgb.R,_rgb.G,_rgb.B);
      PaintBox1.Canvas.moveto(i,0);
      PaintBox1.Canvas.lineto(i,150);
    end;

  //Variante 2 rgb-werte verringern
  //Fabrbe in RGB werte aufsplitten
  _rgb.r:=GetRValue(Grundfarbe);
  _rgb.g:=GetGValue(Grundfarbe);
  _rgb.b:=GetBValue(Grundfarbe);

  for i:=255 downto 0 do
    begin
      if _rgb.r>0 then dec(_rgb.r);
      if _rgb.g>0 then dec(_rgb.g);
      if _rgb.b>0 then dec(_rgb.b);
      //Formfarbe setzen
      PaintBox2.Canvas.Pen.Color := rgb(_rgb.R,_rgb.G,_rgb.B);
      PaintBox2.Canvas.moveto(i,0);
      PaintBox2.Canvas.lineto(i,150);
    end;
end;

außerdem hat hansa davon gesprochen, daß er die Ebene und Grundfarbe im OI einstellen will, dann halt einfach die ebene und Grundfarbe als publishde property und bei den Set_methoden die Proc setzeFarbe aufrufen.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
TheD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 27



BeitragVerfasst: Mo 14.07.03 20:43 
Jo, macht Sinn...

Ciao...

_________________
Bis dannn... TheD!
Wer im Schlachthaus sitzt, sollte nicht mit Schweinen werfen! ;)
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mo 14.07.03 20:51 
Mit dem Code kann ich nichts anfangen. Das ganze geht mit AND OR usw. mit "FF0980FFEA" Und da muß ich an der richtigen Stelle etwas addieren oder so. Das Handbuch ist dafür sehr schlecht geeignet. Da steht so was nicht drin.

_________________
Gruß
Hansa
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 15.07.03 08:39 
hansa hat folgendes geschrieben:
Mit dem Code kann ich nichts anfangen. Das ganze geht mit AND OR usw. mit "FF0980FFEA" Und da muß ich an der richtigen Stelle etwas addieren oder so. Das Handbuch ist dafür sehr schlecht geeignet. Da steht so was nicht drin.


wie, was, wo ?

* Frank nix versteht. *

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Di 15.07.03 09:22 
wo ist das ?

ausblenden Quelltext
1:
TPixelBMP24;					

_________________
Gruß
Hansa
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 15.07.03 09:31 
hansa hat folgendes geschrieben:
wo ist das ?

ausblenden Quelltext
1:
TPixelBMP24;					


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type 
  TPixelBMP24 = packed record 
    R: byte; 
    G: byte; 
    B: byte; 
end;

steht ganz oben in der unit.
Ich glaub Dlphi hat auch was von haus aus (TRgbtriple) kann aber grad nicht guggn

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)