Solved

Center, tile, and stretch wallpaper

Posted on 1997-03-06
4
2,149 Views
Last Modified: 2008-03-04
I'm making an app to change windows wallpaper.  I want to add three radio buttons for Center, Tile, and Stretch.  So when I apply the selected BMP file to make it Windows' wallpaper.  How can I code the radio buttons?  Do I use API?  I'm a beginner.  Please show me step by step.

Thanks in advance
0
Comment
Question by:warp
  • 2
4 Comments
 
LVL 1

Expert Comment

by:BabyFace
ID: 1424253
Hi,

I was woundering which wallpaper you wanted to change?
Did you wan't to change the Window's wallpaper or did you just wanted to make your own wallpaper for your own form?
0
 

Author Comment

by:warp
ID: 1424254
Edited text of question
0
 

Author Comment

by:warp
ID: 1424255
Edited text of question
0
 
LVL 5

Accepted Solution

by:
volking earned 100 total points
ID: 1424256
I'm not sure I understand your question.

If you're asking "How does the Option Button control work" then I'd suggest you read the VB help file.

But if you're asking, "How do I change Wallpaper from VB?" then here's your answer.
========================
from MSDN

Abstract
Using the Microsoft® Windows® application programming interface (API) SystemParametersInfo function, you can remove or change the default desktop wallpaper from within your Microsoft Visual Basic® 4.0 application.
Using SystemParametersInfo to Remove/Select Wallpaper
In a Microsoft® Visual Basic® application, the Microsoft Windows® application programming interface (API) SystemParametersInfo function can be used to set many different system-wide parameters. One of these parameters is the desktop wallpaper. Normally, a user would select a new desktop wallpaper by using Control Panel.
As shown in the example program below, the SystemParametersInfo function can be called with the SPI_SETDESKWALLPAPER value and the name of the wallpaper you want to select. The Windows 95 operating system will then make this the new default wallpaper.
The SPIF_SENDWININICHANGE value tells Windows 95 that it should notify all top-level windows of the new change to the system-wide parameters.
Example Program
This program shows how to remove and select a new desktop wallpaper from within a Visual Basic application.
 1.      Create a new project in Visual Basic. Form1 is created by default.
 2.      Add the following Constant and Declare statements to the General Declarations section of Form1 (note that the Declare statement must be typed as a single line of code):
 
Private Declare Function SystemParametersInfo Lib "user32" Alias
   "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long,
   ByVal lpvParam As String, ByVal fuWinIni As Long) As Long
Const SPIF_UPDATEINIFILE = &H1
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_SENDWININICHANGE = &H2
 
 3.      Add a Command Button control to Form1. Command1 is created by default. Set its Caption property to "Remove Wallpaper".
 4.      Add the following code to the Click event for Command1 (note that the "X =" statement must be typed as a single line of code):
 
Private Sub Command1_Click()
    Dim X As Long
    X = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, "(None)",
       SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
    MsgBox "Wallpaper was removed"
End Sub
 
 5.      Add a second Command Button control to Form1. Command2 is created by default. Set its Caption property to "Change Wallpaper".
 6.      Add the following code to the Click event for Command2 (note that the "X =" statement must be typed as a single line of code):
 
Private Sub Command2_Click()
    Dim FileName As String
    Dim X As Long

    FileName = "c:\windows\pinstripe.bmp"

    X = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, FileName,
       SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
    MsgBox "Wallpaper was changed"
End Sub
 
 
Run the example program by pressing F5. To remove the wallpaper, click the "Remove Wallpaper" command button. Windows 95 displays a black background with no graphics whatsoever. Click the "Change Wallpaper" command button to change the wallpaper to the PINSTRIPE.BMP image.
Additional References
"Desktop Window." (Library, Product Documentation, SDKs, Win32 SDK, Win32 Programmer's Reference, Overviews, Window Management, Windows, About Windows)
Knowledge Base Q97142. "How to Use SystemParametersInfo API for Control Panel Settings."
"SystemParametersInfo QuickInfo Overview Group." (Library, Product Documentation, SDKs, Win32 SDK, Win32 Programmer's Reference, Reference, Functions, ShowCursor to UnhandledExceptionFilter)

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

16 Experts available now in Live!

Get 1:1 Help Now