Results 1 to 16 of 16

Thread: Got 2 Problems about resizing form

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Got 2 Problems about resizing form

    As I said in the title, I encountered two problems, with the resizing action of the Form!

    They would be the following:

    The first is that I have made a scrolling (as is used to do) with two Pictureboxes (one of which scrolls into the other).
    I have added two ScrollBars (vertical and horizontal), and I have set them for the positioning and for the dimensions; but I can't understand where the problem arises (in particular, in horizontal scrolling), following the instructions regarding this operation, when I resize the Form, the value of the bar no longer corresponds ...

    I'm working on it!


    The second, however, is that in the same project, I created a frame, in which I inserted a Textbox (or a Label; I saw that the same thing happens!): How do you make the Textbox resize according to to the size of the Frame (it seems to me that the measurement 'scales' do not correspond)?

  2. #2
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Got 2 Problems about resizing form

    The problem could be in different types of ScaleMode PictureBox, Frame and Form.

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form

    But seems we cannot set scalemode for each elements...
    We can!?

  4. #4
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Got 2 Problems about resizing form

    The scaling is calculated using simple arithmetic. How do you scale up?

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Got 2 Problems about resizing form

    I'm not really sure what you are asking in terms of scalemode. Just keep in mind that scalemode does not change the size of anything. It is just a setting that allows you to use a different base measurement. The default is twips but you may want to use pixels changing the scale mode does not change the size of the control it simply changes the scale of the values. If you want controls to resize then you have to write code that resizes/repositions them as needed.

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form

    Please, try it for yourself!

    I'm sure, I've set everything to the same ScaleMode:

    But I can't do it.
    I am inserting an example proj!
    Attached Files Attached Files

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Got 2 Problems about resizing form

    From you sample project
    Code:
    Command1.Top = Frame1.Height
    Command1.Left = Form1.ScaleWidth - Command1.Width
    
    Command2.Top = Form1.ScaleHeight - Command1.Height
    Command2.Left = Form1.ScaleWidth - Command1.Width
    
    Command3.Top = Form1.ScaleHeight - Command3.Height
    Command3.Left = Form1.Width - Command3.Width
    Command 1 size is not in pixels. showing a width of 1935 compared to 161.25 on command 3
    You also forgot to use the math for the height so if the scale was correct it would not show as it would be past the bottom of the frame.

    Command 2 uses math based on command 1 which is a much higher value due to scale and causes it to be drawn off screen.
    command 3 math does not use scale width so it is also drawn off screen

  8. #8
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Got 2 Problems about resizing form

    For example, like this:
    Code:
    'Frame1.Top = 0
    'Frame1.Left = 0
    'Frame1.Height = Form1.ScaleHeight - Command2.Height
    'Frame1.Width = Form1.ScaleWidth
    Command1.Top = Frame1.Height * Screen.TwipsPerPixelY - Command1.Height
    Command1.Left = Frame1.Width * Screen.TwipsPerPixelX - Command1.Width
    
    Command2.Top = Form1.ScaleHeight - Command2.Height - Command3.Height
    Command2.Left = Form1.ScaleWidth - Command2.Width
    
    Command3.Top = Form1.ScaleHeight - Command3.Height
    Command3.Left = Form1.ScaleWidth - Command3.Width
    Last edited by Argus19; May 12th, 2021 at 08:42 AM.

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Got 2 Problems about resizing form

    It seems that a button placed in the frame does not get the scalemode of the form.

    I would suggest changign the scalemode of the form to the default twips and avoid the issue.

  10. #10
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Got 2 Problems about resizing form

    Quote Originally Posted by DataMiser View Post
    It seems that a button placed in the frame does not get the scalemode of the form.
    The button is bound to Frame1

  11. #11

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form

    Hello again!

    So ...

    DataMise, I actually did this example on the fly, just to show you what was happening ...

    But only now that you pointed it out to me, I saw that one of the problems arises from the fact that the control is linked to the Frame: I hadn't noticed that it changed automatically, once created inside it!


    And, Argus19, "Screen.TwipsPerPixelY" etc., I hadn't really taken it into consideration, as I thought the two measures were enough!


    Anyway thanks!

    Now I'll try again, in my program, and let's see what effect it has, also on the other controls !!

  12. #12

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form

    ... and Ps:

    DataMiser:

    "... Command 2 uses math based on command 1 which is a much higher value due to scale and causes it to be drawn off screen."

    This is my textual error!

    Each Command always went with its number.

    (In fact I had written the difference between

    Form1.ScaleHeight
    and
    Form1.Height

    but then in the rush to hurry up, I made a mistake)



    ---

    And in fact:

    Command2.Top = Form1.ScaleHeight - Command 2.Height
    Command 2.Left = Form1.ScaleWidth - Command2.Width



    This is how it works !!
    Last edited by ProgyReloaded; May 12th, 2021 at 10:34 AM.

  13. #13

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form

    Now...Now...

    And I conclude:


    How is it possible (if possible), to set a Label or a Textbox in Pixel or Twips, within a Frame, if you don't want to use the Argus19 method !?

    (Do I just have to do the mathematical calculation !?

    Isn't there any module that takes care of it, that you know !?
    Because it's a little nerve-wracking to have to do this every time for each Control.)

  14. #14

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form

    Ok!

    Found something!

    dim InPixels as integer
    dim InTwips as integer

    InPixels = (N)
    InTwips = InPixels * Screen.TwipsPerPixelX
    InPixels = InTwips / Screen.TwipsPerPixelX


    and

    Const pixelize As Double = 26.45833333

    This can help!

    But if you know something else,
    let me know!

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Got 2 Problems about resizing form

    Quote Originally Posted by ProgyReloaded View Post
    Now...Now...

    And I conclude:


    How is it possible (if possible), to set a Label or a Textbox in Pixel or Twips, within a Frame, if you don't want to use the Argus19 method !?
    Twips is the default mode. You only run into the types of issues you were having when you change this to something else.
    I wasn't aware until I looked at your project that the controls in a frame do not get the forms scalemode but then I rarely ever use anything other than twips for my forms so I have not had any issues with it.

  16. #16

    Thread Starter
    Member
    Join Date
    Mar 2021
    Posts
    59

    Re: Got 2 Problems about resizing form



    I'm obsessed with the Pixel setting ... !!!

    'Playful video' deformation !!


    Anyway:
    "There is always something to learn!"
    (and to me, who am not a professional, it is always nice to find out!)



    Until next time!

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