Results 1 to 7 of 7

Thread: [RESOLVED] Replacing form's picture at runtime

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Resolved [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?
    Thanks

    Tomexx.

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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)?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    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.....
    Thanks

    Tomexx.

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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:
    1. 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.


  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Replacing form's picture at runtime

    You don't need to load the picture again to resize it:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Me.Height = Me.Height * 1.2
    3. End Sub
    4.  
    5. Private Sub Form_Load()
    6.     Me.AutoRedraw = True
    7. End Sub
    8.  
    9. Private Sub Form_Resize()
    10.     Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight
    11. End Sub

  6. #6
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    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()

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Resolved 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:
    1. Private Const FORM_SHORT As Long = 4185
    2. Private Const FORM_LONG  As Long = 6120
    3.  
    4. Private Sub Command1_Click()
    5.   If Me.Height = FORM_SHORT Then
    6.     imgBottom.Visible = False
    7.     Me.Height = FORM_LONG
    8.   Else
    9.     Me.Height = FORM_SHORT
    10.     imgBottom.Visible = True
    11.   End If
    12. End Sub
    Thanks

    Tomexx.

Posting Permissions

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



Click Here to Expand Forum to Full Width