Jump to content
uniGUI Discussion Forums
Sign in to follow this  
Wapform

create dynamic form problem

Recommended Posts

Main Form called  out  myDialogs, but the form didn't show up.

Please help me to deal this problem!

 

//==============================

// Dynamic Form

//==============================

unit myDialogs;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses,
  uniGUIForm, uniGUIBaseClasses, uniGUIVars, uniGUIApplication,
  uniEdit, uniButton;

function Dialog(const ACaption, APrompt: string; var Value: string): Boolean;

implementation

function Dialog(const ACaption, APrompt: string; var Value: string): Boolean;
var
  Form: TUniForm;
  Edit: TUniEdit;
  ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
  Result := False;
  Form := TUniForm.Create(uniApplication);
  with Form do
    try
      BorderStyle := bsDialog;
      Caption := ACaption;
      Position := poScreenCenter;
      Edit := TUniEdit.Create(Form);
      with Edit do
      begin
        Parent := Form;
        Text := Value;
        Left := 60;
        Top := 60;
      end;
      with TUniButton.Create(Form) do
      begin
        Parent := Form;
        Caption := 'OK';
        ModalResult := mrOk;
        Default := True;
        Left := 100;
        Top := 100;
      end;
      with TUniButton.Create(Form) do
      begin
        Parent := Form;
        Caption := 'Cancel';
        ModalResult := mrCancel;
        Cancel := True;
        Left := 200;
        Top := 100;
      end;
      if ShowModal = mrOk then
      begin
        Value := Edit.Text;
        Result := True;
      end;
    finally
      Form.Free;
    end;
end;

end.

 

//==============================

// Main Program

//==============================

unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniButton;

type
  TMainForm = class(TUniForm)
    UniButton1: TUniButton;
    procedure UniButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function MainForm: TMainForm;

implementation

{$R *.dfm}

uses
  uniGUIVars, MainModule, uniGUIApplication, myDialogs;

function MainForm: TMainForm;
begin
  Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  S: string;
begin
  Dialog(' Caption ', ' Prompt ', S);
  Caption := S;
  MainForm.BorderStyle
end;

initialization

RegisterAppFormClass(TMainForm);

end.

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×