Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #5  
Antiguo 16-02-2012
elGuerrero elGuerrero is offline
Miembro
NULL
 
Registrado: ene 2012
Posts: 10
Poder: 0
elGuerrero Va por buen camino
SetAutoSize funcionando

H!

Buscando en la red, encontré un código de A. Johnson para lo redimensionar el componente TEdit. Lo adapté y si funcionó:

Código:
procedure TEditor.AjustarWidth;
var
  DC: HDC;
  SaveFont: HFont;
  Size: TSize;
  sText: String;
begin
  if (AutoSize) and (MaxLength > 0) then
    begin
    if not HandleAllocated then exit;
    DC := GetDC(handle);
    try
      SaveFont := SelectObject(DC, Font.Handle);
      sText:= DupeString('X', MaxLength);
      if GetTextExtentPoint32(DC, pchar(sText), length(sText), Size) then
          ClientWidth:= Size.cx;
      SelectObject(DC, SaveFont);
    finally
      ReleaseDC(handle, DC);
    end;
    end;//if
end;
La llamada a este procedimiento la hago desde CreateWnd, SetAutoSize y DoSetMaxLength:

Código:
procedure TEditor.CreateWnd;
begin
  inherited CreateWnd;
  AjustarWidth;
end;

procedure TEditor.SetAutoSize(Value: Boolean);
begin
  inherited;
  AjustarWidth;
end;

procedure TEditStr.DoSetMaxLength(Value: Integer);
begin
  AjustarWidth;
  inherited;
end;
Sin embargo, funciona a medias. En tiempo de diseño, cuando modificó SetAutoSize y luego MaxLength, no cambia el ancho del componente visual TEditor, pero si lo hago al revés, si lo cambia. También lo cambia, cuando cambio SetAutoSize, MaxLength y vuelvo a poner la propiedad SetAutoSize.

¿Qué me estará faltando?
¿No habrá otra manera de llamar el procedimiento AjustarWidth cuando se cambie el valor de MaxLength?
Espero puedan ayudarme. Gracias de antemano.
Responder Con Cita
 


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
Modificar DBGrid desde TEdit jhonalone Conexión con bases de datos 6 21-02-2011 18:47:26
Delphi-For-PHP: Modificar el valor de un tEdit maro PHP 4 29-09-2007 20:25:21
Ajustar el width de un TListBox salvica OOP 2 11-08-2007 20:04:01
modificar o crear componente TEdit chivix OOP 3 08-03-2007 18:50:50
Pasar al siguiente Edit al llegar a maxlength Durbed Varios 4 08-11-2005 20:31:36


La franja horaria es GMT +2. Ahora son las 00:59:28.


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