Newsgroup: it.comp.lang.delphi
Titolo: form e risoluzione video

ciao a tutti
vorrei sapere come è possibile adattare tutti i componenti di una form
(esmp. altezza riga dbgrid e colonna ecc )
modificando la risoluzione dello schermo
Grazia in anticipo per il vostro aiuto
Nicola

Devi mettere nel tuo progetto un font dialog ed avere i componenti tipo 
TdxEdit, questa libreria ha un componente per definire lo stile che vuoi.
Poi fai cosě
aggiungi Registri nella sezione Uses
procedure TfMatia.tbFontsClick(Sender: TObject);
begin
   if FontDialog.Execute then
      // Aggiorno registro
      dmLookup.Reg_W('','Font',FontToString( FontDialog.Font));
end;
//
// Expected format:
//   "Arial", 9, [Bold], [clRed]
//
procedure TfMatia.StringToFont(
  sFont : string; Font : TFont );
const
  csfsBold      = '|Bold';
  csfsItalic    = '|Italic';
  csfsUnderline = '|Underline';
  csfsStrikeout = '|Strikeout';
var
  p      : integer;
  sStyle : string;
begin
  with Font do
  begin
    // get font name
    p    := Pos( ',', sFont );
    Name :=
      Copy( sFont, 2, p-3 );
    Delete( sFont, 1, p );
    // get font size
    p    := Pos( ',', sFont );
    Size :=
      StrToInt( Copy( sFont, 2, p-2 ) );
    Delete( sFont, 1, p );
    // get font style
    p      := Pos( ',', sFont );
    sStyle :=
      '|' + Copy( sFont, 3, p-4 );
    Delete( sFont, 1, p );
    // get font color
    Color :=
      StringToColor(
        Copy( sFont, 3,
          Length( sFont ) - 3 ) );
    // convert str font style to
    // font style
    Style := [];
    if( Pos( csfsBold,
          sStyle ) > 0 )then
      Style := Style + [ fsBold ];
    if( Pos( csfsItalic,
          sStyle ) > 0 )then
      Style := Style + [ fsItalic ];
    if( Pos( csfsUnderline,
          sStyle ) > 0 )then
      Style := Style + [ fsUnderline ];
    if( Pos( csfsStrikeout,
          sStyle ) > 0 )then
      Style := Style + [ fsStrikeout ];
  end;
end;
//
// Output format:
//   "Aril", 9, [Bold|Italic], [clAqua]
//
function TfMatia.FontToString(
  Font : TFont ) : string;
const
  csfsBold      = '|Bold';
  csfsItalic    = '|Italic';
  csfsUnderline = '|Underline';
  csfsStrikeout = '|Strikeout';
var
  sStyle : string;
begin
  with Font do
  begin
    // convert font style to string
    sStyle := '';
    if( fsBold in Style )then
      sStyle := sStyle + csfsBold;
    if( fsItalic in Style )then
      sStyle := sStyle + csfsItalic;
    if( fsUnderline in Style )then
      sStyle := sStyle + csfsUnderline;
    if( fsStrikeout in Style )then
      sStyle := sStyle + csfsStrikeout;
    if( ( Length( sStyle ) > 0 ) and
        ( '|' = sStyle[ 1 ] ) )then
    begin
      sStyle :=
        Copy( sStyle, 2,
          Length( sStyle ) - 1 );
    end;
    Result := Format(
      '"%s", %d, [%s], [%s]',
      [ Name,
        Size,
        sStyle,
        ColorToString( Color ) ] );
  end;
end;
constructor TGraphicHintWindow.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  with Canvas.Font do
  begin
    Name := 'Tahoma';
    Style := Style + [fsBold];
    Color := clNavy;
  end;
end;
procedure TGraphicHintWindow.Paint;
var
  R: TRect;
  bmp: TBitmap;
begin
  R := ClientRect;
  Inc(R.Left, 2);
  Inc(R.Top, 2);
  bmp := TBitmap.Create;
  bmp.LoadfromFile(dmMatia.ExePath+'hint.bmp');
  with Canvas do
  begin
    Brush.Style := bsSolid;
    Brush.Color := clYellow;
    Pen.Color   := clYellow;
    Rectangle(0, 0, 26, R.Bottom + 1);
    bmp.Transparent:=True;
    Draw(2,(R.Bottom div 2) - (bmp.Height div 2), bmp);
  end;
  bmp.Free;
  Color := clYellow;
  Canvas.Brush.Style := bsClear;
  Canvas.TextOut(28, (R.Bottom div 2) - (Canvas.Textheight(Caption) div 
2), Caption);
end;
procedure TGraphicHintWindow.ActivateHint(Rect: TRect; const AHint: 
string);
begin
  FActivating := True;
  try
    Caption := AHint;
    Inc(Rect.Bottom, 14);
    Rect.Right := Rect.Right + 28;
    UpdateBoundsRect(Rect);
    if Rect.Top + Height > Screen.DesktopHeight then
      Rect.Top := Screen.DesktopHeight - Height;
    if Rect.Left + Width > Screen.DesktopWidth then
      Rect.Left := Screen.DesktopWidth - Width;
    if Rect.Left < Screen.DesktopLeft then Rect.Left := 
Screen.DesktopLeft;
    if Rect.Bottom < Screen.DesktopTop then Rect.Bottom := 
Screen.DesktopTop;
    SetWindowPos(Handle, HWND_TOPMOST, Rect.Left, Rect.Top, Width, 
Height,
      SWP_SHOWWINDOW or SWP_NOACTIVATE);
    Invalidate;
  finally
    FActivating := False;
  end;
end;
function TdmLookup.Reg_R( Key: string; Op: String; User: Boolean = 
true ): string;
var
   Reg: TRegistry;
begin
   try
      Reg:=TRegistry.Create;
      Reg.RootKey := HKEY_CURRENT_USER;
      if user then
 
Key:='\Software\nem.eSys\'+Application.Title+'\'+dmMatia.Utente+'\'+Key
      else
         Key:='\Software\nem.eSys\'+Application.Title+'\'+Key;
      if Reg.OpenKey(Key, True) then
      begin
         Result:=Reg.ReadString( Op );
      end;
   finally
      Reg.CloseKey;
      Reg.Free;
   end;
end;
procedure TdmLookup.Reg_W( Key: string; Op: String; Val: String; User: 
Boolean = true );
var
   Reg: TRegistry;
begin
   try
      Reg:=TRegistry.Create;
      Reg.RootKey := HKEY_CURRENT_USER;
      if user then
 
Key:='\Software\nem.eSys\'+Application.Title+'\'+dmMatia.Utente+'\'+Key
      else
         Key:='\Software\nem.eSys\'+Application.Title+'\'+Key;
      if Reg.OpenKey(Key, True) then
      begin
         Reg.WriteString( Op, Val );
      end;
   finally
      Reg.CloseKey;
      Reg.Free;
   end;
end;
Massimiliano Monti
Cel: 
+39 - 335 - 8477278
Mail: 
massimili...@matia.it
Url: 
http://www.multimodo.com/mmjstudio/
--- posted by geoForum on 
http://www.delphiedintorni.it