componente a partir do maskedit
02/02/2013
0
Criamos um novo componente, simples, a partir do maskedit para ja ter predefinidos alguns tipos de dados que utilizamos (abaixo);
Instanciamos um objeto em um form e quando vamos mudar o "TipoEdicao" ocorre um access violation. Onde pode estar o erro ?
Quando tentamos utilizar um form que ja tinha esse componente tambem ocorre o mesmo erro.
Alguem tem alguma ideia de onde esta o erro ?
Grato,
unit DXGETCODIGO;
interface
USES Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Mask, MaskUtils;
type
TtpediEDICOES = ( tpediContaContabil, tpediApropriacao );
TdxGETCODIGO = class(TMaskEdit)
private
FOnEnter: TNotifyEvent;
FOnExit: TNotifyEvent;
KTipoEdicao: TtpediEDICOES;
protected
procedure DOEnter; override;
procedure DOExit; override;
procedure SetTipoEdicao(Value: TtpediEDICOES);
public
constructor Create(AOwner: TComponent); override;
published
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
property TipoEdicao: TtpediEDICOES read KTipoEdicao write SetTipoEdicao;
end;
procedure Register;
implementation
USES StrUtils, DIXICH, DXOBRVCL;
constructor TdxGETCODIGO.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
procedure TdxGETCODIGO.SetTipoEdicao( Value: TtpediEDICOES );
begin
TEXT:= cntSTRINGNIL;
IF VALUE = tpediContaContabil THEN
BEGIN
WIDTH:= 129;
EditMask:= odxOBRVCL.PICTCTB;
END
ELSE IF Value = tpediApropriacao THEN
BEGIN
WIDTH:= 81;
EditMask:= odxOBRVCL.PICTAPROP; // ''a.aa.aaa;1; ''; //
END;
KTipoEdicao:= Value;
end;
procedure TdxGETCODIGO.DoEnter;
begin
if Assigned(FOnEnter) then FOnEnter(Self);
end;
procedure TdxGETCODIGO.DoExit;
begin
if Assigned(FOnExit) then FOnExit(Self);
end;
procedure Register;
begin
RegisterComponents(''DIXI'', [TdxGETCODIGO]);
end;
end.
Instanciamos um objeto em um form e quando vamos mudar o "TipoEdicao" ocorre um access violation. Onde pode estar o erro ?
Quando tentamos utilizar um form que ja tinha esse componente tambem ocorre o mesmo erro.
Alguem tem alguma ideia de onde esta o erro ?
Grato,
unit DXGETCODIGO;
interface
USES Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Mask, MaskUtils;
type
TtpediEDICOES = ( tpediContaContabil, tpediApropriacao );
TdxGETCODIGO = class(TMaskEdit)
private
FOnEnter: TNotifyEvent;
FOnExit: TNotifyEvent;
KTipoEdicao: TtpediEDICOES;
protected
procedure DOEnter; override;
procedure DOExit; override;
procedure SetTipoEdicao(Value: TtpediEDICOES);
public
constructor Create(AOwner: TComponent); override;
published
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
property TipoEdicao: TtpediEDICOES read KTipoEdicao write SetTipoEdicao;
end;
procedure Register;
implementation
USES StrUtils, DIXICH, DXOBRVCL;
constructor TdxGETCODIGO.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
procedure TdxGETCODIGO.SetTipoEdicao( Value: TtpediEDICOES );
begin
TEXT:= cntSTRINGNIL;
IF VALUE = tpediContaContabil THEN
BEGIN
WIDTH:= 129;
EditMask:= odxOBRVCL.PICTCTB;
END
ELSE IF Value = tpediApropriacao THEN
BEGIN
WIDTH:= 81;
EditMask:= odxOBRVCL.PICTAPROP; // ''a.aa.aaa;1; ''; //
END;
KTipoEdicao:= Value;
end;
procedure TdxGETCODIGO.DoEnter;
begin
if Assigned(FOnEnter) then FOnEnter(Self);
end;
procedure TdxGETCODIGO.DoExit;
begin
if Assigned(FOnExit) then FOnExit(Self);
end;
procedure Register;
begin
RegisterComponents(''DIXI'', [TdxGETCODIGO]);
end;
end.
Fabio Ferreira..
Curtir tópico
+ 0
Responder
Posts
05/02/2013
Bruno Leandro
o problema provavelmente esta na função SetTipoEdicao coloca um break point e faz uma depuração dentro ela.
Responder
05/02/2013
Bruno Leandro
pois problema de access violation acontece quando voce tenta acessar um objeto ainda nao criado ou já liberado
Responder
Clique aqui para fazer login e interagir na Comunidade :)