Hallo zusammen,
ich habe folgendes Problem:
Ich möchte einen etwas modifizierten Öffnen-Dialog erstellen. Ich habe dafür eine Klasse erstellt, die direkter Nachkomme von TOpenDialog ist. Zusätzlich werden einige Komponenten hinzugefügt (CheckBox, Image, ... ) Soweit so schön ... tut eigentlich alles.
Das Problem ist nun, daß ich immer, wenn ich zur Laufzeit auf das ebenfalls integrierte StringGrid klicke den Fehler "Im Projekt ... ist eine Exception der Klasse EInvalidOperation aufgetreten. Meldung: 'Element '' hat kein übergeordnetes Fenster.'" erhalte, obwohl ich ausdrücklich Parent und ParentWindow angebe.
Hier ein Auszug aus dem Code der Klasse:
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:
| TPreviewOpenDialog = class(TOpenDialog)
private pContainer : TPanel; cbShowPreview : TCheckBox; pImgBorder : TPanel; iPreviewImg : TImage; sgInfoGrid : TStringGrid;
. . .
constructor TPreviewOpenDialog.Create; begin inherited Create(AOwner);
pContainer := TPanel.Create(self); with pContainer do begin Caption := ''; BevelInner := bvNone; BevelOuter := bvNone; ShowHint := True;
pImgBorder := TPanel.Create(self); with pImgBorder do begin Parent := pContainer; Caption := ''; BevelInner := bvRaised; BevelOuter := bvLowered;
iPreviewImg := TImage.Create(self); with iPreviewImg do begin Parent := pImgBorder; Cursor := crHandPoint; Align := alClient; end; end;
sgInfoGrid := TStringGrid.Create(self); with sgInfoGrid do begin Parent := pContainer; end;
cbShowPreview := TCheckBox.Create(self); with cbShowPreview do begin Parent := pContainer; Caption := 'Vorschau'; end; end; end;
. . .
procedure TPreviewOpenDialog.DoShow; var ParentHandle : THandle; ClientRect, WindowRect : TRect; newX, newY, newWidth, newHeight : Integer; begin ParentHandle := GetParent(Handle); GetClientRect(ParentHandle, ClientRect); GetWindowRect(ParentHandle, WindowRect);
newWidth := WindowRect.Right-WindowRect.Left; newHeight := (WindowRect.Bottom-WindowRect.Top)+PREVIEW_HEIGHT+2*SPACE;
newX := (Screen.Width-newWidth) div 2; newY := (Screen.Height-newHeight) div 2;
MoveWindow(parenthandle, newX, newY, newWidth, newHeight, true);
pContainer.ParentWindow := ParentHandle;
pContainer.SetBounds(0,ClientRect.Bottom,ClientRect.Right,PREVIEW_HEIGHT+2*SPACE); pImgBorder.SetBounds(SPACE,SPACE,PREVIEW_WIDTH,PREVIEW_HEIGHT); with sgInfoGrid do begin SetBounds(PREVIEW_WIDTH+2*SPACE,SPACE,pContainer.Width-(PREVIEW_WIDTH+3*Space),INFO_HEIGHT); ColWidths[0] := 96; ColWidths[1] := Width-96;
ScrollBars := ssVertical; sgInfoGrid.ParentWindow := ParentHandle; end; cbShowPreview.SetBounds(PREVIEW_WIDTH+2*SPACE,pContainer.Height-SPACE-17,96,17);
end; |
Hat jemand nen Plan, wie ich diesen lästigen Fehler loswerden kann? Für Hilfe wäre ich sehr dankbar ... .
Moderiert von
Tino: Delphi-Tags hinzugefügt.