Autor Beitrag
superchatti
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Di 15.07.03 16:12 
Also...
Ich benutze folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TMainForm.RxPopUp1DrawItem(Sender: TMenu; Item: TMenuItem;
  Rect: TRect; State: TMenuOwnerDrawState);
begin
  TRxPopupMenu(Sender).DefaultDrawItem(Item, Rect, State);
  Inc(Rect.Left, LoWord(GetMenuCheckMarkDimensions) + 6);
  Rect.Right := Rect.Left + 20;
  InflateRect(Rect, 0, -3);
  with TRxPopupMenu(Sender).Canvas do begin
    Brush.Color := clMenuText;
    FrameRect(Rect);
    InflateRect(Rect, -1, -1);
    Brush.Color := Item.Tag;
    FillRect(Rect);
  end;
end;


Und:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TMainForm.RxPopUp1Popup(Sender: TObject);
var
  I: Integer;
  C: TColor;
begin
  C := CurrText.Color;
  for I := 0 to 16 do
    RxPopUp1.Items[I].Checked := (C = ColorValues[I]);
end;


ColorValues:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
  ColorValues: array [0..16] of TColor = (
    clBlack, clMaroon, clGreen, clOlive, clNavy, clPurple, clTeal, clGray,
    clSilver, clRed, clLime, clYellow, clBlue, clFuchsia, clAqua, clWhite,
    clWindowText);


Wenn ich diesen Code jetzt ausführe meint der:
Zitat:

EMenu Error: 'Index out of range'


Was mache ich falsch!
Brauche die Antwort dringend!!!

_________________
mfG Superchatti
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Di 15.07.03 23:03 
Es sieht so aus, als ob keine 17 Elemente in deinem Menü vorhanden sind.

_________________
If accidentally read, induce vomitting.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 12:24 
In welchem Element?

_________________
mfG Superchatti
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Mi 16.07.03 13:09 
Ich meinte dieses hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TMainForm.RxPopUp1Popup(Sender: TObject);
var
  I: Integer;
  C: TColor;
begin
  C := CurrText.Color;
  for I := 0 to 16 do 
    RxPopUp1.Items[I].Checked := (C = ColorValues[I]);
end;


Ich kenne die Komponente nicht, aber der Fehler heisst ja "Index out of range". Vielleicht gibt es also kein RxPopUp1.Items[16].
Das ist nur eine Vermutung.
Hast du deinen Code denn mal schrittweise debugged, um herauszufinden, wann der Fehler auftritt?

_________________
If accidentally read, induce vomitting.
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 14:05 
Wie geht das denn Schrittweise??

_________________
mfG Superchatti
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 16.07.03 14:09 
Hallo!

superchatti hat folgendes geschrieben:
Wie geht das denn Schrittweise??

Du setzt an einer Stelle im Quellcode einen Breakpoint (F5) und startest das Programm. Gelangt dein Programm an die Quellcodestelle an der du einen Breakpoint gesetzt hast meldet sich Delphi und du kannst z. b. mit F7 oder F8 schreittweise den Code ausführen um dabei Variablen etc zu überprüfen.

Gruß
Tino
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 14:18 
thx

_________________
mfG Superchatti
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 14:38 
Irgendwie meint der der Fehler liegt hier:
ausblenden Delphi-Quelltext
1:
  C := CurrText.Color;					


Ich hab aber keine Ahnung warum!?

_________________
mfG Superchatti
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 16.07.03 14:56 
Was ist denn CurrText?

Setze mal auf diese Zeile einen Breakpoint und starte dein Programm. Wenn Delphi an dieser Zeile halt macht dann halte mal den Mauszeige auf CurrText. Vielleicht konnte es sein das nil angezeigt wird.

Gruß
Tino
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 14:59 
Da steht:
Inaccessible value

Was heißt das??

_________________
mfG Superchatti
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 16.07.03 15:06 
Was ist denn CurrText für ein Objekt?
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 15:10 
CurrText ist eine Funktion:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
function TfrmMain.CurrText: TRxTextAttributes;
begin
  if (PageControl1.ActivePage.Controls[0] as TRxRichEdit).SelLength > 0 then Result := (PageControl1.ActivePage.Controls[0] as TRxRichEdit).SelAttributes
  else Result := (PageControl1.ActivePage.Controls[0] as TRxRichEdit).WordAttributes;
end;


Das ist CurrText!!

_________________
mfG Superchatti
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 16.07.03 15:26 
Formatiere mal deine Funktion wie folgt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function TfrmMain.CurrText: TRxTextAttributes; 
begin 
  if (PageControl1.ActivePage.Controls[0] as TRxRichEdit).SelLength > 0 then 
    Result := (PageControl1.ActivePage.Controls[0] as TRxRichEdit).SelAttributes 
  else 
    Result := (PageControl1.ActivePage.Controls[0] as TRxRichEdit).WordAttributes; 
end;

Dadurch ist es besser zu debuggen. Dann setze mal wieder einen Breakpoint (diesmal in diese Funktion) und schau wo dort der Fehler passiert.

Gruß
Tino
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 15:32 
Jetzt sagt der:
Hier sei der Fehler:
ausblenden Delphi-Quelltext
1:
 if (PageControl1.ActivePage.Controls[0] as TRxRichEdit).SelLength > 0					


Was ich allerdings auch nicht verstehe!

_________________
mfG Superchatti
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 16.07.03 15:38 
Es könnte doch sein das das Control [0] kein TRxRichEdit ist, oder? Dann gehts natürlich schief.

Also am besten vorher prüfen:
ausblenden Delphi-Quelltext
1:
2:
If PageControl1.ActivePage.Controls[0] is TRxRichEdit Then
  {...}

Gruß
Tino
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Mi 16.07.03 15:40 
Es ist Aber TRxRichEdit weil ich das auch bei Fett und so mache und das klappt!

_________________
mfG Superchatti
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 17.07.03 07:30 
Hast du das denn jetzt die Funktion CurrText debuggt um festzustellen ob die IF-THEN Anweisung
ausblenden Delphi-Quelltext
1:
If PageControl1.ActivePage.Controls[0] is TRxRichEdit Then					

True ergibt und somit dann die Zeilen danach auch ausgeführt werden?

Gruß
Tino
superchatti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 296

Win XP, Red Hat Linux 7.3
Delphi 6 PE
BeitragVerfasst: Do 17.07.03 13:40 
Mach ich jetzt!

_________________
mfG Superchatti