Results 1 to 10 of 10

Thread: [RESOLVED] How do i prevent the pop up message box in IE?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Resolved [RESOLVED] How do i prevent the pop up message box in IE?

    Hai you guys. Can you guy help me with this? I'm trying to block the internet connection of computers remotely for my Computer Lab system. I have manage to make the system goes offline but everytime the user try to access the internet using IE, it will pop up the message "Web page unavailable while offline" and whether to connect or stay offline. So my question here is how do i prevent this pop up message from showing using VB 6.0 or prevent the user from clicking " Connect " because once they click "connect" they will be able to connect to the internet. Very urgent coz i only have 2 more days to finish this project.

    Please help ... Thanks alot.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do i prevent the pop up message box in IE?

    There is no need to start a second thread: http://www.vbforums.com/showthread.php?t=397941

    Anyway, the easiest way is probably to use a timer with interval set to 1:

    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    2.     (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    4.     (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    5.  
    6. Private Const WM_CLOSE = &H10
    7.  
    8. Private Sub Timer1_Timer()
    9.     Dim lhWnd As Long
    10.     lhWnd = FindWindow("#32770", "Web page unavailable while offline")
    11.     If lhWnd Then SendMessage lhWnd, WM_CLOSE, 0&, 0&
    12. End Sub
    However that is very much re-active rather than preventative. You'd probably have to do some subclassing to prevent the dialog box ever coming up at all.

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

    Re: How do i prevent the pop up message box in IE?

    I've thought about the FindWindow thing. But I was looking for some better way to prevent it. But google didn't help me here.

    Another thing you may want to use,
    Programmetically set IE to online mode.
    Note: This will not work on active instances of IE. You'll need to close all IE windows before this.
    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


  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation Re: How do i prevent the pop up message box in IE?

    To bushmobile

    Thanks for your reply. But i can't seems to get the code to work coz i'm still getting that dialog box. Can you please help me? I have set the timer interval to 1000

    Thanks alot.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do i prevent the pop up message box in IE?

    Try setting the interval to 1

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Talking Re: How do i prevent the pop up message box in IE?

    Nope still can't work i have tried to set the interval to 1, 5 and also 1000. But it still can't work. Anyone have any idea why?

    Thanks alot.

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do i prevent the pop up message box in IE?

    Hmm, have you enabled the timer? is the code actually firing?

    Perhaps check that FindWindow is returning a value.

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Thumbs up Re: How do i prevent the pop up message box in IE?

    To bushmobile

    You are the best thanks alot. The code works the problem was just that i have disable the timer after i have enable it. The dialog box is not popping up anymore. Thanks alot.

    But can you explain to me how does the code accually function?

    Thanks a billion.

  9. #9
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] How do i prevent the pop up message box in IE?

    The dialog is still popping up, that code is just closing it really quickly.

    The FindWindow API returns the hWnd of the window that has the classname and caption that we request, if it doesn't find that window then it returns 0.

    If the window has been found, we just send a WM_CLOSE message to it which makes it close.

  10. #10

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Thumbs up Re: [RESOLVED] How do i prevent the pop up message box in IE?

    Thanks alot for your explaination. I have been asking around and searching in the net but no one can tell me the solution. Thank again.

    Have a nice day...

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