forms width property

I try to put forms widht property value 20000 but it takes only values up to 18000. Is there some kind of limit to this value or setting which puts limit to that value??

Thanks in advance!
Who is Participating?
wsh2Connect With a Mentor Commented:
Yes.. <smile>.. Use the Screen.Width and Screen.Height properties to get the size of the screen in Twips. Here is a Form_Load routine that I often use to intitialize my opening form.

Private Sub Form_Load ()

    Left = Screen.Width * .1
    Top = Screen.Height * .1
    Width = Screen.Width * .8
    Height = Screen.Height * .8

End Sub

This will center the form on the screen with a fairly good working size. You can change the decimals to anything you prefer.. or if you want to fill the whole screen.. don't multiply the screen values by anything.

Yes, it has to do with your screen resolution size. Forms can only be as big as the Screen.Width + about 180 twips.

If you change your screen resolution, the maximum form width will change.

Now, for a more advanced technique, if you would like a little more performance out of the above example, use the Move method to save the program from having to execute extra Resize events.. (the parameters in the Move method are Left, Top, Width, Height)

Me.Move _
    (Screen.Width * .1, _
    Screen.Height * .1, _
    Screen.Width * .8, _
    Screen.Height * .8)

The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

It means that you have good display with 1200 pixels (18000/15) horizontal screen resolution.
majalaAuthor Commented:
I did it like this (I wanna my form to fill whole screen):

    Left = 0
    Top = 0
    Width = Screen.Width
    Height = Screen.Height

but somehow my forms width isn't even near to screens width? Height worked OK.
After the Form_Load.. are you changing Form.Width anywhere else? Perhaps in your Form_Resize procedure? Call up your Code Window, and then do a Find on the word Width.. because somewhere else in your program (after Form_Load) you are changing it.

Trust me on this.. Screen.Width works.. <smile> and a <wink>.
majalaAuthor Commented:
I don't have any problems to trust you on this :) and normally this has worked OK but I don't know why it isn't working now like it has before.
Even if I'm on forms design window I can't stretch my form more than width 17700. My screen resolution is 1280x1024.
I checked that I don't set that forms width property anywhere else than forms load procedure.
majalaAuthor Commented:
If I change my screen resolution to 1600x1200 and reboot my machine and then tretch form, it works OK
mcrider --
You say forms can only be about as big as your screen resolution, plus about 180 twips. Is this a design-time limitation, or a run-time limitation?

I have good eyes, so I tend to keep my screen resolution pretty high.

I'm writing a program that calls up a form that then prints on 8.5 by 11-inch paper. (I've got a routine that prints it landscape, thanks to an earlier post here.) The form pretty much fills the paper (form size ~ 9.5 by 7.5 inches), and I haven't had a problem getting it to work on my computer. I've also had it work on two other computers it's been tested on, but they were both set to pretty high screen resolution, too.

If I get someone running a 640 by 480 screen, is this going to not work?

The form is not resized at run-time. Nor is it ever rendered for the screen. Its form load event loads data into about 200 fields, executes the print routine, and unloads the form.

You've got me worried now...

You said:

  "You say forms can only be about as big as your screen resolution, plus about 180 twips. Is this a design-time limitation, or a run-time limitation?"

The answer is BOTH!

A form can only be as wide as the screen.width property + 180 twips in both design and runtime.... HOWEVER...

Pictureboxes can be as wide as you want.  What you can do is put everything in a picturebox and use scrollbars to move the image around.

Normally this requires 2 pictureboxes. One is the "View Port" and the other contains the image and is a child of the first picturebox.  You then use the scrollbar to adjust the top and left of the image...

If this helps you, please reject the current answer and select this comment as the answer....

majala -- sorry to piggyback on your question like this, but hopefully the answers I'm getting will be helpful to you, too.

mcrider --

If I have all my stuff in pictureboxes, wouldn't my whole form print _as a picture_? This wouldn't do for me, because I have some fairly small type on the form (as small as 7 point), which doesn't render well as a graphic.

That's why I chose to go with a pain-in-the-tush routine for printing my forms landscape (courtesy of roverm) rather than the Micro$oft-recommended method of dumping things into a picturebox in the first place.

(It will cost you 20 points in PAQ to read through the exchange I had with roverm, but here's the link: 
I can save you some points, if you don't need to see all the text but want his answer. We exchanged e-mails and he sent a project to me that had the code in it. The code from the project is *NOT* listed in the above question, but my e-mail address is, and I'll gladly forward the project to anyone who asks for it. Just ask at

Unfortunately, I'm fairly new to VB, and self-taught (though I used to be about as good as anyone at Applesoft, on my Apple ][+, in the early '80s). So there's a heck of a lot I don't understand about how what roverm sent me works.

Is there no means around this size limitation that doesn't require rendering the form as a picturebox, mcrider?


p.s. Come up with one and I'll post you some points, too.

I didn't realize that you didn't ask the question... Piggybacking... UUgh!

Sorry majala, but here goes the answer to Barry's question:

I am assuming that you are using:

   Form.Print "some text"

to build your screen.  If you are, you can use the same routine you used to print on the form to print to the printer... With a few minor adjustments.  For example, lets say you have the following subroutine to print:

    Sub PrintTheScreen(lObject As Object)
        Dim IsPrinter As Boolean
        If lObject.hDC = Printer.hDC Then
            IsPrinter = True
            'LIKE:  Printer.Orientation = vbPRORLandscape
        End If
        With lObject
            .CurrentX = 200
            .CurrentY = 200
            .FontSize = 12
            lObject.Print "Hello World"
            .FontSize = 7
            .CurrentX = 200
            lObject.Print "This is a test"
            'If the object is the printer, do the EndDoc
            If IsPrinter = True Then .EndDoc
        End With
    End Sub

You can then call the subroutine like this to print to the form:

   PrintTheScreen Form1
You can call the same subroutine to print to a picturebox that is scrolled:

   PrintTheScreen Picture1

AND... You can send the stuff to the printer like this:

   PrintTheScreen Printer

That should be worth some points! ;-)

mcrider --

Normally I'm not keen on piggybacking, but I felt my question relates to majala's as well.

I'm about to post a new question in the VB area wherein we can continue this, if you would be so kind.

majala -- Thanks for the hospitality! Sorry to barge in!

-- b.r.t.
mcrider -- I've posted this in its own thread at the following address: 

I added a lot of background about the code provided by roverm for printing forms landscape, so it's a doozy to read through. Thanks for any help!
majala -- Erick37 posted a solution for me that will probably work for you, too. Here's the beginning of his text:

<====Start copy====>
You can make the form any size you want.  Windows has a MINMAXINFO structure which holds info regarding a window's minimum and maximum sizes.  By subclassing your form, you can intercept the WM_GETMINMAXINFO message and then set the max size to whatever you like.  Then you will be able to set the form's width and height beyond the screen.


"HOWTO: Limit a Window's Minimum and Maximum Size"
<====End copy====>

There are additional comments posted about how this is used later in the thread of my question. Click the link above to follow it all.

If his answer works for you, you might consider throwing a few points his way, in addition to whatever you award to the people who have responded here!

-- b.r.t.
All Courses

From novice to tech pro — start learning today.