Ver Mensaje Individual
  #8  
Antiguo 02-01-2004
SMTZ SMTZ is offline
Miembro
 
Registrado: nov 2003
Posts: 225
Reputación: 21
SMTZ Va por buen camino
Thumbs up

Pues finalmente parece ser que la ventana que yo estaba intentando reescalar no podia caber en una resolucion de 800X600, pero cuando la reescalaba a una resolucion superior a 1024X768 los componentes se adaptaban bien a la nueva resolución pero la ventana era demasiado grande. Para quien le interese, a partir de la información que he sacado de Internet he creado una unidad que me ha solucionado el problema que tenía:


unit UtilidadesU;

interface

Uses
Forms, Windows;

Type
TResolucion = Record

Ancho : Integer;
Alto : Integer;

End;

Procedure AdaptarResolucion ( Ventana : TForm;
AnchoTiempoDiseno,
AltoTiempoDiseno,
cPixelsPerInch,
cFontHeight : Integer );

Function ConocerResolucionWindows : TResolucion;

Function CambiarResolucionWindows ( Ancho, Alto : word): Boolean;

implementation

Procedure AdaptarResolucion ( Ventana : TForm;
AnchoTiempoDiseno,
AltoTiempoDiseno,
cPixelsPerInch,
cFontHeight : Integer );

{Esta función reescala los componentes de una ventana a una nueva resolución}

Var
OldFormWidth : integer;

begin

With TForm.Create ( Ventana ) Do
Begin

scaled := true;
if Screen.Width <> AnchoTiempoDiseno then
begin

OldFormWidth := width;
height := longint ( height ) * longint ( screen.height ) DIV AltoTiempoDiseno;
width := longint ( width ) * longint ( screen.width ) DIV AnchoTiempoDiseno;

scaleBy ( screen.width, AnchoTiempoDiseno );
font.size := ( Width DIV OldFormWidth ) * font.size;

end;

End; // With

End;


Function ConocerResolucionWindows : TResolucion;
Begin

ConocerResolucionWindows.Ancho := Screen.Width;
ConocerResolucionWindows.Alto := Screen.Height;

End;


Function CambiarResolucionWindows ( Ancho, Alto : word): Boolean;
var
lpDevMode: TDeviceMode;

begin

Result := EnumDisplaySettings ( nil, 0, lpDevMode );

if Result then
begin

lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;
lpDevMode.dmPelsWidth := Ancho;
lpDevMode.dmPelsHeight := Alto;
Result := ChangeDisplaySettings ( lpDevMode, 0 ) = DISP_CHANGE_SUCCESSFUL;

end;

end;


end.
Responder Con Cita