Results 1 to 5 of 5

Thread: resizing problem

  1. #1

    Thread Starter
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930

    resizing problem

    I've got a weird problem in a usercontrol. When I call the sub that does the repainting of it, I also force a resize (in the resize event is code that ensures the control has the right dimensions). Generally, it works fine, but when I change the orientation of the control (vertical vs horizontal), it won't size correctly, even though when I change the orientation property, I also call the resize part again. Sometimes if I force the resize event a few times, it will fix it, but that's really sloppy. Also when I've placed the control on a form and use the grab handles to resize it in the form, the size will snap back to what it's supposed to be, but only when the bottom, right, or bottom right corner grab handles were used. The others will allow the control to expand/shrink to the dragged size. Does anyone know why this might going on?
    Last edited by Kaverin; Jul 4th, 2001 at 07:27 PM.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    What is the code of the resize event??

  3. #3

    Thread Starter
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    All it does is force the right size:
    VB Code:
    1. Private Sub UserControl_Resize()
    2.    With UserControl
    3.       .Width = (intButtonWidth * IIf(ebsoButtonOrientation = EBSOrientations.bsHorizontal, intNumButtons, 1)) * Screen.TwipsPerPixelX
    4.       .Height = (intButtonHeight * IIf(ebsoButtonOrientation = EBSOrientations.bsVertical, intNumButtons, 1)) * Screen.TwipsPerPixelY
    5.    End With
    6.    DrawButtons
    7.    Debug.Print "resizing"
    8.    Debug.Print intButtonWidth * IIf(ebsoButtonOrientation = EBSOrientations.bsHorizontal, intNumButtons, 1), UserControl.Width \ Screen.TwipsPerPixelX
    9.    Debug.Print intButtonHeight * IIf(ebsoButtonOrientation = EBSOrientations.bsVertical, intNumButtons, 1), UserControl.Height \ Screen.TwipsPerPixelY
    10. End Sub
    If the orientation is horizontal, the final control width is equal to the number of buttons times the width of one button, and the height is just the height of one button. For vertical, the width is just one button, and the height is one button times number of buttons. In both cases, the single button dimension and the screen dimension are the same, so that IIf() will either return the number of buttons for the right size, or just 1 so it won't affect it. The rest is just what tells me the size currently is, and what it should be (in pixels). I've noticed the property window isn't always in synch, which is beyond my understanding... It's ticking me off.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  4. #4
    gaffa
    Guest
    As a general comment, setting the .Width and .Height of the UserControl in the UserControl_Resize event is generally a bad idea, cos setting either of those properties forces the Resize evetn to fire again....

    Use a module level boolean to flag whether or not you handle the resize:
    Code:
    Dim mbolResizing as Boolean 
    Private Sub UserControl_Resize()
        If not mbolResizing then
            mbolResizing = True
            .Width = lngTheNewWidth
            .Height = lngTheNewHeight
            mbolResizing = False
        End If
    End Sub
    - gaffa

  5. #5

    Thread Starter
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    I've tried that before, and it never worked. I've tried all sorts of things ... I'll still get the weird upperleft grabhandle problem. All the other directions are fine. But when the UL one is used, it can make both height and width change. That's when the sizing gets out of synch, and the grab handles will show a border larger than what it's supposed to be. I'd rather not leave it like that, but I might just have to add in a note or something about it. I just don't like this happening because my control only paints on a specific area, and if it's larger than what that area is, the other parts are left blank gray.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

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