Web Browser Control Does maintain shape after Resizing.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdamOnAccess
    New Member
    • Aug 2008
    • 99

    Web Browser Control Does maintain shape after Resizing.

    I have an access form with a web browser control and I'm trying to enable it to resize with the form. The code causes the web browser control to shink and grow to the exact dimensions of the form, and leaves space at the top for the rest of the access form...

    Code:
    Private Sub Form_Resize()
    On Error GoTo ResizeError
    'resize the browser object with the form
    
    'Turn off screen redraw
    Dim dblHeaderHeight As Double
    dblHeaderHeight = 1.5833
    
    Application.Echo False
    Me!wbbWebsite.Height = Me.InsideHeight - dblHeaderHeight
    Me!wbbWebsite.Width = Me.InsideWidth
    'Turn screen redraw back on
    Application.Echo True
    
    Exit Sub
    ResizeError:
    
    ' NB: Turn screen redraw back on if an error occurs!
    On Error GoTo 0
    
    End Sub
    The code seems to work fine during the event; it resizes to the exact dimensions. Problem is, after it resizes, if I try to enter text INTO the web browser control, or I click on the record selector at the bottom, the web browser control immediately expands over the entire access form and covers the portion at the top.

    Does anyone know how to correct it?
    Thanks,
    -Adam
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    This sounds like something else (not included in your post) is responsible for the resizing. The code as posted clearly works (as you've explained it), so we (You first obviously) need to start looking elsewhere. What about the properties of the form and/or the browser control? Any other code that may be resizing it?

    Comment

    • AdamOnAccess
      New Member
      • Aug 2008
      • 99

      #3
      Hi NeoPa,

      Thanks for the reply. I commented out the following lines. The program does not work, but the problem stopped. The browser does not change shape at all, but when I click on the record selector or add text to a field in the browser, it does not expand and over take the rest of the form.

      If I set it back, the problem comes back. It obviously involves the "Application.Ec ho". Beyond that, I can't figure it out.
      Code:
      'Turn off screen redraw
      Dim dblHeaderHeight As Double
      dblHeaderHeight = 1.5833
      
      'Application.Echo False
      'Me!wbbWebsite.Height = Me.InsideHeight - dblHeaderHeight
      'Me!wbbWebsite.Width = Me.InsideWidth
      'Turn screen redraw back on
      'Application.Echo True
      
      Exit Sub

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Good logical thinking Adam. Clearly it is related to this code somehow. I'm really not sure I can see how though.

        dblHeaderHeight looks a bit suss though. When does it actually show the expected size? I would never expect it to as that value seems to be in something quite different from Twips. Centimetres or inches or something. I would actually expect it to fill up your whole form, or at least so nearly all of it that you wouldn't notice any gap.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          I'm literally running out the door, but isn't it a matter of measurement. InsideHeight is measured in Twips, so subtracting a dblHeaderHeight of 1.5883 would give you the InsideHeight of the Form - .001 inch (1.5883/1440).
          Code:
          Me!wbbWebsite.Height = Me.InsideHeight - dblHeaderHeight

          Comment

          • AdamOnAccess
            New Member
            • Aug 2008
            • 99

            #6
            Nice Job. You nailed it.

            1.5833 * 1440 = 2279.952

            when dblHeaderHeight = 2279.952, the code works perfectly.

            Odd how it initially worked in inches, but then snapped to the full form the moment you touched it.

            Thanks,
            Adam

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by AdamOnAccess
              Nice Job. You nailed it.

              1.5833 * 1440 = 2279.952

              when dblHeaderHeight = 2279.952, the code works perfectly.

              Odd how it initially worked in inches, but then snapped to the full form the moment you touched it.

              Thanks,
              Adam
              You are quite welcome, Adam.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32656

                #8
                Originally posted by NeoPa
                dblHeaderHeight looks a bit suss though. When does it actually show the expected size? I would never expect it to as that value seems to be in something quite different from Twips. Centimetres or inches or something. I would actually expect it to fill up your whole form, or at least so nearly all of it that you wouldn't notice any gap.
                I guess you missed this then ;)

                Comment

                • AdamOnAccess
                  New Member
                  • Aug 2008
                  • 99

                  #9
                  NeoPa,

                  I didn't miss it. That "Nailed It" was directed at both of you. :)

                  Many thanks for your help.

                  The thing that still puzzles me is the way the error showed up. How come it first adjusted the web browser control in inches and, only after you entered text or clicked the record selector, would it snap over the whole form? How come it didn't cover the entire form immediately? Had it done that, I would have known where to look, but since it came up correctly, I didn't think that value was suspect.

                  Either way, thanks again for all your help.
                  -Adam

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32656

                    #10
                    Originally posted by AdamOnAccess
                    NeoPa,

                    I didn't miss it. That "Nailed It" was directed at both of you. :)

                    Many thanks for your help.
                    My bad Adam. Must have been short on patience that day :)
                    Originally posted by AdamOnAccess
                    The thing that still puzzles me is the way the error showed up. How come it first adjusted the web browser control in inches and, only after you entered text or clicked the record selector, would it snap over the whole form? How come it didn't cover the entire form immediately? Had it done that, I would have known where to look, but since it came up correctly, I didn't think that value was suspect.
                    Very good question Adam. Again, that's exactly what I was getting at in my earlier response. It may be interesting to see for myself if you have no problem posteing the database. It doesn't need everything if you have sensitive stuff in it. Just enough to illustrate the problem, and some instructions on how to reproduce it. I'll just copy in some instructions for posting databases here :
                    When attaching your work please follow the following steps first :
                    1. Remove anything not relevant to the problem. This is not necessary in all circumstances but some databases can be very bulky and some things do not effect the actual problem at all.
                    2. Likewise, not entirely necessary in all cases, but consider saving your database in a version not later than 2003 as many of our experts don't use Access 2007. Largely they don't want to, but some also don't have access to it. Personally I will wait until I'm forced to before using it.
                    3. If the process depends on any linked tables then make local copies in your database to replace the linked tables.
                    4. If you've done anything in steps 1 to 3 then make sure that the problem you're experiencing is still evident in the updated version.
                    5. Compile the database (From the Visual Basic Editor select Debug / Compile {Project Name}).
                    6. Compact the database.
                    7. Compress the database into a ZIP file.
                    8. When posting, scroll down the page and select Manage Attachments (Pressing on that leads you to a page where you can add or remove your attachments. It also lists the maximum file sizes for each of the allowed file types.) and add this new ZIP file.

                    It's also a good idea to include some instructions that enable us to find the issue you'd like help with. Maybe some instructions of what to select, click on, enter etc that ensures we'll see what you see and have the same problems.

                    Comment

                    • AdamOnAccess
                      New Member
                      • Aug 2008
                      • 99

                      #11
                      Ok NeoPa,

                      Here it is:

                      I converted the database to mdb format. I'm on 2007, but the problem still showed up in the mdb version.

                      To see the error, open the database and open the form "frmBrowser 1".

                      The form will open and execute docmd.Maximize

                      The Web Browser Control should automatically resize to the full screen, except for the header space above it, which is approximately 1.5 inches.

                      The Web Browser Control is set to open to the Google home page.

                      When Google comes up, enter a single character into the Google homepage text box. You should see the web browser control immediately expand and cover the whole form.

                      The question is, when dblHeaderHeight is set to 1.5833, why would Access first display the control in inches, but then, after you enter text into the control, it immediately converts to twips and expands over the whole form?

                      P.S.
                      As you might imagine, I'm very new to this web browser control. Please check my list of events in the property sheet of the web browser control. It only shows 5 possible events. I know there must be more and I don't know how to access them. I tried bringing up the custom property sheet but I got an error: "The operation on the microsoft web browser failed. Ole Server may need to be reinstalled." Any light you can shed on that would also be appreciated.

                      As Always,
                      Thanks,
                      Adam
                      Attached Files

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32656

                        #12
                        Well Adam. I must say I'm equally confused.
                        1. The value of Me.wbbWebsite.H eight won't display in the dubugger. This makes determining exactly what's going on when, and tying things down, all quite difficult :( I never could work out why the code even appeared to work in the first place.

                          BTW I'd code it anyway, as :
                          Code:
                          Me.wbbWebsite.Height = Me.InsideHeight - Me.wbbWebsite.Top
                          This is far more intuitive and has the bonus of never requiring to be changed as it will always match exactly.
                        2. I too, see the list of events as only five. Bizarre. In the debugger window you can enter new Event Procedures by selecting wbbWebsite from the left-hand ComboBox and the relevant event from the right-hand one. Why these are not all available in the Properties Pane I don't know.

                        Maybe it's just a weird control. Certainly I saw all the things you describe.

                        Comment

                        • ADezii
                          Recognized Expert Expert
                          • Apr 2006
                          • 8834

                          #13
                          It only shows 5 possible events. I know there must be more and I don't know how to access them.
                          1. In Form Design View.
                          2. View ==> Code.
                          3. Select wbbWebsite in the Object Drop Down List in the Upper Left Corner of the Code Window.
                          4. In the Drop Down List in the Upper Right Corner, of the Code Window, you will now see more Events than you can handle that are associated with the Web Browser Control.

                          Comment

                          • AdamOnAccess
                            New Member
                            • Aug 2008
                            • 99

                            #14
                            NeoPa,

                            Yes, your recode is a definite improvement. If I change the layout of the form and the browser control, I won't have to mess with the code at all. Nice!

                            Interesting side note...

                            In my property sheet, the TOP property is set at 1.625 (this is in inches).

                            For the heck of it, I tried this...

                            Code:
                            'Me!wbbWebsite.Height = Me.InsideHeight - Me!wbbWebsite.Top
                            Debug.Print Me!wbbWebsite.Top
                            ...and the debug window showed 2340

                            Correct me if I'm wrong but I interpret this to mean that Access is always using twips. The application options will display my measurement setting of inches in the property sheet, but ultimately, Access is using twips.

                            As far as uncovering additional events, I found them in the drop down as you and ADezii described. I've never seen a control with an incomplete property sheet. I didn't no the event would still get picked up if it wasn't listed in the property sheet. Good thing to know.

                            As far as my coming upon a "weird" browser control... yeah, that would be just like me. :)

                            Hey, thanks again for all the help.
                            You too, ADezii,

                            - Adam

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32656

                              #15
                              Originally posted by AdamOnAccess
                              Yes, your recode is a definite improvement. If I change the layout of the form and the browser control, I won't have to mess with the code at all. Nice!
                              Thank you. I'm glad I was able to help.
                              Originally posted by AdamOnAccess
                              Interesting side note...

                              In my property sheet, the TOP property is set at 1.625 (this is in inches).

                              For the heck of it, I tried this...

                              Code:
                              'Me!wbbWebsite.Height = Me.InsideHeight - Me!wbbWebsite.Top
                              Debug.Print Me!wbbWebsite.Top
                              ...and the debug window showed 2340

                              Correct me if I'm wrong but I interpret this to mean that Access is always using twips. The application options will display my measurement setting of inches in the property sheet, but ultimately, Access is using twips.
                              That's always been my understanding yes. How it shows to you is down to the Regional Settings in your PC I believe.

                              Comment

                              Working...