Results 1 to 6 of 6

Thread: Another Newbie Question

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    China Lake, CA
    Posts
    12

    Another Newbie Question

    Using image/picture boxes to display simple BMPs I have had the following problem:

    The picture will look fine on my machine, but when the software is transfered to a different machine the size of the image (with respect to the rest of the form) has changed. This is unacceptable, but I'll be derned if I can find the fix....

    Help?

  2. #2
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    hmmm

    u could have it resize the picture at startup, like so:
    'use an image and set stretch to true

    [Highlight=VB]
    private sub form1_load
    image1.left = (form1.width / (enter frm1.width on ur comp here) )_
    * (enter image1.left on ur comp here)
    end sub

    do same theing for top, replacing width with height
    this is also good if u dont know what sfcreen resoultion will be.
    Don't pay attention to this signature, it's contradictory.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    China Lake, CA
    Posts
    12
    image1.left = (form1.width / (enter frm1.width on ur comp here) )_
    * (enter image1.left on ur comp here)


    Can you explain what this line of code does? I mean, it appears to me that the quantity in parenthesis would always evaluate to 1, so image1.left would remain unchanged. I'm not saying you're wrong, I'm saying I don't get it.....

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    If you want to have the Form always the exact size of the bitmap, you'd use an Image control.
    VB Code:
    1. Private Sub Form_Load()
    2.    Me.ScaleMode = vbPixels
    3.    If Me.ScaleWidth < Image1.Width Then
    4.       Do
    5.          Me.Width = Me.Width + Screen.TwipsPerPixelX
    6.       Loop Until Me.ScaleWidth = Image1.Width
    7.    Else
    8.       Do
    9.          Me.Width = Me.Width - Screen.TwipsPerPixelX
    10.       Loop Until Me.ScaleWidth = Image1.Width
    11.    End If
    12.  
    13.    If Me.ScaleHeight < Image1.Height Then
    14.       Do
    15.          Me.Height = Me.Height + Screen.TwipsPerPixelY
    16.       Loop Until Me.ScaleHeight = Image1.Height
    17.    Else
    18.       Do
    19.          Me.Height = Me.Height - Screen.TwipsPerPixelY
    20.       Loop Until Me.ScaleHeight = Image1.Height
    21.    End If
    22.    Image1.Left = 0
    23.    Image1.Top = 0
    24. End Sub
    It's a bit of a roundabout way of doing it, but I don't know how the borders of the form factor into the width/height.

    Enjoy!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    sql_lall
    Guest

    Talking A different way:

    A slightly different way, something LIKE this:
    VB Code:
    1. 'only pseudo-code
    2. Private Sub Form_Load()
    3. ScreenX = Screen.Width
    4. ScreenY = Screen.Height
    5. image1.left = 1/5 * ScreenX
    6. image1.top = 1/4 * ScreenY
    7. image1.width = 1/2 * ScreenX
    8. image1.height = 1/3 * ScreenY
    9. End Sub

    The top-left corner *SHOULD* be 1/5 in and 1/4 down from the top-left of the screen.
    The bottom-right corner *SHOULD* be (1/5+1/2) in and (1/4 + 1/3) up from the bottom-left of the screen.

    You could do this, or just resize the screen (it is possible, just don't ask me how)

  6. #6
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Heh that's exactly how I did it Sas
    It's a bit weird but you never know the size of the border of the forms on other computers.

    sql_lall, I'm afraid that's not always true, the position of the forms always seems pretty random to me

    Ah well... what happened to the puzzling questions we used to answer about 1 or 2 months ago?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

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