| Autor |
Beitrag |
Tweafis
      
Beiträge: 647
WinXP + fbsd
Delphi 5 Prof
|
Verfasst: Do 19.06.03 13:38
Wie kann ich eine Eigene Form mit Rückgabe erstellen bzw. eienn Dialog (Neu... Dialog). Ich hab das schon versucht aber krieg das nicht hin. Ich möchte meinen Dialog mit
MeinDialog(Parameter) aufrufen und als rückgabe dann das eingegebene zurückgeben (möglicherweise auch ein Record)
Kann mir da jemand helfen?
_________________ .: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
|
|
kiwicht
      
Beiträge: 1021
Win 7, MacOS
Delphi x, VBA, PHP, ...
|
Verfasst: Do 19.06.03 14:21
hilft dir das vielleicht weiter?
Delphi-Quelltext 1: 2: 3: 4: 5: 6:
| function InputBox(const ACaption, APrompt, ADefault: string): string; begin Result := ADefault; InputQuery(ACaption, APrompt, Result); end; |
Wenn du jetzt einfach InputBox durch deinen Namen ersetzt, die Funktion in dein Programm vernünftig einbindest und gemäß deinen Wünschen erweiterst, dann klappts vielleicht.... vielleicht sollte man das ganze auch als Procedure angehen, und vor Result noch ne dynamische Form erzeugen... müsste klappen,glaub ich
mfG
PS:
und das hier, wenn du das einbaust?
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:
| function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean; var Form: TForm; Prompt: TLabel; Edit: TEdit; DialogUnits: TPoint; ButtonTop, ButtonWidth, ButtonHeight: Integer; begin Result := False; Form := TForm.Create(Application); with Form do try Canvas.Font := Font; DialogUnits := GetAveCharSize(Canvas); BorderStyle := bsDialog; Caption := ACaption; ClientWidth := MulDiv(180, DialogUnits.X, 4); Position := poScreenCenter; Prompt := TLabel.Create(Form); with Prompt do begin Parent := Form; Caption := APrompt; Left := MulDiv(8, DialogUnits.X, 4); Top := MulDiv(8, DialogUnits.Y, 8); Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4); WordWrap := True; end; Edit := TEdit.Create(Form); with Edit do begin Parent := Form; Left := Prompt.Left; Top := Prompt.Top + Prompt.Height + 5; Width := MulDiv(164, DialogUnits.X, 4); MaxLength := 255; Text := Value; SelectAll; end; ButtonTop := Edit.Top + Edit.Height + 15; ButtonWidth := MulDiv(50, DialogUnits.X, 4); ButtonHeight := MulDiv(14, DialogUnits.Y, 8); with TButton.Create(Form) do begin Parent := Form; Caption := SMsgDlgOK; ModalResult := mrOk; Default := True; SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight); end; with TButton.Create(Form) do begin Parent := Form; Caption := SMsgDlgCancel; ModalResult := mrCancel; Cancel := True; SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15, ButtonWidth, ButtonHeight); Form.ClientHeight := Top + Height + 13; end; if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end; finally Form.Free; end; end; |
(ich hoffe ich hab dich richtig verstanden und flame jetzt hier nicht sinnlos das Forum zu... 
|
|
Tweafis 
      
Beiträge: 647
WinXP + fbsd
Delphi 5 Prof
|
Verfasst: Do 19.06.03 14:33
Hmm, das bei InputQuery könnte mri weiterhelfen. Aber geht das nicht auch über Die Delphi IDE
_________________ .: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
|
|
kiwicht
      
Beiträge: 1021
Win 7, MacOS
Delphi x, VBA, PHP, ...
|
Verfasst: Do 19.06.03 14:40
hm.. sicherlich.
Form platziert, n Edit-Feld rauf, n Button, und der Rest dürfte sich selber erklären. Um den passenden Code ergänzen, und das ganze dann von deiner Hauptform aufrufen... dürfte nicht so schwer sein, glaub ich =)
|
|
Tweafis 
      
Beiträge: 647
WinXP + fbsd
Delphi 5 Prof
|
Verfasst: Do 19.06.03 14:52
Hab mir grad nochmal Input Query angesehen und das sieht ja eigentlich ganz einfach aus  nur das mit dem GetAveCharSize und MulDiv check ich noch nicht richtig. Aber sonst, thx 
_________________ .: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
|
|
kiwicht
      
Beiträge: 1021
Win 7, MacOS
Delphi x, VBA, PHP, ...
|
Verfasst: Do 19.06.03 15:25
dazu kann ich dir auch nicht viel sagen, ich hab halt nur c&p benutzt...
musst du mal mit strg auf einen Delphi-Befehl doppelklicken, dann öffnet er dir dazu den originalen Source-Code.....
mfG
|
|
Tweafis 
      
Beiträge: 647
WinXP + fbsd
Delphi 5 Prof
|
Verfasst: Do 19.06.03 15:26
Jo, schon klar bin nur nicht draufgekommen 
_________________ .: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
|
|
|