Results 1 to 7 of 7

Thread: Still working on it...

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Question

    I have been able to get my mail program to work finally using Mswinsck.ocx as a reference file. This works great on the machine I am developing on because this has already been registered. When I go to a WinNT computer the Mswinsck.ocx is not registered so I can not create the winsock object.

    How do I register this object using the package deployment wizard or can't I?

    Is there a way to include a form in a class so that I can add the Winsock control to the form and reference that in the class?

    Is there a way to send a very simple mail message using straight APIs from Wsock32.dll?


    Again I am trying to package this all in a class to be used in other projects as well.

    I can provide the class code if you need it.

    Thanks
    This space for rent...

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    P&DW will register any controls for you.
    Instead of adding it to the form as a control, try this:
    Code:
    Public WithEvents Winsock1 As (New?) Winsock
    Put it in the Declarations section of your form. It can then be accessed from a class:
    Code:
    Form1.Winsock1.xxx
    Any events will be passed back to Form1, though. You can add it to the class, and then the class will recieve the events.

    As for not using the Winsock control, I think there is an example on Planetsourcecode of sending an email using the API.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Parksie,

    I'm a little confused then (like that's new), what I did was add Mswinsck.ocx into my project as a reference and then declared it in the class as
    Code:
    Private Sub Class_Initialize()
        Set mobjWinsock = New MSWinsockLib.Winsock
    End Sub
    I ran the program on the Win 98 machine I'm developing on and everything works great. I use P&DW and setup the program on a Win NT 4.0 6a machine and I get a Run-time error 429, Active X component can't create object This may be wrong but I assumed that it is because the OCX did not get registered.

    Is there a way to verify that the OCX was registered?

    I also placed
    Code:
    Private WithEvents mobjWinsock As MSWinsockLib.Winsock
    in the class declarations. So I would not have to refer back to the form (I won't know the form name for future projects) again I would like to make the class stand on its own so I can use the class over and over again. Is there a way to have the winsock control on the project form and then be able to use that control in the stand alone class, maybe passing the form name that the control is on to the class and then create the control in the class at runtime?

    Thanks for any advice you can offer.
    This space for rent...

  4. #4
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Tut, tut, tut, parksie.

    One cannot use New when one is declaring something WithEvents.
    Courgettes.

  5. #5

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Originally posted by V(ery) Basic
    Tut, tut, tut, parksie.

    One cannot use New when one is declaring something WithEvents.
    I think that's why he stated (New?)
    This space for rent...

  6. #6

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Parksie,

    I did try it your way as mentioned above but when I try
    Code:
    frmMain.Winsock1.LocalPort = 0
    inside the class, I get the error: Run-time error '91': Object variable or With block variable not set

    I did not think you needed a Set New statement for form controls.
    This space for rent...

  7. #7

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Pass Winsock object to the class

    This may show my ignorance for classes but...

    Could you create the winsock object in the project before you call the class and then pass the winsock object to the class so that it can be used?
    This space for rent...

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