Quick Search for:  in language:    
primary,focus,here,allow,display,forms,larger
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,011,557. lines
 Jobs: 117. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Visual Basic.
Click here to see a screenshot of this code!Advanced Mailprogram
By Henrico Bloemhof on 7/1

(Screen Shot)

Click here to see a screenshot of this code!A Simple Database WIth XP Design ( Without XP )
By Osen Kusnadi on 7/1

(Screen Shot)

Fractional Addition
By SAEED HASSAN on 7/1


Defrag at certain time
By Michael Nipper on 7/1


Click here to see a screenshot of this code!Extended Find Ver 2
By Roger Gilchrist on 7/1

(Screen Shot)

Y! Module
By NightCrawler on 7/1


Files Comperator (the right way)
By Jarry Claessen on 6/30


Simple UDP example
By Mick Walton on 6/30


CAPS Trigger
By Trevor Burley on 6/30


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Create a form bigger than the screen!

Print
Email
 

Submitted on: 6/9/1997
By: VB Tips and Source Code 
Level: Not Given
User Rating: By 4 Users
Compatibility:VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0

Users have accessed this code 22136 times.
 
 
     The primary focus here is to allow you to display forms that are larger than the screen can show. Need an 8˝" x 11" Form? NO Problem!The size used in this example is 8˝" x 11", but it could just as easily be landscape, envelope, or any needed size.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Create a form bigger than the sc
'     reen!
' Description:The primary focus here is 
'     to allow you to display forms that are l
'     arger than the screen can show. Need an 
'     8˝" x 11" Form? NO Problem!The size used
'     in this example is 8˝" x 11", but it cou
'     ld just as easily be landscape, envelope
'     , or any needed size.
' By: VB Tips and Source Code
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=153&lngWId;=1'for details.'**************************************

Place a Horizontal Scrollbar on the form (doesn't matter where) and Set its properties as follows: 
Height =300
LargeChange =900
Name= HScroll
SmallChange =30
These properties Do Not need To be identical to mine, but will serve as a good common ground starting point. You can always modify them to suit your needs and taste later. 
Now, let's place a Vertical Scrollbar On the form (doesn't matter where) and Set its properties as follows: 
LargeChange =900
Name= VScroll
SmallChange =30
Width=300
Now, For the magic. Place a PictureBox on your form and Set the following properties for it. The PictureBox will serve as our container for all controls and graphics that need To be placed on the virtual form. 
BackColor=&H00FFFFFF;&
Height =15900
Name= PicBox
Width=11640
There is one last control that we need To place on the virtual form. However, this control is Not placed directly onto the form but onto the picture box. It is a label that will serve as a filler to cover up the gap left between the two scrollbars In the lower right hand corner. Click on the PictureBox to Select it, Then Double click the Label control on the VB Toolbox. Make sure that the label is the same color as your scrollbars. Then Set its properties as follows: 
Height =300
Name= lblFiller
Width=300
From this point on, all of the control that are placed on the virtual form (the picturebox) are solely for our own visual evidence that the form does indeed move. Place any controls you wish and Set their properties as you wish on the form. (The downloadable project has already placed several controls on the picture box for you.) 
Let's start our Coding process by writing a routine To line everything up the way it should be. We need to place the scrollbars where they should go, make their dimensions match that of the form, and also position the lblFiller label properly. I have called this procedure AlignScrollBars(). This procedure needs to be placed in your General Decalrations section. The code looks like this: 
Sub AlignScrollBars()

' Resize the scrollbars HScroll.Width = Me.ScaleWidth - lblFiller.Width VScroll.Height = Me.ScaleHeight - lblFiller.Height ' Reposition the scrollbars HScroll.Left = 0: HScroll.Top = Me.ScaleHeight - HScroll.Height VScroll.Top = 0: VScroll.Left = Me.ScaleWidth - VScroll.Width ' Redimension the scrollbar parameters HScroll.Max = PicBox.Width - Me.ScaleWidth VScroll.Max = PicBox.Height - Me.ScaleHeight ' Reposition the PictureBox PicBox.Top = (-1 * VScroll) PicBox.Left = (-1 * HScroll) ' Reposition the Picturebox label by scr ' ollbars lblFiller.Top = VScroll.Height + VScroll - 30 lblFiller.Left = HScroll.Width + HScroll - 30 UpdateDisplay End Sub
Note the call To UpdateDisplay. That procedure is just For the fun of it. I have used it to create some text and a graphic on the form at run time. This is what the procedure looks like. For VB4: Sub UpdateDisplay()
' Place text on the PictureBox PicBox.AutoRedraw = True Dim PictureBoxText As String PictureBoxText = "Virtual Form - 8˝ x 11 size" With PicBox .Font = "Arial" .FontSize = 14 .FontBold = True .FontItalic = True .CurrentX = (PicBox.Width - PicBox.TextWidth(PictureBoxText)) / 2 .CurrentY = 0 End With
PicBox.Print PictureBoxText ' Graphics can be drawn on the virtual f ' orm at run time PicBox.Line (100, 100)-(500, 500), , B End Sub
For VB3: (since the With construct is only available in VB4.) Sub UpdateDisplay()
' Place text on the PictureBox PicBox.AutoRedraw = True Dim PictureBoxText As String PictureBoxText = "Virtual Form - 8˝ x 11 size" PicBox.Font = "Arial" PicBox.FontSize = 14 PicBox.FontBold = True PicBox.FontItalic = True PicBox.CurrentX = (PicBox.Width - PicBox.TextWidth(PictureBoxText)) / 2 PicBox.CurrentY = 0 PicBox.Print PictureBoxText ' Graphics can be drawn on the virtual f ' orm at run time PicBox.Line (100, 100)-(500, 500), , B End Sub
At this point, there are only three procedures left For us To code. We need to be able to realign the controls (scrollbars, etc) Each time the scrollbars are clicked and each time the form is resized. I have written these three procedures like this: (Of course in VB3 you will want to remove the Private keyword from the Sub line). Private Sub Form_Resize()
AlignScrollBars End Sub
Private Sub HScroll_Change()
AlignScrollBars End Sub
Private Sub VScroll_Change()
AlignScrollBars End Sub
Now, save your project and run the thing. If you have placed additional controls on the picturebox during design time, you should be able To see them float across the screen as your scroll around. Keep in mind that during design time, you can drag the picturebox around to work With the sections that are Not visible within the form. The code will line everything back up so you don't even have to clean up behind yourself.


Other 13 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/5/1999 3:45:00 PM:Jim Kelly
This is just what I need! I am very new 
to VB and am trying to print for the 
first time, so I decide to use 
PRINTFORM. The problem was I could only 
make a 7 x 5 form.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/21/1999 7:26:00 AM:Degziebob
This is almost what I'm looking for.  I 
need the above program but I ALSO need 
to be able to create & design things on 
the area of screen.  I have drawn lots 
of tables (like a football league ) 
that have arrays in them and I need to 
get them to be on the whole page.  
Anyone done this?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/24/1999 7:39:00 PM:Mike Thompson
The code for making a form bigger than 
the screen is good, but how can you 
print the whole document complete?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/1999 7:48:00 AM:Dennis Foley
I did everything, but when I use 
printform it doesn't work.  I get a 
gray box on half the page and nothing 
more.
I created a button to call 
printform, is this not right???
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/9/1999 2:40:00 AM:degziebob
update: got all my info on the 
picbox...but I CANT print the 
form/picbox onto an A4 page, and as far 
as I know you can't....so the code is 
virtually useless.  If anyone finds out 
how to do this then PLEASE EMAIL ME!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/19/1999 8:54:00 AM:Sridharan
I tried to scroll a large Form.  I 
succedded.  But one thing. My project 
is to have a full chart on one form.  
Like Splitter window of VC++, I need to 
create Y-axis with 10 items and X-Axis 
with 24 hrs each and each vertical line 
indicates 2 mins.  So I need to have 
more than 70,000 (in twips) width.  How 
do I?. It is grateful to U sir...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/21/1999 1:47:00 PM:smccarty
I am trying to design a Data Report in 
Landscape view, if anyone has done this 
please email your suggestions. Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/1/1999 12:49:00 PM:Gerry Kompleski
Thanks. The example let me create a 
form that worked. 
Upon creation of 
the form that is larger than the screen 
what is the code that will enable the 
end user to:
1.Use the page up/down 
keys to go through the page without 
having the focus on the scroll bar? 
(When the focus is on the scroll bar 
the keys work. But if the focus is on, 
let's say, a text box within the form 
those keys do not work.)
2.Go to the 
top/bottom when Ctrl home/end is 
pressed ?
3.Get the up/down arrow keys 
to scroll through multiple text boxes 
(as in excel)?
4.When tabbing down the 
form that is a row of text boxes I will 
tab to a text box lower than screen. 
How can I code the program to show the 
textbox on the screen that has been 
tabbed into?
I know this is a lot 
but any/all help would be appreciated. 
I am a novice that is just trying.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/21/1999 10:23:00 AM:Bill
Looks good but like other people I need 
to print
whole 8.5X11 screen and have 
been unable to using printform
.If 
anyone has a cure for this please e 
mail me.
Thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/28/1999 9:23:51 AM:The Journeyman
Okay, to all of those that cannot print 
the whole form:
Try painting the form 
onto a printer object.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/27/2001 10:58:15 AM:Mox
Wow!  Nice code, exactly what I was 
looking for too.  Thanks!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/7/2002 11:17:33 PM:Sharon Niles
Thank you, just what I was looking for. 
 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/26/2002 9:16:55 PM:George Renee
Looks good but like other people I need 
to print
whole 8.5X11 screen and 
have 
been unable to using 
printform
.If you has a remmedy for 
this please e 
mail me.
Thanks  
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/13/2002 6:39:50 PM:Glen Starrett
Note:  If you are using .Net and are 
searching for how to create a virtual 
area picturebox in VB.Net or C# (like I 
was...) then save yourself some time!  
The Panel class does exactly what you 
are probably looking for--just set 
AutoSize = True.  If you still want the 
picturebox control in it, then drop a 
picturebox control on top of a panel.  
Or, of course, you can roll your own 
control in .Net by inheriting the 
System.Windows.Forms.ScrollableControl 
class.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/26/2002 11:41:13 PM:
The code is very good! I can see that 
the form can be a larger than I ever 
tried.
But I still don't know about 
the code how to painting the form 
onto a printer object.
Please email 
me! Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/24/2002 12:56:45 PM:Anthony Dale Moore
Thank you this code helped alot.
Also 
those who are having trouble printing, 
you can also use the printer.pr method. 
a little bit of typing, but works
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/24/2002 12:57:49 PM:Anthony Dale Moore
printer.print*
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/18/2003 11:14:51 PM:
HOWTO: Print a Form That Is Too Large 
for the Screen or 
Page
http://support.microsoft.com/def
ault.aspx?scid=kb;EN-US;230502
Got a 
problem, ask the expert...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.