?
Solved

set wallpaper Tile/Center/Stretch

Posted on 1998-11-25
3
Medium Priority
?
3,145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

801 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