Solved

set wallpaper Tile/Center/Stretch

Posted on 1998-11-25
3
3,078 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

15 Experts available now in Live!

Get 1:1 Help Now