|
-
Nov 30th, 2006, 07:01 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Replacing form's picture at runtime
Hi,
I use a borderless form and a picture as the background. I'm thinking about adding an "options" area at the bottom of my form. With a click of the button I'd extend the form and show some controls (options). Another click of the same button and I shorten the form hiding the controls in the process.
But since I use a picture in the background I'm thinking I'd have to replace the picture at runtime along with extending/retracting the form itself. I don't want to load the picture from file any time I wan't to show the options.
All I can think of is having two image controls outside the form's boundaries and copying a curently needed picture to my form's background.
Is there a better way (more efficient or preffered) of doing that?
-
Nov 30th, 2006, 07:06 PM
#2
Re: Replacing form's picture at runtime
Why not just use a picture that is big enough to fill the form when it is extended (to show the options)?
-
Nov 30th, 2006, 07:19 PM
#3
Thread Starter
Hyperactive Member
Re: Replacing form's picture at runtime
Thanks for the replay,
It's a custom form picture with border all around so if I did that then I would loose the bottom border. That's the only problem.
Unless I could just move the image of the bottom few pixels and always keep it at the bottom but I have no idea how.....
-
Dec 1st, 2006, 02:10 AM
#4
Re: Replacing form's picture at runtime
if you still want to replace the form's picture at run time you can do that by setting
VB Code:
Form1.Picture = Form2.Image1.Picture
Or even you can have two image controls in the same form and use Visible = True and Visible = False accordingly for each image control based on the Option menu clicks
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Dec 1st, 2006, 03:49 AM
#5
Re: Replacing form's picture at runtime
You don't need to load the picture again to resize it:
VB Code:
Private Sub Command1_Click()
Me.Height = Me.Height * 1.2
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
End Sub
Private Sub Form_Resize()
Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight
End Sub
-
Dec 1st, 2006, 02:58 PM
#6
Fanatic Member
Re: Replacing form's picture at runtime
you could also use a resource file that has all of the pictures you need and just load them when you need them:
PictureBox1.Picture = LoadResPicture()
-
Dec 1st, 2006, 05:18 PM
#7
Thread Starter
Hyperactive Member
Re: Replacing form's picture at runtime [Resolved]
Good ideas. I wen't with one of my own.
I just use the longest image for form when it's extended. I also have an image control with just a bottom border that I keep where the edge of the shorter form would be. I show the image for short form and hide for fully extended board.
VB Code:
Private Const FORM_SHORT As Long = 4185
Private Const FORM_LONG As Long = 6120
Private Sub Command1_Click()
If Me.Height = FORM_SHORT Then
imgBottom.Visible = False
Me.Height = FORM_LONG
Else
Me.Height = FORM_SHORT
imgBottom.Visible = True
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|