Solved

set wallpaper Tile/Center/Stretch

Posted on 1998-11-25
3
3,040 Views
Last Modified: 2008-02-26
I set wallpaper with
SystemParametersInfo( SPI_SETDESKWALLPAPER , 0, buf , SPIF_SENDWININICHANGE);

BUF = Filename to bitmap file..
But i want to change the Setting for HOW the wallpaper should be too..
Center/Tile and Stretch.. I looked for hours in the API help etc, but cant find it..
0
Comment
Question by:brainware
3 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1347868
Here is a method :

{ Procedure to set the desktop wallpaper. Based on an example at
www.chami.com }
{ Revised AND Corrected }
{ Reference:
/tips/delphi/123096D.html }

Const
  WPS_Tile = 0; { Tile Wallpaper }
  WPS_Center = 1; { Center wallpaper }
  WPS_SizeToFit = 2; { Resize the wallpaper to match current resolution }
  WPS_XY = 3; { Place the picture at the given location }

Procedure SetWallpaperExt (sWallpaperBMPPath : String; nStyle, nX, nY :
Integer);
Var
  reg : TRegIniFile;
  s1 : String; { 0 = Stretch, 1 = No Stretch }
  x, y : Integer; { x,y location of bitmap }

Begin

  { Open the registry }
  reg := TRegIniFile.Create ('Control Panel\Desktop');

  s1 := '0'; { Default to stretch }
  x := 0; { Default to an origin of 0,0 }
  y := 0;

  { Initialize variables according to passed values }
  { WPS_Stretch requires no changes, that's why it isn't here }

  case nStyle of
    WPS_Tile : s1 := '1';
    WPS_Center : nStyle := WPS_Tile;
    WPS_XY :
    Begin
      nStyle := WPS_Tile;
      x := nX;
      y := nY;
    End;
  End;

  { Write the registry entries needed }
  reg.WriteString ('','Wallpaper',sWallpaperBMPPath);
  reg.WriteString ('','TileWallpaper',s1);
  reg.WriteString ('','WallpaperStyle',IntToStr (nStyle));
  reg.WriteString ('','WallpaperOriginX',IntToStr (X));
  reg.WriteString ('','WallpaperOriginY',IntToStr (Y));

  { Close the registry }
  reg.Free;

  { Let the system know we changed the desktop wallpaper }


SystemParametersInfo(
    SPI_SETDESKWALLPAPER,
    0,
    PChar( sWallpaperBMPPath ),
    SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE );

{ SystemParametersInfo (SPI_SETDESKWALLPAPER,0,Nil,SPIF_SENDWININICHANGE);}
End;

Regards, Zif.
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347869
brainware

Yip just as Zif said, but you can also use SPIF_SENDCHANGE for immediate update...

SystemParametersInfo (SPI_SETDESKWALLPAPER,0,Nil,SPIF_SENDCHANGE);

Later
BoRiS
0
 
LVL 2

Author Comment

by:brainware
ID: 1347870
Thanks guys.. i tryed my self for like 30 hours before asking..
i see i was a bit off-track.. :)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now