开发者

Winsock object problem with WithEvents

I am developing a Standard EXE Project for sending mail.

I have a class module for sending email using winsock.

I have a withevents winsock variable set to the winsock control of a form.

The problem is that events are being catched in form's control event handler. When i comment form's contro开发者_开发问答l event handling procedures and put a breakpoint in class module witheevents variable's event handler,i am unble to catch the events.

Please suggest a workaround.


If you really need to create a class (little c) that wraps constituent controls you create a UserControl, which can be invisible at runtime and have no UI interaction at all. Then, as the Winsock control's container, this UserControl will receive the events and you can handle them there.

I do this fairly often in order to create higher-level communication components, moving things like a message framing protocol inside. Then the container I put these UserControls onto only handles events raised when it has received complete messages for example. I've done the same thing to create an embeddable HTTP Server control, raising events back to the containing Form to process GET/POST requests with parameters and so on to provide a Web UI.

A Class (big C), Form, and UserControl are just three kinds of class (little c) you can create in VB6. "Class modules" really should have been called "UserClass" for clarity I suppose, in hindsight.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜