Solved

set wallpaper Tile/Center/Stretch

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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