Design ActiveX DLL event using VB6.0

zhaozj2021-02-16  33

We know that the following method definitions can be used directly in the design of the ActiveX DLL program, for example: public event tracer, keyvalue as string, defines an event to the EXE program. But we also know that there must be an external action or timer to be triggered, but how to trigger the event in the ActiveX DLL inside?

I have searched a number of technical articles that have not been able to find a suitable handling method, but I have found a good way to deal with this problem. Maybe I am too lonely, I didn't see this article introduction; if I have the content I have written with others, please don't think that I am plagiarism. Because the following content is indeed the result I exploited.

1. First we should define an ActiveX DLL project to design a class such as a CPRINTER class, and set the instance of the instancing to 5-multiuse;

2, add events in the CPrinter class module, such as: Public Event TracerView (INDEXVALUE AS Integer, KeyValue As String, TraceResults As String);

3, the method of adding a Friend CPrinter class module, such as: Friend Sub CaptureView (IndexValue As Integer, KeyValue As String, TraceResults As String) Add code trigger events in the process RaiseEvent TracerView (IndexValue, KeyValue, TraceResults);

4. Add a form to the ActiveX DLL project, such as the FGRID form; and define the variable of the cPrinter class that reference ActiveX DLL in the code module of the form, such as the following definition: Private Minitrpt As Cprinter;

Friend Property Get Document () AS CPRINTER 'DLL Project Class In Engineering Internal Usage Set Document = Minitrpt End Property

Friend Property Set Document (Byval VNewData As Cprinter) Set Minitrpt = VNewData End Property

5. You can use the Cprinter class's Friend, Public Method, such as Minitrpt.captureView 0, Mnuyaymenu.Item (0) .caption, mnuyaymenu.Item (0) .tag

Events, methods, and attributes can be used inside the ActiveX DLL project through the above 5 steps.

转载请注明原文地址:https://www.9cbs.com/read-26474.html

New Post(0)