PDA

View Full Version : Hunh?


ScottDuncan
04-10-2005, 12:33 PM
I'm working on a SetDesktop Backround function that i found here in the forum somewhere. I don't need all the user interaction that the .apz included, so i stripped out a bunch of the code. I simply need a button that onClick sets the desktop to an image that i specify and stretched to fit. I rearranged the code in a seperate project and it works perfectly. It includes a function call (on a button) and a global function. All seemed well.

Then in the project that i want to use this function, i placed the function call on a button and the global function in the globals. i also made sure to place the .jpg and the JPG2BMP.exe in the DOC folder.

It locks up my project and fails to function. i don't get it. i copied the code directly from a working version. Any help is always appreciated.

Here is my code (it's the same in both the working version and the broken one);

function call (onButtonClick)
SetWallpaper("Xplugz - Anne Frank 01 (Flor00).jpg", "Xplugz - Anne Frank 01 (Flor00)");

global function
function SetWallpaper(img, imgName)
imagesplit = String.SplitPath(img)
File.Run("AutoPlay\\Docs\\JPG2BMP.EXE", img .. ";;" .. _WindowsFolder .. "\\"..imgName..".bmp", "", SW_MINIMIZE, true);
Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "TileWallpaper", 0, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "WallpaperStyle", 2, REG_SZ);
DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. "\\"..imgName..".bmp\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end

(I'm a beginner at coding so i write a lot of "Longhand code". In my function call, i send the filename without the extension for filenaming purposes, i just haven't figure the String.SplitPath action yet)

TJ_Tigger
04-10-2005, 09:15 PM
Here try this


function SetWallpaper1(img, imgName)
if not File.DoesExist(img) then
--If file does not exist then exit the code might want a dialog message here.
return
end
--split path name to get extension.
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 .."\\"..imgName.. ".bmp", "", SW_MINIMIZE, true);
else
File.Copy("image", _WindowsFolder .. "\\" .. imgName .. ".bmp", false, true, true, true, nil)
end
--sets the registry value for tile and stretch
Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "TileWallpaper", 0, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "WallpaperStyle", 2, REG_SZ);
DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. "\\" .. imgName .. ".bmp\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end


The SplitPath action splits the file name and path into sections that are returned in a table. Look at the help file to see what the parts are returned and what the table items are named.

Tigg