CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    resetting/reloading form (RESOLVED)

    Hello, it's been a while since I have posted, here goes.

    I would like to know if there is a way to reload a form during runtime. What I mean is to simulate you closing the form out and relaunching it? I have a winsocks project that won't release the connection. Even after you .close it , and then try to reconnect. Unless I close and then reopen the project or .exe I cannot disconnect and then make another call right behind it.
    Last edited by dedub; April 21st, 2005 at 07:47 PM. Reason: RESOLVED
    R.L.T.W. A+, NET+, CCNA

    doin' my best

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    Re: resetting/reloading form

    It sounds like what you need is to resolve the issue with the connection. Have you tried Winsock1.Close?

    To unload a form, use: Unload MyForm
    You might need to follow that with: Set MyForm = Nothing.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    Re: resetting/reloading form

    This is the code I found here that worked like a champ. Unfortunately the .close alone would not do the trick




    Code:
    Public Sub reloadForm(frm As Form)
        Winsock1.Close
        Winsock2.Close
        Unload frm
        Load frm
        frm.Show
    End Sub
    R.L.T.W. A+, NET+, CCNA

    doin' my best

  4. #4
    Join Date
    Dec 2001
    Posts
    6,332

    Re: resetting/reloading form

    What code do you have (if any) in the Close event? Is there data being sent to or from the connection at the time you are trying to unload the form?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  5. #5
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    Re: resetting/reloading form

    To answer your question I had just a simple winsock1.close . I'm sure that closed the socket but there after I could not make another request without creating an error. I could of trapped it but that still would not have allowed me to make another call. All I could do is close down the project or .exe and restart it. I do not know enough about winsocks to go any deeper than that. What I did figure out is that winsocks is a VERY busy control. What I mean is I ran a packet sniffer before I even made a connection request and it was pumping out packets like crazy to and from both computers. Probably because of the listening port.
    R.L.T.W. A+, NET+, CCNA

    doin' my best

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    Re: resetting/reloading form

    I'm not referring to the Close method, but rather Winsock1_Close. The event. This will fire when the port closes, but if I recall, it won't if the port is closed by calling the method.

    However, if you have the thing listening all the time so it can accept a connection, then close that before unloading the form. If you see port traffic when the port of the control is closed, then you might have some sort of spyware on you system, or the other system. I've never looked into how the control behaves in the listening state, but closed is closed.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  7. #7
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    Re: resetting/reloading form

    I understand now about the Winsock1_Close. event, thanks for setting me straight. Info like that I could not find in any tutorial. As far as the packets, they are broadcast packets DEFINATELY comming from the winsocks control. Im going to adjust my code a little and give it a shot. Thanks again.

    ds
    R.L.T.W. A+, NET+, CCNA

    doin' my best

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

Featured