Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 28
  1. #1
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,159

    Post Function: Setting Windows Wallpaper

    This is a function that allows you to take either a jpg or bmp image and set it as the windows wallpaper.

    This code should be placed on the button or image [On Click] event that you want to use to set the users wallpaper.

    Code:
    SetWallpaper(0,2,image_name_or_variable)
    The function takes three parameters. The first two are for the orientation (tile and style respectively) of the image and the third is the image itself. Only pass .jpgs or .bmps to this function.

    Centered = 0 , 0
    Stretched = 0 , 2
    Tiled = 1 , 0

    NOTE: For the jpg conversion to work you need to use a program by Worm called JPG2BMP.EXE, which can be found in the IndigoRose Forums.

    The following code should be placed on the Global Functions area of your project. This function will always create an entry in the wallpaper dialog on the users computer called "ams5.bmp". This was done to keep the number of items displayed in the Windows wallpaper dialog box to a minimum. This item can be changed to reflect the name of your application or any other name as is appropriate.

    Code:
    function SetWallpaper(tile,style,img)
    	local imagesplit = String.SplitPath(img)
    	if imagesplit.Extension == ".jpg" then
    		--runs a program created by Worm from the AMS Forum to convert .jpgs to .bmps
    		File.Run(_SourceFolder .."\\JPG2BMP.EXE", img .. ";;" .. _WindowsFolder .. "\\ams5.bmp", "", SW_MINIMIZE, true);
    		setreg = true;
    	elseif imagesplit.Extension == ".bmp" then
    		--copy the image to the windows folder
    		File.Copy(img, _WindowsFolder .. "\\ams5.bmp", false, true, true, true, nil)
    		setreg = true;
    	else
    		Dialog.Message("Error","The image you have selected is not supported.");
    		setreg = false;
    	end
    	--sets the registry value for tile and stretch
    	if setreg == true then
    		Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "TileWallpaper", tile, REG_SZ);
    		Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "WallpaperStyle", style, REG_SZ);
    		DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. "\\ams5.bmp\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    	end
    end
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  2. #2
    Join Date
    Jul 2003
    Posts
    710
    That's an excellent function, rock on!

    Here's the thread with the app, should anyone need it:
    http://www.indigorose.com/forums/sho...hlight=jpg2bmp

  3. #3
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,159
    Quote Originally Posted by Desmond
    That's an excellent function, rock on!

    Here's the thread with the app, should anyone need it:
    http://www.indigorose.com/forums/sho...hlight=jpg2bmp
    Thanks Desmond. I was going to attach the file but the forum told me it was too large. I have it hosted on my site as well. Here it is.

    JPG2bmp.zip
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  4. #4
    Join Date
    Jul 2003
    Posts
    710
    ya, my original plan was to attach it to the thread, but i got the same error. ahh well. Thanks for hosting it!
    Last edited by Desmond; 07-20-2004 at 03:05 PM.

  5. #5
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    I'm happy to upload stuff for anyone anytime. Would you like me to transfer the file to our site and edit the link Tigger?

    Corey Milner
    Creative Director, Indigo Rose Software

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,159
    Corey,

    That would be great. That way if I accidently delete if from my site I don't break the link.

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  7. #7
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    K. I'll do it after dinner and let you know in this thread. Rock on.

    Corey Milner
    Creative Director, Indigo Rose Software

  8. #8
    Join Date
    Feb 2004
    Posts
    2
    Great Function, makes my live much easier. Now I am waiting just to get the same for a Screensaver which is defined as a file within the project

  9. #9
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,159

    Wallpaper with unique filename

    Here is the function that uses the image name to create a new wallpaper.

    Code:
    --[[
    **************************************************************************************
    ** Use this function if you want each wallpaper you assign to have it's own name.	**
    ** WARNING I suggest you use the above for testing so you don't end up with a lot 	**
    ** of different names in your Wallpaper dialog.  The following function is the same **
    ** as the above but uses the name of the selected image as the name of the 			**
    ** wallpaper image instead of ams5.bmp.												**
    **************************************************************************************
    ]]--
    
    function SetWallpaper(tile,style,img)
    	local imagesplit = String.SplitPath(img)
    	if imagesplit.Extension == ".jpg" then
    		--runs a program created by Worm from the AMS Forum to convert .jpgs to .bmps
    		File.Run(_SourceFolder .."\\JPG2BMP.EXE", img .. ";;" .. _WindowsFolder .. imagesplit.Filename .. ".bmp", "", SW_MINIMIZE, true);
    		setreg = true;
    	elseif imagesplit.Extension == ".bmp" then
    		--copy the image to the windows folder
    		File.Copy(img, _WindowsFolder .. imagesplit.Filename .. ".bmp", false, true, true, true, nil)
    		setreg = true;
    	else
    		Dialog.Message("Error","The image you have selected is not supported.");
    		setreg = false;
    	end
    	--sets the registry value for tile and stretch
    	if setreg == true then
    		Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "TileWallpaper", tile, REG_SZ);
    		Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "WallpaperStyle", style, REG_SZ);
    		DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. imagesplit.Filename .. ".bmp\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    	end
    end
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  10. #10
    Join Date
    Oct 2003
    Location
    dallas tx
    Posts
    16

    what about themes?

    I've used this code on my project, and it works great. I have been looking for the code to change the theme on XP (using valid theme file such as Luna) nad ahve not found it. I have found third party apps that can do this (settheme.exe), but am wanting to have this be a pure registry and or dll function. Im thinking it has something to do with uxtheme.dll or user32.dll but my knowledge of dll's stop there. Any help or links to where i can help myself would be much appreciated.

  11. #11
    Join Date
    Aug 2004
    Posts
    47

    Wallpaper

    I saw this string on setting wallpaper on the users computer with a click, but I can get it to work. I cut and pasted the info below onto the global function, and also put the other info on my picture. But I don't know where ot change the file name.

    thanks

  12. #12
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,159
    Are you wanting to change the input file name or the output file name.

    The input is changed when you call the function.

    function SetWallpaper(tile,style,img)

    The output is changed here
    function SetWallpaper(tile,style,img)
    local imagesplit = String.SplitPath(img)
    if imagesplit.Extension == ".jpg" then
    --runs a program created by Worm from the AMS Forum to convert .jpgs to .bmps
    File.Run(_SourceFolder .."\\JPG2BMP.EXE", img .. ";;" .. _WindowsFolder .. imagesplit.Filename .. ".bmp", "", SW_MINIMIZE, true);
    setreg = true;
    elseif imagesplit.Extension == ".bmp" then
    --copy the image to the windows folder
    File.Copy(img, _WindowsFolder .. imagesplit.Filename .. ".bmp", false, true, true, true, nil)
    setreg = true;
    else
    Dialog.Message("Error","The image you have selected is not supported.");
    setreg = false;
    end
    --sets the registry value for tile and stretch
    if setreg == true then
    Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "TileWallpaper", tile, REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "WallpaperStyle", style, REG_SZ);
    DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. imagesplit.Filename .. ".bmp\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    end
    end
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  13. #13
    Join Date
    Aug 2004
    Posts
    47

    wall paper

    thanks for your reply, I am fairly new with codes. What I am trying to do is give the user 3 choices of wall paper. I have a little thumbnail that when the user rollsover a larger image fades in so they can get a better look at it.

    Underneath the thumbnail I give the user the option of 800 by 600 or
    1024 x 768

    so when he clicks on the numbers I would like a jpg to load to his desktop.

    So with the code above. Do I put it into the global? and then I link the text 800 X 600 to the .jpg file that will go to their desktop? What action do I put on the link?

    Willie

  14. #14
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,159
    If I understand correctly you want to do this.

    Your two images are based on two resolutions, lets call them Tigg1024x768.jpg and Tigg800x600.jpg. You have the above function loaded in your global functions area and then when they click the button or label you would do the following.

    Code:
    SetWallpaper(0, 2, "AutoPlay\\Images\\Tigg1024x768.jpg")
    --Tile of 0 equals no tile and style of 2 equals stretched.
    The function will then do the rest, in the case of using the jpg it will convert to bmp (Tigg1024x768.bmp) and copy the file to the _WindowsFolder, set the registry accordingly and apply the new wallpaper.

    for the other image you would do this
    Code:
    SetWallpaper(0, 2, "AutoPlay\\Images\\Tigg800x600.jpg")
    You could even go so far as the label your two options 1024x786 and 800x600 then when they click the button you could use that res as part of the name.

    Code:
    sRes = Button.GetText(this)
    SetWallpaper(0, 2, "AutoPlay\\Images\\Tigg".. sRes ..".jpg")
    
    --Or if your buttons were named Tigg1024x768 and Tigg800x600 the same as your images without the extension you could do this
    --sNameandRes = Button.GetText(this)
    --SetWallpaper(0, 2, "AutoPlay\\Images\\".. sNameandRes ..".jpg")

    I hope that helps. I kept thinking of ideas as you can probably note, so I hope that those ideas help rather than add confusion.

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  15. #15
    Join Date
    Aug 2004
    Posts
    47

    wall paper

    I think that i am getting close, thanks for your patients

    So I copy the code for the button, and in the actions for the label that i have, I paste it on the click, and change the name in the code to match my file?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. INFO: JET and MDAC (Complete) Runtime Notes
    By Desmond in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 11-28-2003, 08:35 AM
  2. INFO: JET 4.0 SP7-SP8 Runtime Notes
    By Desmond in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 11-28-2003, 08:34 AM
  3. INFO: Setup Factory and the Windows Installer
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-22-2002, 10:38 AM
  4. INFO: Setting Environment Variables
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-10-2002, 12:07 PM
  5. HOWTO: Install Files to the Windows Directory
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 09-18-2002, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts