Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

set wallpaper Tile/Center/Stretch

Posted on 1998-11-25
3
Medium Priority
?
3,175 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

Technology Partners: 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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 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