Solved

# forms width property

Posted on 2000-03-09
238 Views
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??

0
Question by:majala
• 5
• 3
• 3
• +2

LVL 14

Accepted Solution

wsh2 earned 30 total points
ID: 2603622
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.

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.

0

LVL 14

Expert Comment

ID: 2603628
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.

0

LVL 14

Expert Comment

ID: 2603633
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)

0

LVL 27

Expert Comment

ID: 2603650
Hi
It means that you have good display with 1200 pixels (18000/15) horizontal screen resolution.
Cheers
0

Author Comment

ID: 2603682
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.
0

LVL 14

Expert Comment

ID: 2603734
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>.
0

Author Comment

ID: 2603953
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.
0

Author Comment

ID: 2603988
If I change my screen resolution to 1600x1200 and reboot my machine and then tretch form, it works OK
0

LVL 7

Expert Comment

ID: 2604770
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...

Thanks
0

LVL 14

Expert Comment

ID: 2604896
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?"

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...

0

LVL 7

Expert Comment

ID: 2605006
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: http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10265730
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 barrytice@hotmail.com.)

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?

b.r.t.

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

LVL 14

Expert Comment

ID: 2605159
BarryTice,

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
'SEE IF THE PASSED OBJECT IS THE PRINTER
If lObject.hDC = Printer.hDC Then
IsPrinter = True
'LIKE:  Printer.Orientation = vbPRORLandscape
End If
'PRINT YOUR STUFF TO THE OBJECT
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! ;-)

0

LVL 7

Expert Comment

ID: 2605218
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.
0

LVL 7

Expert Comment

ID: 2605309
mcrider -- I've posted this in its own thread at the following address:
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10308833

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!
0

LVL 7

Expert Comment

ID: 2605529
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.

Example:

"HOWTO: Limit a Window's Minimum and Maximum Size"
http://support.microsoft.com/support/kb/articles/Q185/7/33.ASP
<====End copy====>

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.
0

## Featured Post

### Suggested Solutions

Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games. Â  The game allows for a choice of who goes first and keeps track of the number of wins forâ€¦
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we aâ€¦
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). Uâ€¦
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that aâ€¦