TStringGrid und TInplaceEdit
-
Kleine Frage zum Abend. Ich habe eine eigene TStringGrid Klasse, welche mit einem eigenem TInplaceEdit versehen ist. War benötigt um die Hintergrundfarbe des InplaceEdit zu setzen. Siehe: http://www.c-plusplus.net/forum/viewtopic-var-p-is-1468079.html#1468079
Hat jemand vielleicht eine Ahnung wie ich den InplaceEditor hinbiegen kann, das ich dessen Text auch rechtsbündig/zentriert eingeben kann?
-
Sorry, ich denke, das ist nicht möglich, da TInplaceEditor (indirekt) von WinControl abgeleitet ist, welches wiederum das Windows "Edit Control" als Basis verwendet. Und dieses Control bietet keine Möglichkeit, die Ausrichtung (Alignment) zu ändern.
-
Was ist eigentlich mit unserer FAQ?
http://www.c-plusplus.net/forum/viewtopic-var-t-is-39261.html
-
Klingt interessant, bekomme es aber nicht ganz umgesetzt. Ich habe eine Custom-StringGrid Kompoennte (leider Delphi) und habe versucht es in das dortige InplaceEdit einzubauen, leider erfolglos. Sieht eventuell jemand meinen Fehler?
TExtInplaceEdit = class(TInplaceEdit) private FAlignment: TAlignment; protected procedure CreateParams(var Params: TCreateParams); override; procedure SetAlignment(const Value: TAlignment); public Constructor Create(aOwner: TComponent); override; published property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify; end; TTeStringGrid = class(TStringGrid) private FEditorAlignment: TAlignment; protected procedure SetEditorAlignment(const Value: TAlignment); public published property EditorAlignment: TAlignment read FEditorAlignment write SetEditorAlignment default taLeftJustify; end; { TExtInplaceEdit ===============================================================} constructor TExtInplaceEdit.Create(aOwner: TComponent); begin inherited Create(AOwner); FAlignment := taLeftJustify; end; procedure TExtInplaceEdit.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); //if Multiline then // Params.Style := Params.Style or LongWord(ES_MultiLine); case Alignment of taLeftJustify: Params.Style := Params.Style or LongWord(ES_Left); taRightJustify: Params.Style := Params.Style or LongWord(ES_Right); else Params.Style := Params.Style or LongWord(ES_Center); end; //if WordWrap then // Params.Style := Params.Style and (not LongWord(ES_AUTOHSCROLL)) //else // Params.Style := Params.Style and (not LongWord(0)); end; procedure TExtInplaceEdit.SetAlignment(const Value: TAlignment); begin if (FAlignment<>Value) then begin FAlignment := Value; RecreateWnd; end; end; { TTeStringGrid ===============================================================} procedure TTeStringGrid.SetEditorAlignment(const Value: TAlignment); begin if (FEditorAlignment<>Value) then begin if InplaceEditor <> nil then if InplaceEditor is TExtInplaceEdit then begin FEditorAlignment := Value; with TExtInplaceEdit(InplaceEditor) do begin Alignment := FEditorAlignment; end; end; end; end;
Im Objektinspector wird der Wert für EditorAligment niemals geändert und wenn ich in SetEditorAlignment() die Abfragen:
if InplaceEditor <> nil then if InplaceEditor is TExtInplaceEdit then
auskommentiere, erhalte ich einen Speicherfehler. *grml*
Vielleicht kennt sich ja wer mit der Materie etwas besser aus. Wäre toll!