Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-03-2011
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Paulao.

En una propiedad, el método de lectura tiene que ser una funcion sin parámetros y el método de escritura un procedimiento con un sólo parámetro.

Por ejemplo:
Código Delphi [-]
...
type
 TMi_Clase = class(TObject)
  private
    FVersion: string;
    function GetVersion: string;
    procedure SetVersion(Ver: string);
  public
    property Version: string read FVersion write FVersion;
  end;
...
implementation
...
function TMi_Clase.GetVersion: string;
begin
  Result:= FVersion; // (o código para obtener la versión)
end;

procedure TMi_Clase.SetVersion(Ver: string);
begin
  FVersion:= Ver;
end;

Ejemplo de uso:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  MClase: TMi_Clase;
begin
  MClase:= TMi_Clase.Create;
  MClase.Version:= 'xx.xx.xx';
  if MClase.Version <> 'xx.xx.xx' then
    ShowMessage('¡ Imposible !')
  else
    ShowMessage('Todo Ok...');
end;

Edito: Aunque para ampliar el ejemplo utilizé una propiedad con lectura y escritura, es posible definirla de sólo lectura o sólo escritura. Y también podés prescindir de la variable privada.

Un saludo.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 21-03-2011 a las 15:51:58.
Responder Con Cita
  #2  
Antiguo 21-03-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 23
Paulao Va por buen camino
Esta es mi funcion que deberia traer el result en mi property
Código Delphi [-]
function TGeneralFiles.GetRet_Versao(NomeArq: string): string;
var
  VerInfoSize, VerValueSize, Dummy: DWORD;
  VerInfo: Pointer;
  VerValue: PVSFixedFileInfo;
  Maior, Menor, Release, Build: Word;
begin
  Result := '';

  VerInfoSize := GetFileVersionInfoSize( PChar(NomeArq), Dummy );
  GetMem( VerInfo, VerInfoSize );
  try
    GetFileVersionInfo( PChar(NomeArq), 0, VerInfoSize, VerInfo );
    VerQueryValue( VerInfo, '', Pointer(VerValue), VerValueSize );
    with VerValue^ do
    begin
      Maior := dwFileVersionMS shr 16;
      Menor := dwFileVersionMS and $FFFF;
      Release := dwFileVersionLS shr 16;
      Build := dwFileVersionLS and $FFFF;
    end;
  finally
    FreeMem( VerInfo, VerInfoSize );
  end;

  Result :=
    IntToStr(Maior) + '.' + IntToStr(Menor) + '.' +
    IntToStr(Release) + '.' + IntToStr(Build);
    FVersao := Result;
end;
Responder Con Cita
  #3  
Antiguo 21-03-2011
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Paulao.

Una forma posible sería:
Código Delphi [-]
...
type
  TMiClase = class(TObject)
  private
    FAppName: string;
    function GetAppVersion: string;
  public
    property Version: string read GetAppVersion write FAppName;
  end;
...

implementation
...

function TMiClase.GetAppVersion:string;
var
 Size, Size2: DWord;
 Pt, Pt2: Pointer;
begin
  Size := GetFileVersionInfoSize(PChar(FAppName), Size2);
  if Size > 0 then
  begin
    GetMem (Pt, Size);
    try
      GetFileVersionInfo (PChar (FAppName), 0, Size, Pt);
      VerQueryValue (Pt, '\', Pt2, Size2);
      with TVSFixedFileInfo (Pt2^) do
      begin
        Result:= ' Ver '+
                 IntToStr (HiWord (dwFileVersionMS)) + '.' +
                 IntToStr (LoWord (dwFileVersionMS)) + '.' +
                 IntToStr (HiWord (dwFileVersionLS)) + '.' +
                 IntToStr (LoWord (dwFileVersionLS));
      end;
    finally
      FreeMem (Pt);
    end;
  end;
end;
...

Llamada:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  MC: TMiClase;
begin
  MC:= TMiClase.Create;
  MC.Version:= 'C:\Program Files\Borland\Delphi7\Bin\Delphi32.exe';
  ShowMessage(MC.Version);
end;
Para obtener la versión utilizé la función sugerida por el amigo rgstuamigo en el post Cargar Version en el Caption del Form .


Un saludo.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #4  
Antiguo 21-03-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 23
Paulao Va por buen camino
Gracias por la solucion. Asi si quedo mi Unit y la llamada
Código Delphi [-]
type
  TGeneralFiles = class
  FAppName: string;
  private
    function GetAppVersion: string;
  public
    property Versao: string read GetAppVersion write FAppName;
    constructor Create;
end;

implementation

{ GeneralFiles }

constructor TGeneralFiles.Create;
begin
  FAppName := Application.ExeName;
end;

function TGeneralFiles.GetAppVersion: string;
var
 Size, Size2: DWord;
 Pt, Pt2: Pointer;
begin
  Size := GetFileVersionInfoSize(PChar(FAppName), Size2);
  if Size > 0 then
  begin
    GetMem (Pt, Size);
    try
      GetFileVersionInfo (PChar (FAppName), 0, Size, Pt);
      VerQueryValue (Pt, '\', Pt2, Size2);
      with TVSFixedFileInfo (Pt2^) do
      begin
        Result:= ' Versão: '+
                 IntToStr (HiWord (dwFileVersionMS)) + '.' +
                 IntToStr (LoWord (dwFileVersionMS)) + '.' +
                 IntToStr (HiWord (dwFileVersionLS)) + '.' +
                 IntToStr (LoWord (dwFileVersionLS));
      end;
    finally
      FreeMem (Pt);
    end;
  end;
end;

end.

Código Delphi [-]
procedure TfrmMain.FormCreate(Sender: TObject);
begin
  FGeneralFiles := TGeneralFiles.Create;
end;
Código Delphi [-]
procedure TfrmMain.FormShow(Sender: TObject);
begin
  Self.Caption := Self.Caption + ' - ' + FGeneralFiles.Versao;
end;
Ya estas resuelto.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error al asignar método fjcg02 OOP 3 20-01-2011 13:39:56
Error al usar el método Write mcs Varios 1 03-05-2010 10:27:10
Error Property already defined by lookupfield Viky Varios 3 24-11-2009 16:21:25
Error Usestandarprinter: property does not exist chino150 Impresión 6 28-12-2007 19:24:19
[DCC Error] Unit_ClienteExterno.pas(72):E2233 Property 'Date' inaccessible here saltamirano Varios 4 14-12-2007 18:47:49


La franja horaria es GMT +2. Ahora son las 13:58:54.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi