Results 1 to 17 of 17

Thread: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

  1. #1

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Resolved [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

    Who know how to block popups from webbrowser component or to disable the scrollbar? or else no right click on the webbrowser component.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    This might help for the popup thing.

  3. #3

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Exclamation Re: block popups, disabe scrollbars, no right click in webbrowser component

    This code work for disable popup`s
    Code:
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    Cancel = True
    End Sub
    now i need something for disable the scrollbar of webbrowser. Any idea?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by RoYeti
    This code work for disable popup`s
    Code:
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    Cancel = True
    End Sub
    now i need something for disable the scrollbar of webbrowser. Any idea?
    Try this
    VB Code:
    1. Public Declare Function EnableScrollBar Lib "user32.dll" (ByVal hWnd As Long, _
    2. ByVal wSBflags As Long, ByVal wArrows As Long) As Long
    3.  
    4. 'SCROLLBAR CONSTS
    5. Public Const SB_HORZ As Long = 0
    6. Public Const SB_VERT As Long = 1
    7. Public Const SB_CTL As Long = 2
    8. Public Const SB_BOTH As Long = 3
    9.  
    10. Public Const ESB_DISABLE_BOTH = &H3
    11. Public Const ESB_DISABLE_DOWN = &H2
    12. Public Const ESB_DISABLE_LEFT = &H1
    13. Public Const ESB_DISABLE_RIGHT = &H2
    14. Public Const ESB_DISABLE_UP = &H1
    15. Public Const ESB_ENABLE_BOTH = &H0
    16.  
    17. 'Example usage for disabling:
    18. Call EnableScrollBar(WebBrowser1.hWnd, SB_BOTH, ESB_DISABLE_BOTH)
    19.  
    20. 'Example usage for enabling both:
    21. Call EnableScrollBar(WebBrowser1.hWnd, SB_BOTH, ESB_ENABLE_BOTH)

  5. #5

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by Hack
    Try this
    VB Code:
    1. Public Declare Function EnableScrollBar Lib "user32.dll" (ByVal hWnd As Long, _
    2. ByVal wSBflags As Long, ByVal wArrows As Long) As Long
    3.  
    4. 'SCROLLBAR CONSTS
    5. Public Const SB_HORZ As Long = 0
    6. Public Const SB_VERT As Long = 1
    7. Public Const SB_CTL As Long = 2
    8. Public Const SB_BOTH As Long = 3
    9.  
    10. Public Const ESB_DISABLE_BOTH = &H3
    11. Public Const ESB_DISABLE_DOWN = &H2
    12. Public Const ESB_DISABLE_LEFT = &H1
    13. Public Const ESB_DISABLE_RIGHT = &H2
    14. Public Const ESB_DISABLE_UP = &H1
    15. Public Const ESB_ENABLE_BOTH = &H0
    16.  
    17. 'Example usage for disabling:
    18. Call EnableScrollBar(WebBrowser1.hWnd, SB_BOTH, ESB_DISABLE_BOTH)
    19.  
    20. 'Example usage for enabling both:
    21. Call EnableScrollBar(WebBrowser1.hWnd, SB_BOTH, ESB_ENABLE_BOTH)
    I`m a new one please help me more. I paste this code in form code but it give me some errors..

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by RoYeti
    I`m a new one please help me more. I paste this code in form code but it give me some errors..
    What errors did it give and on what lines did the errors occur?

  7. #7

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re:block popups, disabe scrollbars, no right click in webbrowser component

    Compile errors:

    Only comments may appear after End Sub, End function, or End proprerty

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by RoYeti
    Compile errors:

    Only comments may appear after End Sub, End function, or End proprerty
    This tells me that you have pasted the code in the wrong place on the form.

    The API declare should be in the Form's declaration section along with the constants declarations.

    The calls should be placed in an event, such as a Form_Load event or a button's click event.

  9. #9

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    i put in the Form_Load but say`s the same thing and select me the first 2 lines
    Code:
     Public Declare Function EnableScrollBar Lib "user32.dll" (ByVal hWnd As Long, _
    ByVal wSBflags As Long, ByVal wArrows As Long) As Long

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by RoYeti
    i put in the Form_Load but say`s the same thing and select me the first 2 lines
    Code:
     Public Declare Function EnableScrollBar Lib "user32.dll" (ByVal hWnd As Long, _
    ByVal wSBflags As Long, ByVal wArrows As Long) As Long
    You don't put this in the Form_Load. This goes in the Form's declaration section.

    Open a code window. In the upper left hand corner will be a drop down box. Drop that down and locate "General" Click on General.

    This will take you to the declarations section. Put that code there.

  11. #11
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

    The hWnd property of WebBrowser control may generate runtime error.
    This page has an alternative function to get Webbrowser's hWnd.

    By the way, Hack, your code is not working for Webbrowser control (WinXP-SP2, VB6-SP6). As far as I can remember, somewhere in the web I read that, the scrollbar of webbrowser control is a 'html thing'. It may not be removed this way.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by iPrank
    By the way, Hack, your code is not working for Webbrowser control (WinXP-SP2, VB6-SP6). As far as I can remember, somewhere in the web I read that, the scrollbar of webbrowser control is a 'html thing'. It may not be removed this way.
    Ok...I've never had the need nor desire to use the webbrowser control, so I just posted code that I've used on scrollbars of other controls. If my code doesn't work, then how would the member accomplish his goal?

  13. #13
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by Hack
    Ok...I've never had the need nor desire to use the webbrowser control, so I just posted code that I've used on scrollbars of other controls. If my code doesn't work, then how would the member accomplish his goal?
    Sorry Hack. I didn't meant to sound rude.

    I was looking for this solution a few months ago. All pages I found in Google says that it can be done by only changing HTML code. Like, this one or this one

    But they are not very useful if we want to show a webpage, instead of a picture.

    This code by Francesco Balena uses GetSystemMetrics to get the size of the scrollbars and hide them behind a container picturebox.

    We could use this idea or,

    My idea is, when we get the height/width of scrollbars, just resizing the webbrowser may hide the scrollbars outside the form's client area. (instead of using a picturebox, we'll use the form. As it is already the contaier of webbrowser control)

    I'm sorry again if I sounded rude.

    Edit: None of them are the 'perfect' solution. I'll be greatful if someone can give a more acceptable solution. I'm still searching for the solution.
    Last edited by iPrank; Dec 19th, 2005 at 12:57 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by iPrank
    I'm sorry again if I sounded rude.
    You didn't at all.

    In fact, in re-reading my post, I think I may sounded a little rude, but that wasn't my intension either.

    So, the bottom line of what you are telling me is that as far as you know, there are no real, clean, ways of disabling the webbrowser scrollbars? Right?

  15. #15
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser component

    Quote Originally Posted by Hack
    So, the bottom line of what you are telling me is that as far as you know, there are no real, clean, ways of disabling the webbrowser scrollbars? Right?
    Yes. That's what I found (or didn't found ) by searching.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  16. #16
    New Member
    Join Date
    Mar 2010
    Posts
    8

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser componen

    Dear Sir,
    Today only i visited this forum and found it very useful.

    I know programming in VB6, and currently facing a problem.
    The problem is that i want to open the link on my webbrowser control in in a new window.
    If i am using the right click > open in new window then i am able to catch it via..

    Code:
    Private Sub wb_NewWindow2(index As Integer, ppDisp As Object, Cancel As Boolean)
      ........
      .........
      frmMain.wb(new_index).RegisterAsBrowser = True
      Set ppDisp = frmMain.wb(new_index).Object
    End Sub
    But what i want is even if somebody click the left mouse button on a link, i shall be able to open it in a new window (with session maintained).

    Second thing is that i want to scroll the loaded page programatically (pagedown/pageup).

    Is it possible to do the above two actions?
    Last edited by limpu.cool; Mar 23rd, 2010 at 11:59 AM.

  17. #17
    New Member
    Join Date
    Apr 2013
    Posts
    13

    Re: [RESOLVED] block popups, disabe scrollbars, no right click in webbrowser componen

    WebBrowser1.Document.body.setattribute "scroll", "no"

    try this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width