SolidWorks EPDM secondary development entry (III)

Source: Internet
Author: User
Tags sendmsg

Today we provide an example of sending messages. Below we will post the code for discussion.

Design a class library with two files. Message. vb, policy. vb

'Message. vb Code Namespace Notification Public Interface IPJMessage 'defines an Interface Function ToHTML () As string' to add the sending method Function SubJect () to the Interface () as String 'add End Interface Public Class Message End Class Public Class ThirdClass: Implements IPJMessage Public Function SubJect () As String Implements IPJMessage. subJect = "Send" 'Function returns a Send String End Function Public Function ToHTML () As String Implements IPJMe Ssage. ToHTML = "Good afternoon! "'Function returns a good afternoon string End Function End ClassEnd Namespace
'Y. vb Code Imports EdmLibNamespace Notification Public Class Notification Dim duser As IEdmUser7 Public Sub New (ByVal user As IEdmUser7) duser = user' assign the passed user value to IEdmUser7 End Sub ''' <summary> ''' send message ''' </summary> ''' <param name = "context "> IPJMessage instance </param> ''' <remarks> </remarks> Public Sub SendMessage (ByVal context As IPJMessage) duser. sendMsg (context. subJect (), context. toHTML () 'Call the SendMsg method of duser End Sub End ClassEnd Namespace
The files in the class library are compiled into dll and imported into the application. Add a form. Add a button and a combobox control to the form.
'Form Load Event code Private Sub frmTestBatchList_Load (ByVal sender As System. object, ByVal e As System. eventArgs) Handles MyBase. load vault. loginAuto ("Trainning", Me. handle. toInt32) 'Log onto PDM Dim userMgr As iedmusermgr5' and define the UserMgr5 type object userMgr = vault Dim pos As IEdmPos5 pos = userMgr. getFirstUserPosition 'get the first user Dim user As IEdmUser5 While Not pos. isNull user = userMgr. getNextUser (pos) 'obtains the user ComboBox1.Items. add (user. name) 'Add a user to comboBox End While End Sub
'Code of the button event Private Sub btnSendMsg_Click (ByVal sender As System. object, ByVal e As System. eventArgs) Handles btnSendMsg. click Dim userMgr As IEdmUserMgr5 userMgr = vault Dim user As IEdmUser5 user = userMgr. getUser (ComboBox1.Text) 'gets the Dim smessage As IPJMessage = New ThirdClass () Dim noti As Notification noti = New Notification (user) selected in ComboBox) 'User-to-Notification constructor noti. sendMessage (smessage) 'sends the message End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.