Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Basic Screen Saver

Status
Not open for further replies.

gpalmer711

IS-IT--Management
May 11, 2001
2,445
0
0
GB
I have designed a Screen Saver In visual Basic that will scroll through a list of pictures. I am using a Picture control to display the pictures and the pictures scroll through at a rate determined by the user. If all the pictures are the same size/or streched to be the same size i.e. 800 x 600 then there is no problem. However if I use the autosize option of the Picture control then the screen saver stops when ever the Picture control resizes. Does anybody know a way round this?

Many Thanks
 
If you already know the sizes of your pictures you could programmatically resize your control to suit, or use several picture controls of varying sizes.

Ralph
 
I have though of this and that works perfectly fine. However I have designed this for an artist friend of mine who will be issuing this screen saver to display his art work. He will be issuing updates for the screensaver from his website. So If I change the size of the control at design time then I will need to update the software each time he releases a new picture. Where as if I can get the screen saver to autosize the control then there will be no need to change the software.
To try a different route, is there any way to find out the size of a picture without actually loading it?
 
Hey gpalmer711

There is a way to find out the size of a picture. I assume you use a picturebox to display the pictures? In that case use the following code:

Picture1.Height = Picture1.Picture.Height
Picture1.Width = Picture1.Picture.Width

Hope this helps,

Thei
 
I am now able to resize the control OK however I also have a piece of code that centers the Picture control in the middle of the screen. The pt & pl variable have been declared and the loldheight is a variable that contains the the current height of the screen dependent on screen resolution i.e. 800 x 600 resolution makes loldheight = 600.

When the final 2 lines of code execute it causes the screen saver to stop responding.

pt = ((loldheight * Screen.TwipsPerPixelY) - Picture1.Height) / 2
pl = ((loldwidth * Screen.TwipsPerPixelX) - Picture1.Width) / 2
Picture1.Top = pt
Picture1.Left = pl

Does any one know of a way to keep a picture control centered on the screen without using the above code?

Many thanks
 
Did you try using a backward slash (\) instead of the forward slash for division? The backward leaves the result in integer form. I don't know if this will make a difference, but it's probably worth a try.

formula \ 2 instead of formula / 2
 
I have just tried that but it makes no difference, it is actually the following lines that cause the app to stop. If I remove them then the screen saver runs without problems.
Picture1.Top = pt
Picture1.Left = pl
 
Figured it out myself, all I had to do was set the picture controls enabled property to false.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top