MSN is a real-time information communication tool (IM) widely used on the network. The author uses it to contact colleagues or friends, but it is found that the lack of a group of group information is lacking. Software, after reviewing some information, finally wrote. Let's take your own MSN's information group meter with me.
Step 1: New project. Start VB, select the "New" submenu of the File menu to create a VB project, and the system is automatically added to add a form and name Form1.
Step 2: Adding a reference to the MSN interface. Click on the engine menu in the menu of the VB IDE environment to select the "Reference (n) ..." submenu in the pop-up menu. Find the "Messenger API Type library" item in the "Available Reference" drop-down list in the pop-up, you will start the front hook and then close the "Reference" window. See Figure 1
figure 1
Step 3: Set the form to add a control. First double-click Form1 in VB's engineering manager, open the form design environment. Select the form and change its caption value to "MSN message group". Then add a control on the form and set its initial properties. See the table below for the controls to add:
Name Type Caption Property Value Label1 Label Group Object: Combo1 ComboBox
Check1 Checkbox only sends online Label2 Label message content: Text1 TextBox
Command1 CommandButton Send [& O] Command2 CommandButton Exit [& x]
After adding the control, adjust its position, and finally form the effect of Figure 2:
Step 4: Write code.
DIM M_MSG AS New Messengerapi.Messenger 'MSN COM object
Dim M_Groups as MessengeraPi.imessengergroups' MSN Packets
DIM m_GROUP As Messengerapi.imessengergroup 'MSN
Dim M_Contracts As MessengeRapi.imessengerContacts' MSN All friends information
DIM M_CONTRACT AS MessengeRapi.imessengerContact 'MSN content of each friend object
Private submmand1_click ()
DIM I as integer
'Detect whether the information you need to send is legal
If Trim (Text1.Text) = "" ""
"The information sent by msgbox can not be empty!", Vbinformation, "prompt"
Text1.setfocus
EXIT SUB
END IF
'Judgment Message Send Objects is a member of all friends or a group
IF combo1.listindex = 0 THEN
SET M_CONTRACTS = m_msg.mycontacts
Else
SET M_GROUPS = m_msg.mygroups
Set m_group = m_groups.Item (Combo1.ListIndex - 1)
SET M_CONTRACTS = m_group.contacts
END IF
'Traverse the object to be sent, send information
For i = 0 to m_contracts.count - 1
Set m_contract = m_contracts.Item (i)
If Check1.Value = 1 Thenif M_Contract.Status = 2 THEN
M_Msg.instantMessage M_Contract 'Open a friend form you want to send
Doevents
SendKeys text1.text 'Write information
Doevents
SendKeys "{entry}" sends information
Doevents
SendKeys "% {f4}" closes friends window
END IF
Else
m_msg.instantMessage M_Contract
Doevents
SendKeys text1.text
Doevents
SendKeys "{entry}"
Doevents
SendKeys "% {f4}"
END IF
Next I
'Successfully sent information
If msgbox ("Is it finished! Is it clear message?", Vbinformation Vbyesno, "Tip") = Vbyes Then
TEXT1.TEXT = "" "
Text1.setfocus
Else
Text1.setfocus
END IF
End Sub
Private sub fascist2_click ()
Unload me
End
End Sub
'Initialization control
Private sub flow_load ()
DIM I as integer
'Initializing the drop-down box
SET M_GROUPS = m_msg.mygroups
With combo1
.Additem "all group"
For i = 0 to m_groups.count - 1
SET M_GROUP = m_groups.Item (i)
.Additem m_group.name
Next I
.Listindex = 0
End with
End Sub
'Release variables
Private Sub Form_Unload (Cancel AS Integer)
SET M_MSG = Nothing
Set m_groups = Nothing
Set m_group = Nothing
Set m_contracts = Nothing
Set m_contract = Nothing
End Sub
Step 5: Compile operation. Select the "File" menu to generate the "Project 1.exe" menu item, one of your MSN information group software is completed. Run this EXE interface is as follows:
This example of the source program can be downloaded as follows: http://www.ly800.com/soft/msngs.rar Welcome everyone to discuss, my email: root@ly800.com