This article describes how to use C++builder to implement a detailed approach to Messenger, which uses the following techniques:
1. Multi-line program technology to prevent deadlock in the interface.
2. The network enumeration is used to enumerate online users.
3. Converting from ansistring to Unicode using Unicode conversion functions.
4. The use of Simple irregular window technology.
5. Install automatically and add yourself to the system start-up.
6. System Tray Technology.
Programming Method:
1. Some controls added to the form as shown in the Picture: tlistview,ttreeview,tmemo, menus, trays, buttons, status bar
2. Add code for each control as written in this article.
3. The following is the sending function
void __fastcall Tformmain::buttonsendclick (tobject *sender)
{
ansistring message,username,fromname;
Tlistitem *listitem;
if (checkboxanony->checked) fromname=editanony->text;
Else Fromname= "";
message=memo1->text;
if (message== "") {showmessage ("Please Enter words to send");
if (! Listview1->selcount) {
if (treeview1->selected==null) {showmessage ("Please select Destnation");
username=treeview1->selected->text;
if (treeview1->selected->level==1) username=username+ "*";
New Netmessagesend (false,username,fromname,message,checkboxgetret->checked);
return;
}
listitem=listview1->selected;
username=listitem->caption;
if (treeview1->selected->level==0) username+= "*";
while (username[1]== ' \]) username=username.substring (2,username.length ()-1);
New Netmessagesend (false,username,fromname,message,checkboxgetret->checked);
for (int i=1;iselcount; i++) {
Listitem=listview1->getnextitem (listitem,sdall,titemstates () < username=listitem->caption;
if (treeview1->selected->level==0) username+= "*";
while (username[1]== ' \]) username=username.substring (2,username.length ()-1);
New Netmessagesend (false,username,fromname,message,checkboxgetret->checked);
}
}
Here is the Network node enumeration function, which is a thread.