|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Re-size Print Previewthe screen. So far so good - it works. What must I do to permit the user to enlarge the display if something is too small to be read and they want enlarge it? What must I do to permit the user to reduce the display and view the entire page on the screen? Thank you, Jim Y Here is some of the code: =============================== Option Explicit 'switch to determine whether Query or Wedding Query Public gEventType As Integer 'switch to determine whether screen display or printer copy Public gScrnPrntr As String 'use Screen or Printer to identify Private Sub Form_Load() 'gEventType 0 for Wedding Query, 1 for General Query 'NOTE Since the form is in twips, the PictureBox must be positioned ' and sized using twips. In the PictureBox, inches are used. ' Try 1.2 enlargement and 0.6 reduced size (full screen) for form Pic.ScaleMode = 5 'inches in the PictureBox, Form1 is twips Pic.Width = 8.5 * 1440 '12,240 twips wide Pic.Height = 11 * 1440 '15,840 twips high Pic.Top = 0.25 * 1440 '360 twips wide Pic.Left = (Screen.Width - Pic.Width) / 2 With VScroll1 .Left = Pic.Left + Pic.Width 'Position VScroll1 on right of Pic .Top = 0 '1440 .Height = 10360 '7200 .Max = 60 '60% instead of 100% to not go up too far .LargeChange = 30 'two clicks to scan full page - 60/30=2 .SmallChange = 6 'ten clicks to scan full page - 60/6=10 End With Private Sub mnuQueryDisplay_Click() Pic.Cls gEventType = 1 'for General Query gScrnPrntr = "Screen" 'use Screen or Printer Call QueryForms 'in ModDisplay End Sub End Sub ================================================== Public Sub QueryForms() Dim strPrinted As String 'date & time form was printed - reserved Dim strPrntStrng As String 'combined items on one line Dim intEventType As Integer 'Zero (0) for Wedding, One (1) for General Dim strType As String Dim Obj As Object 'Form1.Pic or Printer <SNIP> 'Get Date and time of printing strPrinted = "Printed: " & Format(Now, "ddd, mmm, dd, yyyy") _ & " " & Format(Now, "hh:mm AM/PM") If Form1.gScrnPrntr = "Screen" Then Set Obj = Form1.Pic ElseIf Form1.gScrnPrntr = "Printer" Then Set Obj = Printer Else Exit Sub End If 'Get Query/Wedding Query switch intEventType = Form1.gEventType 'Draw border around the page - 0.62 inch border all around Obj.DrawWidth = 4 Obj.Line (0.62, 0.62)-(7.88, 10.25), , B 'Print Company Name, Adress and Phone numbers Obj.FontName = "Arial" Obj.FontSize = 12 Obj.FontBold = True Obj.CurrentX = 0.69 Obj.CurrentY = 0.66 Obj.Print "ABCDEFGHIJKLMNOPQRSTUVWXYZQWE" <SNIP> "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message There are at least three (probably more than three) different ways of doing news:UYYYe.302042$5N3.18508@bgtnsc05-news.ops.worldnet.att.net... > I have a test program that permits display of the form (preview) at full > size using a PictureBox on the screen. So far so good - it works. What > must I do to permit the user to enlarge the display if something is too > small to be read and they want enlarge it? What must I do to permit the > user to reduce the display and view the entire page on the screen? this, and they all have their advantages and disadvantages. A simple StretchBlt of your picture box image is one way that would enable you to make the size anything you want, but I would definitely advise that you should *not* use that method in your specific case (too much loss of detail because of the very limited resolution of the original "image"). Of the other two methods that I have in mind, one would permit very easy scrolling of a "magnified or enlarged" image (in much the same way as you are presumably currently crolling the full size page) and the other one would make such scrolling more difficult (as far as the amount of code is concerned) to accomplish. Much depends on how much magnification you wish to provide. The "harder to implement" method would permit almost limitless magnification, but if you are happy with up to two or three times the width and two or three times the height then you can use the easier method. That's quite a large magnification when you see it in practice, and it makes it possible to fairly comfortably read text as small as 3 points in size. In fact, even a 200 percent magnification makes it possible to read 4 point text, and such a magnification (using the method I have in mind) would require a contiguous block of memory of only about 13 megabytes for your autoredraw picture box, an amount that is always available even on very low end systems. Basically what you do is create your picture box and set its ScaleWidth to 8.5 and its ScaleHeight to 11 and you use coordinates for your drawings and text as though those units are inches (even though they are not). The actual size of the picture box (Width and Height) does not matter. It can be almost anything you wish. If you want it to display the page at "full size" (as you currently seem to be doing) then you also set the Width and the Height to 8.5 and 11 respectively, first making sure that you set it's "container's" Scalemode, at least temporarily, to vbInches. The "container" could either be a Form or perhaps another Picture Box (I would suggest the latter). You will of course need to maintain a variable of type Single (let's call it "magnification") and in this case (full size page) you would set "magnification = 1". If instead you wanted a "200 per cent magnified page" you would set the picture box Width and Height properties to 17 and 22 respectively, again making sure that it's "container's" ScaleMode is vbInches when you do so but you still set the ScaleWidth to 8.5 and the ScaleHeight to 11. Then you set the variable "magnification" to 2. You will, of course, have to provide the user with a facility to "scroll the very large page" within its container so that he can see the various parts of it, but I notice that you already seem to have provided such a facility for the vertical direction so it obviously won't be any trouble for you to do the same for the horizontal direction as well. Alternatively, if you wanted a "smaller than full page" size (so that you could fit the entire page onto the screen regardless of the user's display size and resolution) you would set the picture box Width property to 8.5 * 0.7 and its Height property to 11 * 0.7 and you would set the variable "magnification" to 0.7 also. Again, you would set the ScaleWidth to 8 and the ScaleHeight to 11 (you never set these to values other than those). Obviously I've chosen the value "0.7" at random. In practice you would calculate that value such that the page would be displayed in full on whatever size and resolution display is currently in use. Because the ScaleWith is always 8.5 and the ScaleHeight is always 11 you can draw your lines and circles and boxes and paint your pictures and metafiles and things using those coordinates just as though they were real inches. The only thing you need to do differently is the font size for whatever text you write on the page (because the font size in VB is always set in "points", and a point is a point, no matter what you set the ScaleWidth and ScaleHeight to). So, when printing your text you should set the font size in accordance with the current contents of the "magnification" variable (which was set to 1, 2 or 0.7 in the above three examples). So, for example, if you needed 12 point text you would use Obj.Font.Size = 12 * magnification. There is a very slight catch to this (isn't there always!) because the actual font sizes of True Type fonts are limited to "whole pixel" values, and the size you get will be the size you ask for to the nearest whoole pixel (which is very, very close to the desired size on a typical high resolution printer and only "quite close" to the desired size of the rather limited resolution of a typical monitor). However, unless you are printing stuff that required clean and straight "fully justified text" you won't have much problem with that. There are, of course, ways to achieve nice clean fully justified text that justifies at exactly the same character on the printer as it does on the screen, but I don't think you'll need to get into that sort of stuff for your own specific application. Anyway, that's the "bare bones" of it. I won't have time to write any actual code for you (under orders to wash all the "green stuff" off the top of our little motorhome today!) but I'm sure you will be able to code it yourself, looking at the stuff you have already done. Other people here may have other suggestions for you of course. This is just one option for you to consider. The big advantage of this method is that the print routines for your picture box and for your printer can be exactly the same (obviously you would set the variable "magnification" to 1 when printing to the printer). There may be a few points I've missed (in a bit of a rush at the moment) but if there are I'm sure others here will point them out for you. Mike "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message .. . . by the way, one thing I forgot to mention is that when you send your news:UYYYe.302042$5N3.18508@bgtnsc05-news.ops.worldnet.att.net... output to the printer you should leave its ScaleWidth and ScaleHeight properties alone. Just set its ScaleMode property to vbInches (and your "magnification" variable to 1) and leave it at that. Also, as you may or may not be aware, most printers have "unprintable margin" into which they simply cannot deposit ink (even printers that can print "full bleed" pages usually default to the standard "unprintable margin" setting unless you change it). Basically, as far as VB is concerned the "page" (when using US Letter size 8.5 x 11 inch paper as you are doing) is a "drawing rectangle" which usually measures 8 inches wide and sometimes 11 inches high and sometimes less than that. Also, the individual "unprintable margins" (top, left right and sometimes bottom) are different sizes on different printers (even when using the same size paper). The printable area (which VB "sees") is therefore a rectangle that is slightly smaller than the page and whose top left corner is positioned somewhere near (but not actually at) the top left corner of the physical page. As far as VB is concerned, location (0, 0) is the top left corner of this printable rectangle (not the top left corner of the physical page). The actual size and position of this printable rectangle is different on different printers. This makes it impossible to accurately position stuff on your page with any reliability (unless you do something about it). VB does not expose these measurements for you, but you can easily get at them using an API routine. The following routine will sort it all out for you. If you call it (passing 0, 0, as its parameters) it will effectively "tell" VB that location (0, 0) is exactly at the top left corner of the physical page for whatever printer happens to be currently in use. Thereafter you can forget all about it and simply regard your US Letter paper as an 8.5 x 11 inch rectangle where location (0, 0) is exactly at its physical top left corner and everything will be positioned exactly where you want it to be. Try it out. Mike Option Explicit Private Declare Function GetDeviceCaps Lib "gdi32" _ (ByVal hdc As Long, ByVal nindex As Long) As Long Private Const PHYSICALOFFSETX As Long = 112 Private Const PHYSICALOFFSETY As Long = 113 Private Sub SetPrinterOrigin(x As Single, y As Single) With Printer .ScaleLeft = .ScaleX(GetDeviceCaps(.hdc, PHYSICALOFFSETX), _ vbPixels, .ScaleMode) - x .ScaleTop = .ScaleY(GetDeviceCaps(.hdc, PHYSICALOFFSETY), _ vbPixels, .ScaleMode) - y .CurrentX = 0 .CurrentY = 0 End With End Sub Private Sub Command1_Click() Printer.ScaleMode = vbInches SetPrinterOrigin 0, 0 ' top left corner of physical page ' Now you can print your stuff accurately positioned End Sub "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message Oops! Slight "typo" in my first reply. I said:news:UYYYe.302042$5N3.18508@bgtnsc05-news.ops.worldnet.att.net... Alternatively, if you wanted a "smaller than full page" size (so that you could fit the entire page onto the screen regardless of the user's display size and resolution) you would set the picture box Width property to 8.5 * 0.7 and its Height property to 11 * 0.7 and you would set the variable "magnification" to 0.7 also. Again, you would set the ScaleWidth to 8 and the ScaleHeight to 11 (you never set these to values other than those). .. . . and I meant to say: Alternatively, if you wanted a "smaller than full page" size (so that you could fit the entire page onto the screen regardless of the user's display size and resolution) you would set the picture box Width property to 8.5 * 0.7 and its Height property to 11 * 0.7 and you would set the variable "magnification" to 0.7 also. Again, you would set the ScaleWidth to 8.5 and the ScaleHeight to 11 (you never set these to values other than those). (Note the "set the ScaleWidth to 8.5 and the ScaleHeight to 11" instead of "set the ScaleWidth to 8 and the ScaleHeight to 11). Sorry about that. Didn't want to cause confusion. Mike
Show quote
Hide quote
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message news:dh42lp$ge6$1@newsg3.svr.pol.co.uk... Sometime ago you gave me code about the printer border. Since then I include it in my programming. > "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message > news:UYYYe.302042$5N3.18508@bgtnsc05-news.ops.worldnet.att.net... > > Oops! Slight "typo" in my first reply. I said: > > Alternatively, if you wanted a "smaller than full page" size (so that you could fit the entire > page onto the screen regardless of the user's display size and resolution) you would set the > picture box Width property to 8.5 * 0.7 and its Height property to 11 * 0.7 and you would set the > variable "magnification" to 0.7 also. Again, you would set the ScaleWidth to 8 and the ScaleHeight > to 11 (you never set these to values other than those). > > . . . and I meant to say: > > Alternatively, if you wanted a "smaller than full page" size (so that you could fit the entire > page onto the screen regardless of the user's display size and resolution) you would set the > picture box Width property to 8.5 * 0.7 and its Height property to 11 * 0.7 and you would set the > variable "magnification" to 0.7 also. Again, you would set the ScaleWidth to 8.5 and the > ScaleHeight to 11 (you never set these to values other than those). > > (Note the "set the ScaleWidth to 8.5 and the ScaleHeight to 11" instead of "set the ScaleWidth to > 8 and the ScaleHeight to 11). > > Sorry about that. Didn't want to cause confusion. > > Mike Generally, I check for a 0.50 inch minimum border and warn the user if their printer requires a larger border. So far no one has had a problem. From my own printers I know that border is not always uniform about a page and can be as small as 0.15 inch. I am guessing 0.50 inch to be safe for most, if not all, printers I have had a *busy* couple of days and not able to do too much with this preview code. I have some of it resolved using your comments. I think it is up to my experimenting right now. (Nice thing about retirement, NO pressure to get it done! No deadline to meet.) If I have any questions, I will get back to you. I appreciate your comments. Thank you, Jim Y "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message Well not all printers, but certainly most of them. I've got a Citizen news:NqAZe.313534$5N3.1726@bgtnsc05-news.ops.worldnet.att.net... > From my own printers I know that border is not always uniform > about a page and can be as small as 0.15 inch. I am guessing > 0.50 inch to be safe for most, if not all, printers Printeva printer which needs a slightly larger bottom (or is it top?) border than that, about 0.6 inches as I recall (I haven't used it in ages). But 0.5 should be plenty for the top and bottom border on most printers, and about 0.25 for the left and right borders (depending on paper size). > I have had a *busy* couple of days and not able to do too much Exactly. I'm in the same "retired" club myself ;-)> with this preview code. I have some of it resolved using your comments. > I think it is up to my experimenting right now. (Nice thing about > retirement, > NO pressure to get it done! No deadline to meet.) > If I have any questions, I will get back to you. I appreciate Thanks. Let me know how you get on.> your comments. Mike > I think I have it all resolved with 8 point text, .625, 1.00, and 1.375 magnification. There is one > Thanks. Let me know how you get on. > > Mike thing that I have not been able to resolve and that is having the HScroll across the bottom of the screen. It is working above the PictureBox and not a problem. I am curious as to how I can get it across the bottom. The 2 or 3 things that I tried failed. Do you have any suggestions? I have made the scroll bars appear only on the views that need them and changed the MAX value to agree with the size displayed. As I said, I like to experiment with the code. When the program first starts, Pic2 displays "Query" at *full* size (1) and I give the user the option to change it to see the full sheet (.625) or enlarge it (1.375). Using those magnifications makes it easy with the 8 point text size and displays at nice sizes. I am sure that as I experiment with the program, I will be able to consolidate some of the code and not waste space with my typing. Thank you, Jim Y ============================================== Public gScrnPrntr As String 'use Screen or Printer to identify 'Size switch Public gScale As Single Private Sub Form_Load() 'gEventType 0 for Wedding Query, 1 for General Query 'gScale multiplier for screen display of form 'NOTE Since the form is in inches, the PictureBox(es) are in inches 'PictureBox scale Pic.ScaleMode = 5 'inches in PictureBox Pic2.ScaleMode = 5 'inches in PictureBox gScale = 1 'Begin with actual size display Pic.Width = 8.5 Pic.Height = 11 Pic.ScaleWidth = 8.5 Pic.ScaleHeight = 11 Pic.Top = 0.25 Pic.Left = (Screen.Width / 1440 - Pic.Width) / 2 Pic2.Top = 0 Pic2.Left = 0 Pic2.Width = 8.5 Pic2.Height = 11 Pic2.ScaleWidth = 8.5 Pic2.ScaleHeight = 11 With VScroll1 .Left = Pic.Left + Pic.Width 'Position VScroll1 on right of Pic .Top = 0 .Height = 7.2 .Max = 60 '60% instead of 100% to not go up too far .LargeChange = 30 'two clicks to scan full page - 60/30=2 .SmallChange = 6 'ten clicks to scan full page - 60/6=10 End With With HScroll1 .Left = Pic.Left 'Position HScroll1 above Pic .Top = Pic.Top - HScroll1.Height .Width = Pic.Width .Max = 100 .LargeChange = 40 .SmallChange = 5 End With HScroll1.Visible = False End Sub Private Sub HScroll1_Change() Pic2.Left = -(HScroll1.Value / 100) * ScaleWidth End Sub I thought I should explain further about the top/bottom HScroll1 position question. If I locate it
on the bottom of Pic, HScroll1 is off screen. If I make Pic height fit the screen, the height of Pic2 is distorted. Is there a method in which HScroll1 can remain at the bottom of the screen without being affected by the vertical scroll of Pic or the size of Pic? I am satisfied with the way I currently have it working, just curious at this time. Thank you, Jim Y Show quoteHide quote "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message news:VX2_e.83315$qY1.46637@bgtnsc04-news.ops.worldnet.att.net... > > >> Thanks. Let me know how you get on. >> >> Mike > > > I think I have it all resolved with 8 point text, .625, 1.00, and 1.375 magnification. There is > one thing that I have not been able to resolve and that is having the HScroll across the bottom of > the screen. It is working above the PictureBox and not a problem. I am curious as to how I can > get it across the bottom. The 2 or 3 things that I tried failed. Do you have any suggestions? > > I have made the scroll bars appear only on the views that need them and changed the MAX value to > agree with the size displayed. As I said, I like to experiment with the code. When the program > first starts, Pic2 displays "Query" at *full* size (1) and I give the user the option to change it > to see the full sheet (.625) or enlarge it (1.375). Using those magnifications makes it easy with > the 8 point text size and displays at nice sizes. I am sure that as I experiment with the > program, I will be able to consolidate some of the code and not waste space with my typing. > > Thank you, > Jim Y > > ============================================== > > Public gScrnPrntr As String 'use Screen or Printer to identify > 'Size switch > Public gScale As Single > > > Private Sub Form_Load() > > 'gEventType 0 for Wedding Query, 1 for General Query > 'gScale multiplier for screen display of form > > 'NOTE Since the form is in inches, the PictureBox(es) are in inches > > 'PictureBox scale > Pic.ScaleMode = 5 'inches in PictureBox > Pic2.ScaleMode = 5 'inches in PictureBox > > gScale = 1 'Begin with actual size display > > Pic.Width = 8.5 > Pic.Height = 11 > Pic.ScaleWidth = 8.5 > Pic.ScaleHeight = 11 > > Pic.Top = 0.25 > Pic.Left = (Screen.Width / 1440 - Pic.Width) / 2 > > Pic2.Top = 0 > Pic2.Left = 0 > Pic2.Width = 8.5 > Pic2.Height = 11 > Pic2.ScaleWidth = 8.5 > Pic2.ScaleHeight = 11 > > > With VScroll1 > .Left = Pic.Left + Pic.Width 'Position VScroll1 on right of Pic > .Top = 0 > .Height = 7.2 > .Max = 60 '60% instead of 100% to not go up too far > .LargeChange = 30 'two clicks to scan full page - 60/30=2 > .SmallChange = 6 'ten clicks to scan full page - 60/6=10 > End With > > With HScroll1 > .Left = Pic.Left 'Position HScroll1 above Pic > .Top = Pic.Top - HScroll1.Height > .Width = Pic.Width > .Max = 100 > .LargeChange = 40 > .SmallChange = 5 > End With > > HScroll1.Visible = False > > End Sub > > Private Sub HScroll1_Change() > > Pic2.Left = -(HScroll1.Value / 100) * ScaleWidth > > End Sub > "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message That's because you're making the container picture box (pic) to big. Itnews:rpb_e.84559$qY1.34193@bgtnsc04-news.ops.worldnet.att.net... > I thought I should explain further about the top/bottom HScroll1 > position question. If I locate it on the bottom of Pic, HScroll1 is > off screen. If I make Pic height fit the screen, the height of Pic2 > is distorted. should never exceed the height or width of the client area of the Form. You have to look on pic as a simple "look through window" such that when you look through it you can see the main page (pic2) "behind the window". Pic2 is usually much larger than pic, and you scroll the viewport using the scroll bars. Have a look at my previous message. Also, here is the code with additional stuff to set the height. Obviously there is more work to be done yet, but the following code shows how to properly size and position both picture boxes and the scroll bar(s). I haven't yet actually put in any code to control the scroll bars so that they scroll the page, but I'm sure you will be able to do that yourself. Run the following code and you should be able to run the Form in its Maximized state and also as a user resizable Form and the picboxes and the scroll bars should adjust accordingly as the user resizes the Form. Also, it should work on all display resolutions and dpi settings. Mike Option Explicit Private Declare Function SetParent Lib "user32" _ (ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long Private gScale As Single Private hScroll As Boolean Private vScroll As Boolean Private Sub SetPage() Me.ScaleMode = vbInches pic.ScaleMode = vbInches pic.BorderStyle = vbFixedSingle pic.BackColor = vbBlue pic2.AutoRedraw = True pic2.ScaleMode = vbInches pic2.BorderStyle = vbBSNone SetParent pic2.hWnd, pic.hWnd ' if you haven't done it in IDE pic2.Move 0, 0, 8.5 * gScale, 11 * gScale pic2.ScaleWidth = 8.5 ' always this value pic2.ScaleHeight = 11 ' always this value pic.BorderStyle = vbBSNone HScroll1.TabStop = False ' stop the annoying flashing VScroll1.TabStop = False ' of the scroll bars If Me.ScaleWidth >= (pic2.Width + VScroll1.Width) Then ' we can set the container to the same width as pic2 ' and we do not need a horizontal scroll bar pic.Width = pic2.Width pic.Top = 0 hScroll = False ' also we might as well put the scrollbar at the ' right hand edge of the Form VScroll1.Left = Me.ScaleWidth - VScroll1.Width VScroll1.Top = 0 ' and we might as well centre the "page" in what's left pic.Left = (Me.ScaleWidth - pic.Width - VScroll1.Width) / 2 Else ' size pic so that both pic and the vertical scrollbar ' fit across the available width of the Form and we ' do need a horizontal scroll bar pic.Width = Me.ScaleWidth - VScroll1.Width pic.Top = 0 hScroll = True ' put the scrollbar at the right hand edge VScroll1.Left = Me.ScaleWidth - VScroll1.Width VScroll1.Top = 0 ' and put the container at the right hand edge pic.Left = 0 End If ' ' If hScroll = False Then ' set container height to use all available height pic.Height = Me.ScaleHeight HScroll1.Visible = False VScroll1.Height = pic.Height Else ' allow room for horizontal scroll bar If (Me.ScaleHeight - HScroll1.Height) > 0 Then pic.Height = Me.ScaleHeight - HScroll1.Height End If HScroll1.Visible = True HScroll1.Left = 0 HScroll1.Top = pic.Height HScroll1.Width = pic.Width VScroll1.Height = pic.Height End If End Sub Private Sub Form_Load() Dim s1 As String, n As Long gScale = 1 ' show page at 100 per cent SetPage pic2.Font.Name = "Times new Roman" pic2.Font.Size = 12 * gScale s1 = "Just some sample text" For n = 1 To 100 pic2.Print s1 Next n End Sub Private Sub Form_Resize() SetPage End Sub "Mike Williams" <M***@WhiskyandCoke.com> wrote in message Placing a picturebox in another isn't the same as setting the parent. Unless news:dhbrkp$hhv$1@newsg4.svr.pol.co.uk... > pic.ScaleMode = vbInches > pic.BorderStyle = vbFixedSingle > pic.BackColor = vbBlue > pic2.AutoRedraw = True > pic2.ScaleMode = vbInches > pic2.BorderStyle = vbBSNone > SetParent pic2.hWnd, pic.hWnd ' if you haven't done it in IDE I'm missing something, you really should be using the picturebox's Container property. Set pic2.Container = pic -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Please keep all discussions in the groups.. "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message Nope. You're not missing anything, Ken. It's me that is missing something news:ONJKEB4wFHA.3756@tk2msftngp13.phx.gbl... > Placing a picturebox in another isn't the same as setting the parent. > Unless I'm missing something, you really should be using the > picturebox's Container property. Set pic2.Container = pic ;-) You are of course correct. Thanks for pointing it out. I'm sure that Jim will see your reply and will amend the example code accordingly. Time for a rum and Coke®, methinks ;-) Mike
Show quote
Hide quote
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message news:dhc223$i1r$1@news8.svr.pol.co.uk... I amended the line above, added the code to display the reduced and enlarged views and set the > "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message > news:ONJKEB4wFHA.3756@tk2msftngp13.phx.gbl... > >> Placing a picturebox in another isn't the same as setting the parent. >> Unless I'm missing something, you really should be using the >> picturebox's Container property. Set pic2.Container = pic > > Nope. You're not missing anything, Ken. It's me that is missing something ;-) > You are of course correct. Thanks for pointing it out. I'm sure that Jim will see your reply and > will amend the example code accordingly. Time for a rum and Coke®, methinks ;-) > > Mike scroll bars to not display wasted space. I appreciate the step-by-step notes. Thank you Mike and Ken for the help, Jim Y "Jim Y" <j.s.yablonsky@NOSPAM.att.net> wrote in message I think you may have slightly misunderstood my original answer Jim. In your news:VX2_e.83315$qY1.46637@bgtnsc04-news.ops.worldnet.att.net... > I think I have it all resolved with 8 point text, .625, 1.00, and 1.375 > magnification. > There is one thing that I have not been able to resolve and that is having > the HScroll across the bottom of the screen. It is working above the > PictureBox and not a > problem. I am curious as to how I can get it across the bottom. code (in the specific example you posted) you appear to be setting the size of *both* picture boxes to 8.5 x 11 inches in order to display your page at "actual" size (gScale = 1). That's not the way it should be done. For gScale = 1 ("actual size", or what MS Word calls "zoom to 100 per cent") the size of the "contained" picture box (pic2 in your example) should be 8.5 x 11 inches. Also, its BorderStyle (in all cases) should be vbBSNone. The Borderstyle of its container (pic in your example) should normally be vbFixedSingle. So, the first part of your code should be something like: gScale = 1 ' (the value 1 represents 100 per cent) Me.ScaleMode = vbInches pic.ScaleMode = vbInches pic.BorderStyle = vbFixedSingle pic.BackColor = vbBlue pic2.ScaleMode = vbInches pic2.BorderStyle = vbBSNone SetParent pic2.hWnd, pic.hWnd ' if you haven't done it in IDE pic2.Move 0, 0, 8.5 * gScale, 11 * gScale pic2.ScaleWidth = 8.5 ' always this value pic2.ScaleHeight = 11 ' always this value Note that in the above code I have also given the container picture box a blue background and the "contained" picture box a white background (the page). This makes it easy to spot errors in your coding, because if your code is done correctly then you should never see any of the blue, even when you move the scroll bars. So what we've got now is a container picture box (pic) that contains another picture box (pic2). Pic2 represents the printer page. The size of pic2 is 8.5 x 11 inches in this case (because we set gScale to 1) and the ScaleWidth / ScaleHeight of pic 2 is also 8.5 x 11 inches (note the ScaleWidth / ScaleHeight of pic 2 is *always* 8.5 x 11 inches regardless of the value of gScale, because pic2 always represents the full page). Notice that we have not yet set the size of the container (pic). It doesn't really matter how big the container is, as long as it is no larger than the pic2. The container (pic) is merely a "window" through which we can "look" and through which we can see all or part of the page (pic2). Now we need to set the size of the container (pic) to a sensible value. It needs to fit *entirely* into the client area of the Form and it also needs to leave a little room for the vertical scroll bar (and also the hoprizontal scroll bar if we need one). The container (pic) is *always* smaller than the client area of the Form. The next thing to do is have a look at your Form and see how much room there is for pic. This of course depends on how large your Form currently is, which depends on all sorts of things including the display resolution (800 x 600, 1024 x 768 etc), whether or not the Form is maximized, the current Windows dpi setting various other factors). This is all easily checked simply by using the Form's ScaleWidth property. So you check the ScaleWidth of the Form and and if the Form is wider than the combined widths of pic2 and the vertical scroll bar then you set pic Width (the container picbox) exactly equal to the width of pic2 and you do not need a horizontal scrollbar. However, if the Form's client area is less wide than the combined Widths of pic2 and the vertical scrollbar (which it almost certainly will be on a display running at 800 x 600 pixels) then you set pic2 Width to the same width as the client area of the Form (less the width of the vertical scrollbar), and you do need a horizontal scrollbar. A slight added complication is that the Width of pic (the container) includes its borders. You can either automatically account for this by adding suitable code or you can simplify things and also make pic (the container) a borderless picture box. For simplicity, let's use the latter option. So in addition to the above code you would also have the following: pic.BorderStyle = vbBSNone If Me.ScaleWidth >= (pic2.Width + VScroll1.Width) Then ' we can set the container to the same width as pic2 ' and we do not need a horizontal scroll bar pic.Width = pic2.Width pic.Top = 0 ' also we might as well put the scrollbar at the ' right hand edge of the Form VScroll1.Left = Me.ScaleWidth - VScroll1.Width ' and we might as well centre the "page" in what's left pic.Left = (Me.ScaleWidth - pic.Width - VScroll1.Width) / 2 Else ' size pic so that both pic and the vertical scrollbar ' fir across the available width of the Form pic.Width = Me.ScaleWidth - VScroll1.Width pic.Top = 0 ' put the scrollbar at the right hand edge VScroll1.Left = Me.ScaleWidth - VScroll1.Width ' and put the container at the right hand edge pic.Left = 0 End If Notice that we have not yet set the height of the vertical scroll bar or the width or position of the horizontal scrollbar (if we need one) or the height of the container picture box (pic). So, the next thing we need to do is to check how high the client area of the Form is (Me.ScaleHeight) and using that information in conjunction with the current value of the gScale variable and decide how high we should make the container picture box. I think that maybe it might be wise to leave that for the moment though (actually I'm in a rush to go sdomewhere). Read this stuff carefully and get it all working and then post back when you're ready for more. Mike |
|||||||||||||||||||||||