primary,focus,here,allow,display,forms,larger
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
RentACoder Stats

 Code:  lines
 Jobs: 0 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for RentACoder.
Wrapping Scrolling Text
By Paranoid_Androi d on 7/2


Create A Dummy File
By AML on 7/2


Click here to see a screenshot of this code!Captionbar manipulation!
By Peter Hebels on 7/2

(Screen Shot)

A Game Of War
By Co0nest on 7/2


Click here to see a screenshot of this code!KeyGen Example
By Bengie|NET on 7/2

(Screen Shot)

Click here to see a screenshot of this code!OpenBrowser v1.9
By Orlando Jerez on 7/2

(Screen Shot)

SendMessageBySt ring() Example
By Jaime Muscatelli on 7/2


Click here to see a screenshot of this code!FirstSunday
By Jan Paul Penning on 7/2

(Screen Shot)

Click here to see a screenshot of this code!Ikonz v1.0
By Gaurav Creations on 7/2

(Screen Shot)

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
 
VB icon
Submitted on: 6/9/1997
By: VB Tips and Source Code 
Level: Not Given
User Rating: By 106 Users
Compatibility:

Users have accessed this code 16396 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 langauges 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 s
    //     creen!
    // 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://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.153/lngWId.-10/qx/vb/scripts/ShowCod
    //     e.htm    //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 scrollbars
    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 form 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 form 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:

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