Ads 468x60px

Smaller time frame always follow the bigger time frame. It's better wait be patience to enter in position than risk with BIG SL. Having strong trading discipline and taking losses when necessary is a sign of serious trading approach
Subscribe:

Labels

Saturday, August 11, 2012

SETTING WINDOWS WALLPAPER REVISITED (WITH NEW TRICKS!)


We demonstrated how to set Windows' wallpaper from your application using our previously featured SetWallpaper() function. Since then we've improved it to support setting the exact position of the wallpaper and the ability to resize the wallpaper to fit the screen.
uses
  Registry, WinProcs, SysUtils;

const
  // WallPaperStyles
  WPS_Tile      = 0;
  WPS_Center    = 1;
  WPS_SizeToFit = 2;
  WPS_XY        = 3;

//
// sWallpaperBMPPath
//   - path to a BMP file
//
// nStyle
//   - any of the above WallPaperStyles
//
// nX, nY
//   - if the nStyle is set to WPS_XY,
//     nX and nY can be used to set the
//     exact position of the wall paper
//
procedure SetWallpaperExt(
  sWallpaperBMPPath : string;
  nStyle,
  nX, nY : integer );
var
  reg    : TRegIniFile;
  s1     : string;
  X, Y   : integer;
begin
  //
  // change registry
  //
  // HKEY_CURRENT_USER\
  //   Control Panel\Desktop
  //     TileWallpaper (REG_SZ)
  //     Wallpaper (REG_SZ)
  //     WallpaperStyle (REG_SZ)
  //     WallpaperOriginX (REG_SZ)
  //     WallpaperOriginY (REG_SZ)
  //
  reg := TRegIniFile.Create(
           'Control Panel\Desktop' );

  with reg do
  begin
    s1 := '0';
    X  := 0;
    Y  := 0;

    case nStyle of
      WPS_Tile  : s1 := '1';
      WPS_Center: nStyle := WPS_Tile;
      WPS_XY    :
      begin
        nStyle := WPS_Tile;
        X := nX;
        Y := nY;
      end;
    end;

    WriteString( '',
      'Wallpaper',
      sWallpaperBMPPath );

    WriteString( '',
      'TileWallpaper',
      s1 );

    WriteString( '',
      'WallpaperStyle',
      IntToStr( nStyle ) );

    WriteString( '',
      'WallpaperOriginX',
      IntToStr( X ) );

    WriteString( '',
      'WallpaperOriginY',
      IntToStr( Y ) );
  end;
  reg.Free;

  //
  // let everyone know that we
  // changed a system parameter
  //
  SystemParametersInfo(
    SPI_SETDESKWALLPAPER,
    0,
    Nil,
    SPIF_SENDWININICHANGE );
end;
Here are two examples on how to call the above SetWallpaperExt() function.
// set wallpaper to winnt.bmp and
  // stretch it to fit the screen
  SetWallpaperExt(
    'c:\winnt\winnt.bmp',
    WPS_SizeToFit, 0, 0 );

  // set the wallpaper origin
  // to (10, 200)
  SetWallpaperExt(
    'c:\winnt\winnt.bmp',
    WPS_XY, 10, 200 );

comments