Computing.Net > Forums > Programming > VB.NET picture question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB.NET picture question

Reply to Message Icon

Name: FBI Agent
Date: January 10, 2006 at 19:22:09 Pacific
OS: Windows XP Home
CPU/Ram: 1.79GHz Celeron/ 384MB DD
Comment:

im trying to make a program that randomly chooses a picture out of a folder to use as my new desktop background.

i have everything done except the code where i would right click on the image and choose "set as desktop background". all of the files and folders are saved on my computer and everything works perfectly...

actually... another problem that i have with this is when i resize the images to fit in my program some pictures become blurry. is there a way to fix that? i dont have my exact code with me right now but i would be able to tell you if what you did was the same. and yes, when i resize the image, i make it the same ratio as the original. thanks a lot for any help!

FBI Agent

AIM: EliteAssassin187



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: January 11, 2006 at 03:51:02 Pacific
Reply:

THe desktop wall paper is set using the registry key:
HKEY_CURRENT_USER\Control Panel\Desktop\ConvertedWallpaper

I don't know how to refresh yet...but let me test something....

Chi

They mostly come at night...mostly.


0

Response Number 2
Name: Chi Happens
Date: January 11, 2006 at 04:48:24 Pacific
Reply:

Forget about the registry...
Here is some code to do it in c# (you should be able to convert this to vb.net pretty easily)

if(openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
System.IO.Stream s = new System.Net.WebClient( ).OpenRead( openFileDialog1.FileName );

System.Drawing.Image img = System.Drawing.Image.FromStream( s );
string tempPath = Path.Combine( Path.GetTempPath( ), "wallpaper.bmp" ) ;
img.Save( tempPath , System.Drawing.Imaging.ImageFormat.Bmp ) ;
SystemParametersInfo( SPI_SETDESKWALLPAPER,
0,
tempPath,
SPIF_SENDWININICHANGE );
}


you also need this stuff:


[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;

const int SPI_SETDESKWALLPAPER = 20 ;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;


Hope this helps,
Chi

They mostly come at night...mostly.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


I cant connect to the int... trace shared folder acces...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB.NET picture question

vb.net DataGridView question www.computing.net/answers/programming/vbnet-datagridview-question/15220.html

Questions vb.net www.computing.net/answers/programming/questions-vbnet/12968.html

VB.NET Image Path Questions www.computing.net/answers/programming/vbnet-image-path-questions/17618.html