Ver Mensaje Individual
  #1  
Antiguo 30-10-2010
Avatar de lucasarts_18
lucasarts_18 lucasarts_18 is offline
Miembro
 
Registrado: mar 2005
Ubicación: Villa Alemana,Chile
Posts: 1.087
Reputación: 21
lucasarts_18 Va por buen camino
Duda con inicialización de variables

Hola Estimados.

Mucho tiempo que no posteaba, ahora retomando un proyecto en delphi me sale la duda con una variable pública que tengo en un formulario.

Este es el código donde seteo esa variable.



Código Delphi [-]
var
v_Id_Ajuste : Integer;
Frm_IngAjuste : TFrm_IngAjuste;
begin
if ZQry_Ajustes.RecordCount > 0 then
begin
v_Id_Ajuste := ZQry_Ajustes.FieldValues['id_ajuste'];
Frm_IngAjuste := TFrm_IngAjuste.Create(nil);
Frm_IngAjuste.f_Id_Ajuste := v_Id_Ajuste;
Frm_IngAjuste.ShowModal ;
end;
end;


Como ven hasta acá todo perfecto. Pero mi duda es al momento que el formulario donde utilizaré esta variable no se inicializa mediante el evento onshow.

Código Delphi [-]

procedure TFrm_IngAjuste.FormShow (Sender: TObject);
begin
LimpiarCampos;
dt_Fecha.Text := vg_fechasys;
Edt_Bodega.Text := vg_nombodega;
ZQry_Ajuste.ParamByName('p_id_ajuste').AsInteger := f_Id_Ajuste;
ZQry_Ajuste.Open;
if ZQry_Ajuste.RecordCount > 0 then
begin
Edt_NroAjuste.Text := IntToStr(f_Id_Ajuste);
Edt_Fecha.Text := ZQry_Ajuste.FieldValues['fecha'];
Edt_Bodega.Text := ZQry_Ajuste.FieldValues['nom_bod'];
ZQry_AjusteDet.ParamByName('p_id_bodega').AsInteger := vg_idbodega;
ZQry_AjusteDet.ParamByName('p_id_ajuste').AsInteger := f_Id_Ajuste;
ZQry_AjusteDet.Active := False;
ZQry_AjusteDet.Active := True;
end;
 
Edt_NroAjuste.Text := IntToStr(f_Id_Ajuste);
end;


La variable f_id_Ajuste que es de tipo integer y publica del formulario llega en 0, sin embargo en el evento onpaint llega con valor.



Qué evento más podría usar, el onpaint no me sirve mucho, lo ideal era el onshow, pero por lo visto no se inicializan en ese momento dicha variables públicas.

Gracias..

Saludos .-
__________________
No todo es como parece ser...
Responder Con Cita