Set of a group of address books implemented by TTREEVIEW,

xiaoxiao2021-03-06  57

Reply to: adayuer ([± 0 ° C]) () Reputation: 96 2002-04-01 09: 40: 17Z score: 0 Look at my code. The group of contacts that implemented with TtreeView, contacts TLISTVIEW. / --------------------------------------------------- -------------------------- void __fastcall ttbf :: n5click (Tobject * sender) {thittests ht; ttreenode * node1; if (mouse_sender && mouse_sender-> ClassNameIs ( "TTreeView")) {TTreeView * pTV = (TTreeView *) mouse_Sender; HT = pTV-> GetHitTestInfoAt (mouse_x, mouse_y); if (HT.Contains (htOnItem)) Node1 = pTV-> GetNodeAt (mouse_x, mouse_y) ; If (node1-> text == "all") {messagedlg ("///" is a system group, can't delete! ", MTWARNING, TMSGDLGBUTTONS () << mbyes, 0);} else PTV -> Items-> delete (node1);

}} // ---------------------------------------------- ----------------------------- void __fastcall ttbf :: GrouptVMousedown (Tobject * Sender, TMousebutton Button, TshiftState Shift, Int x, int Y) {mouse_x = x; mouse_y = y; mouse_sender = sender;} // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------- Void __fastcall ttbf :: n3click TObject * Sender) {THitTests HT; TTreeNode * Node1; if (mouse_Sender && mouse_Sender-> ClassNameIs ( "TTreeView")) {TTreeView * pTV = (TTreeView *) mouse_Sender; HT = pTV-> GetHitTestInfoAt (mouse_x, mouse_y); if (HT .Contains (htonitem)) {node1 = ptv-> getnodeat (mouse_x, mouse_y); if ((node1-> level == 0) && (node1-> text == "all")) {messagedlg ("/" all / "Is the system group, can not be new subsidy!", MTWARNING, TMSGDLGBUTTONS () << mbyes, 0); return;} if (node1-> level == 1) {Messagedlg ("can only establish two levels! "MTWARNING, TMSGDLGBUTTONS () << mbyes, 0); returno} else {ttreenod e * fnode; string s = "new group"; fnode = node1-> getFirstChild (); if (fnode) While (! NOSAMENAME (FNode, s)) {;}; ptv-> items-> addchild (node1, S);}}}} // ----------------------------------------- --------------------------------- void __fastcall ttbf :: n2click (Tobject * sender) {Ttreenode HT; TTREENODE * Node1; if (mouse_sender && mouse_sender-> classnameis ("ttreeview * ptv = (ttreeView *) mouse_sender; ht = ptv-> gethitteTestinfoat (mouse_x, mouse_y);

IF (ht.contains (htonitem)) {node1 = ptv-> getnodeat (mouse_x, mouse_y); string s = "new group"; while (! NOSAMENAME (node1, s)) {;}; ptv-> items- > Add (node1, s);}}} // ----------------------------------- -------------------------------------- void __fastcall ttbf :: n4click (TOBJECT * Sender) { THitTests HT; TTreeNode * Node1; if (mouse_Sender && mouse_Sender-> ClassNameIs ( "TTreeView")) {TTreeView * pTV = (TTreeView *) mouse_Sender; HT = pTV-> GetHitTestInfoAt (mouse_x, mouse_y); if (HT.Contains (htOnItem) ) {Node1 = ptv-> getnodeat (mouse_x, mouse_y); if ((node1-> level == 0) && (node1-> text == "all")) {messagedlg ("/" all / "is a system group Can't rename! ", MTWARNING, TMSGDLGBUTTONS () << mbyes, 0);} else node1-> edittext ();}}

} // ----------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------- void __fastcall ttbf :: grouptvclick (Tobject * sender) {/ * thittests ht; ttreenode * node1; if (Sender-> ClassNameis ("TtreeView")) {TTREEVIEW * PTV = (TtreeView *) sender; ht = ptv-> gethittestinfoat (mouse_x, mouse_y); if (ht.contains (htonitym)) {node1 = ptv-> getnodeat (mouse_x, mouse_y); sb-> simpletext = "absoluteindex:" INTOSTR (Node1-> AbsoluteIndex) "/ TINDEX:" INTOSTR (Node1-> index) "/ TTEXT [" node1-> text "] "}} * /} // ----------------------------------------- ----------------------------------

void __fastcall TTBF :: GroupTVChange (TObject * Sender, TTreeNode * Node) {// SB-> SimpleText = "Count:" IntToStr (Node-> Count) "AbsoluteIndex:" IntToStr (Node-> AbsoluteIndex) " Index: " INTOSTR (Node-> Index) " Text [" Node-> Text "] "; TListItem * Pitem; String Tmp; TBLV-> items-> clear (); if ((Node-> text = = "All" && Node-> Level == 0)) {for (int i = 0; i tblist-> count; i ) {pitem = tblv-> items-> add (); tmp = Telitem *) (m-> tblist-> items [i])) -> name; pitem-> caption = TMP; pitem-> subs-> add (string ((telitem *) (m-> tblist-> items [i])) -> NICK)); Pitem-> Subitems-> Add (String ((telitem *) (m-> tblist-> items [i])) -> phone)); Pitem-> Subitems- > Add ((telitem *) ((telitem *) (m-> tblist-> items [i])) -> type == 0)? "English": "Chinese")); Pitem-> Subitems-> Add ( String ((telitem *) (m-> tblist-> items [i])) -> MEMO));} return;} else if (node-> level == 0) {for (int i = 0; i tblist-> count; i ) { IF (Node-> text! = string ((telitem *) (m-> tblist-> items [i])) -> group)) Continue; pitem = tblv-> items-> add (); TMP = (Telitem *) (m-> tblist-> items [i])) -> name; pitem-> caption = tmp; pitem-> subs-> add (string ((telitem *) ((telitem *) (m-> tblist-> Items [I])) -> NICK); Pitem-> Subitems-> Add (String ((telitem *) (m-> tblist->

Items [i])) -> phone)); Pitem-> Subitems-> Add (String ((telitem *) (m-> tblist-> items [i])) -> type == 0)? " English: "Chinese")); Pitem-> Subitems-> Add (String ((telitem *) (m-> tblist-> items [i])) -> MEMO));} return;} else f Node-> level == 1) {TTREENODE * PNODE = Node-> Parent; for (int i = 0; i tblist-> count; i ) {if ((Node-> text! = String (Telitem *) (m-> tblist-> items [i])) -> Subgroup) || (pnode-> text! = String ((telitem *) (m-> tblist-> items [i]) ) -> group)) Continue; pitem = tblv-> items-> add (); tmp = ((telitem *) (m-> tblist-> items [i])) -> Name; pitem-> caption = TMP; Pitem-> Subitems-> Add ((telitem *) (m-> tblist-> items [i])) -> nick)); Pitem-> Subitems-> Add (String (((Telitem *) ) (M-> tblist-> items [i])) -> phone)); Pitem-> Subitems-> Add (String ((((telitem *) (m-> tblist-> items [i])) - > type == 0)? "English": "Chinese")); Pitem-> Subitems-> Add (String ((Telitem *) (M-> TBLIST-> Items [i])) -> MEMO)) ; } Return;}} // -------------------------------------------------------------------------------------------------------------------- -------------------------------- Void __fastcall ttbf :: grouptvediting (Ttreenode * Node, Bool & Allowedit) {IF ((Node-> Level == 0) && (node-> text == "all")) allowedit = false; else oldtext = node-> text;}

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

New Post(0)