Fórum Erro 'TWidgetControl' and 'TForm' o que sera ? #387218

25/09/2010

0

Tenho uma Unit que tem agumas funcao para uso de um componente.
Estou criando essa funcao para exibir uma mensagem + na linha
Parent := ( F_FormMsg );   da o seguinte erro incompatible Types
'TWidgetControl' and 'TForm'. o que pode ser


 F_FormMsg := TForm.Create( nil );
   with F_FormMsg do begin
      Color :=ClWhite ;
      Width := 320;
      Height := 150;
      BorderIcons:=[] ;
      Position:=poScreenCenter ;
      Color   :=ClWhite ;
      BorderStyle := bsDialog;
      FormStyle   := fsStayOnTop;
      Caption := 'Runtime Form';
   end;
   F_LbMsg := TLabel.Create(APPLICATION);
   with F_LbMsg do begin
      Parent := ( F_FormMsg ); 
      Left := 10;
      Top := 30;
      Autosize:=False ;
     // Caption :='Emitindo Redução Z Isso pode Levar Alguns Minutos ....';
       Caption :='Efetuando Formas De pagamentos....';
      Alignment :=taCenter ;
      Font.Size :=15 ;
      Font.Color:=ClRed ;
      Width := 310;
      Height:=84 ;
      WordWrap:=True ;
   end;
   F_FormMsg.ShowModal;
end;

Obrigado a tds..
Emerson Charles

Emerson Charles

Responder

Posts

26/09/2010

Wesley Batista

Olá amigo, veja a unit que desenvolvi com o teu exemplo

unit Unit4;

interface

uses

Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Unit1, Buttons;

type

TForm4 = class(TForm)

BitBtn1: TBitBtn;

procedure BitBtn1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

F_LbMsg : TLabel;

F_FormMsg : TForm;

end;

var

Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.BitBtn1Click(Sender: TObject);

begin

F_FormMsg := TForm.Create( nil );

with F_FormMsg do begin

Color :=ClWhite ;

Width := 320;

Height := 150;

BorderIcons:=[] ;

Position:=poScreenCenter ;

Color :=ClWhite ;

BorderStyle := bsDialog;

FormStyle := fsStayOnTop;

Caption := 'Runtime Form';

end;

F_LbMsg := TLabel.Create(APPLICATION);

with F_LbMsg do begin

Parent := ( F_FormMsg );

Left
:= 10;

Top :=
30;

Autosize:=False
;

//
Caption :='Emitindo Redução Z Isso pode Levar Alguns Minutos ....';

Caption
:='Efetuando Formas De pagamentos....';

Alignment :=taCenter ;

Font.Size :=15 ;

Font.Color:=ClRed ;

Width := 310;

Height:=84 ;

WordWrap:=True ;

end;

F_FormMsg.ShowModal;

end;

end.
veja o Resultado : 


Fiz exatamente o que você fez, me envie o exemplo, coloca no teu disco virtual. e manda o link para analisar.
Um abraço
Wesley Batista
Responder

Gostei + 0

26/09/2010

Emerson Charles

entao dentro de um form funciona sim, é que eu estava tentando
colocar dentro de um componente, neste componente tenho uma unit
que chama u_func_comp ai da erro nessa linha, acho que é por questao de nao ter form.
ai fiz assim só que nao consigo liberar depois do proceso.
type
  { TFrmInput }
  TFrmInput = class(TForm)
  private
    LabText: TLabel;
    LabSN: TLabel;
    LabCR: TLabel;
    LabData :TLabel ;
    EdtSN: TEdit;
    EdtCR: TEdit;
    Rate: Double;
    procedure CreateLabels;
  public
     f_sMsg : string ;
     procedure LiberaDialog;
     destructor Destroy; override;
     procedure CreateDialog(AOwner: TComponent);
  end;

Const
 FORM_INDENT     = 14;


// CreateDialog
procedure TFrmInput.CreateDialog(AOwner: TComponent);
begin
  // cria formulário
   Width := 320;
   Height := 150;
   BorderStyle := bsDialog;
   Caption := 'Andamento do Processo';
   Color   :=ClWhite ;
   BorderIcons:=[] ;
   FormStyle   := fsStayOnTop;
   Rate := Canvas.TextWidth('W') / 11;
   Position := poScreenCenter;
   CreateLabels;
end;

destructor TFrmInput.Destroy;
begin
  Free ;
end;



// CreateLabels
procedure TFrmInput.CreateLabels;
begin
  // texto
  LabText := TLabel.Create(Self);
  with LabText do
    begin
      Parent := Self;
      Left := 10;
      Top := 30;
      Autosize:=False ;
      Caption :=f_sMsg ;
      Alignment :=taCenter ;
      Font.Size :=15 ;
      Font.Color:=ClRed ;
      Width := 310;
      Height:=84 ;
      WordWrap:=True ;
    end;
    Application.ProcessMessages ;
end;

procedure TFrmInput.LiberaDialog;
begin
 Close ;
end;



Chamo assim

procedure TPrgFisc.testeMsg(Par_Msg : String ) ;
begin
  with TFrmInput.CreateNew(Self) do
    begin
       f_sMsg:=Par_Msg;
       CreateDialog(FOwner);
       Show ;
       Refresh ;
   //    Free;
    end;
end;

Na hora de liberar da um monte de erro tentei assim
procedure TPrgFisc.F_FecharMsg ;
begin
  FreeAndNil(TFrmInput) ;
   // Free;

end;
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar