hola force1758 si lo que quieres no es muy complicado e incluso repetitivo, puedes optar por crear una función, con lo que la llamas cada vez que la necesitas, como ejemplo te pongo la siguiente
Código Delphi
[-]function Inputdate(const ACaption, APrompt: string; Separadores:Boolean =true): string;
function GetCharSize(Canvas: TCanvas): TPoint;
var
I: Integer;
Buffer: array[0..51] of Char;
begin
for I := 0 to 25 do Buffer[i] := Chr(I + Ord('A'));
for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
Result.X := Result.X div 52;
end;
var
Form: TForm;
Prompt: TLabel;
Combo: TDateTimePicker;
Ed: TEdit;
Labelfec2: TLabel;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
R: TRect;
begin
Result := '';
Form := TForm.Create(Application);
with Form do
try
Canvas.Font := Font;
DialogUnits := GetCharSize(Canvas);
BorderStyle := bsDialog;
FormStyle :=fsStayOnTop;
Caption := ACaption;
ClientWidth := MulDiv(195, 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(180, DialogUnits.X, 4);
WordWrap := True;
end;
Ed:=TEdit.Create(Form);
with Ed do
begin
Parent := Form;
Left := Prompt.Left;
Top := Prompt.top+Prompt.Height+5;
Width := MulDiv(180, DialogUnits.X, 4);
Text :='';
end;
Labelfec2 := TLabel.Create(Form);
with Labelfec2 do
begin
Parent := Form;
Caption := 'Fecha';
Left := Prompt.Left;
Top := ED.top+ED.Height+5;
WordWrap := True;
end;
Combo := TDateTimePicker.Create(Form);
with Combo do
begin
Parent := Form;
Left := Prompt.Left;
Top := Labelfec2.top+Labelfec2.Height+5;
Width := MulDiv(178, DialogUnits.X, 4);
end;
ButtonTop := combo.top+Combo.Height+10;;
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := 'OK';
ModalResult := mrOk;
default := True;
SetBounds(MulDiv(Prompt.Left-2, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := 'Cancelar';
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(137, DialogUnits.X, 4), ButtonTop,ButtonWidth, ButtonHeight);
Form.ClientHeight := 140;
end;
if ShowModal = mrOk then
begin
if Separadores then Result:=Ed.Text+' [ '+DateToStr(Combo.Date)+' ]'
else Result:=Ed.Text+' '+DateToStr(Combo.Date);
end;
finally
Form.Free;
end;
end;
y otro ejemplo
Código Delphi
[-]function InputMemo(const ACaption, APrompt: string; Text:String =''): string;
function GetCharSize(Canvas: TCanvas): TPoint;
var
I: Integer;
Buffer: array[0..51] of Char;
begin
for I := 0 to 25 do Buffer[i] := Chr(I + Ord('A'));
for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
Result.X := Result.X div 52;
end;
var
Form: TForm;
Prompt: TLabel;
MEM: TMemo;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
R: TRect;
begin
Result := '';
Form := TForm.Create(Application);
with Form do
try
Canvas.Font := Font;
DialogUnits := GetCharSize(Canvas);
BorderStyle := bsDialog;
FormStyle :=fsStayOnTop;
Caption := ACaption;
ClientWidth := MulDiv(396, 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(180, DialogUnits.X, 4);
WordWrap := True;
end;
MEM := TMemo.Create(Form);
with MEM do
begin
Parent := Form;
Left := Prompt.Left;
Top := Prompt.top+Prompt.Height+5;
Height := 150;
Width := MulDiv(380, DialogUnits.X, 4);
Lines.Text := Text;
end;
ButtonTop := MEM.top+MEM.Height+10;;
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := 'OK';
ModalResult := mrOk;
default := True;
SetBounds(MulDiv(Prompt.Left-2, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := 'Cancelar';
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(340, DialogUnits.X, 4), ButtonTop,ButtonWidth, ButtonHeight);
Form.ClientHeight := 220;
end;
MEM.Lines.Clear;
MEM.Lines.Add(Text);
if ShowModal = mrOk then Result:=MEM.Lines.Text
else Result:=Text; finally
Form.Free;
end;
end;