Results 1 to 13 of 13

Thread: Resize, scale width/height [re4solved]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resize, scale width/height [re4solved]

    VB Code:
    1. FrmSplitted.pic.ScaleMode = 3
    2. FrmSplitted.pic.ScaleWidth = xWidth
    3. FrmSplitted.pic.ScaleHeight = yWidth

    why does this code give me an error 'invalid property value? i need to resize a picture box how can this be done? what is the best method?
    Last edited by Pino; Jun 16th, 2004 at 02:15 PM.

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Which line is the error on?

    You can't do it like that....ScaleWidth & ScaleHieght are for reading from....In the Design time propertys if you change these values you will notice the ScaleMode changes to "User" which means you are setting a user defined scale. What you need to use is the frm.Width & frm.Height Propertys and the Screen.TwipsPerPixelX & Screen.TwipsPerPixelY
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    VB Code:
    1. With FrmSplitted
    2.         .ScaleMode = vbPixels
    3.         .pic.Move .pic.Left, .pic.Top, xWidth, yWidth
    4.     End With

    Scalewidth and scaleheight for pic returns the inner part of pic. So if you change the scalemode of pic, you change how values are displayed in pic's inner sizes. So instead of changing pic's scalemode, we change pic's host's scalemode and then resize pic according to this. There is an alternative method though...

    VB Code:
    1. With FrmSplitted
    2.         .pic.Move .pic.Left, .pic.Top, .ScaleX(xWidth, vbPixels, .ScaleMode), .ScaleY(yWidth, vbPixels, .ScaleMode)
    3.     End With

    Above code will convert pixels to the current used Scalemode of pic's host. Hope this helps

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'm sure just using the TwipsPerPixel is just as easy though

    VB Code:
    1. frmMain.Width = iWidth *Screen.TwipsPerPixelX
    2. frmMain.Height = iHeight *Screen.TwipsPerPixelY
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    But it doesn't work if ScaleMode is set to something else than vbTwips Move command is also two times faster than doing Width and Height calls separately.

  6. #6
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by Merri
    But it doesn't work if ScaleMode is set to something else than vbTwips Move command is also two times faster than doing Width and Height calls separately.
    Your thinking of the container.....the thign is the Form's Width & Height propertys are always in twips....if you change the scale mode of the form then it affects controls that it is the container for....to chnage the Width & Height properties to anything but twips would mean changing the forms containers ScaleMode and I don't think that is possibel . if you are changing the size of a picture box it is easy because you make the form's scale mode Pixel and the pictureboxes Width & Height propertys will turn into Pixel values .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    He is clearly using a picturebox on a form here, so you're kind of talking about the wrong thing I do know this and I also know Scales are not supported by Screen and that you need to use TwipsPerPixel to place form correctly to the screen (though I've rarely had any use for this).

  8. #8
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Doh!!!, I didn't see the .pic. part .

    In that case shouldn't this work:
    VB Code:
    1. FrmSplitted.ScaleMode = 3
    2. FrmSplitted.pic.Width = xWidth
    3. FrmSplitted.pic.Height = yWidth
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    Thanks Fellers

    [Resolved]

    Before these two start arguing

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    Originally posted by Electroman
    Doh!!!, I didn't see the .pic. part .

    In that case shouldn't this work:
    VB Code:
    1. FrmSplitted.ScaleMode = 3
    2. FrmSplitted.pic.Width = xWidth
    3. FrmSplitted.pic.Height = yWidth

    nope that doesnt work thats why i posted

  11. #11
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    It does work, and that's my first suggestion (vbPixels = 3, but you should always use these predeclared variables to keep code more readable).

  12. #12
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by Pino
    nope that doesnt work thats why i posted
    I don't think you spotted the change I made to your code (the first line & removed the Scale off the other lines)....I just checked it and yes it did work .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  13. #13
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by Pino
    Thanks Fellers

    [Resolved]

    Before these two start arguing
    If you don't mind adding -[Resolved]- to the title then . Thanx
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

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