Home > Software engineering >  HTreeItem to create a different order, want to order what method
HTreeItem to create a different order, want to order what method

Time:10-02

Question:
I scan a file within the folder, which divides into the file, the Document, Video, Audio, Graphics, and Other,
Begin your search, the JPG file, if found so judgment, m_hTItemGraphics for null
If==NULL m_treeCtrl. InsertItem (... );
But there was a problem like this, so that to create order, affected by the search to the order of the file type,
The Graphics files, if you found the Graphics will be created in the first,

But now I want to send this order of child nodes will die,
Such as the first Document, the second Video...
But use TVI_FRIST or TVI_LAST on my side, so can only guarantee a/in the end, before the there was no way to guarantee the position, the rest 4
So I have what way, can write die this order directly,
Because I found that if I create good child nodes in the outside, there will be, assuming that if there is no image file within the folder, you will create a loophole nodes,

CodePudding user response:

Inserted the several classification and record the HTREEITEM first, later to retrieve the file according to the classification of the inserted into the corresponding node

CodePudding user response:

Information stored in the memory, sorting, and then directly inserted into the treeitem,

CodePudding user response:

 TV_SORTCB TVSCB; 
TVSCB. HParent=PNMTV - & gt; ItemNew. HItem;
TVSCB. LParam=0;
TVSCB. LpfnCompare=TreeViewCompareProc;

Tree. SortChildrenCB (& amp; TVSCB/*, FALSE */);
///////////////////////////////////////////////////////////////////////////////////////////////////

Int the CALLBACK CLeftView: : TreeViewCompareProc (LPARAM lparam1,
LPARAM lparam2, LPARAM lparamSort)
{
LPTVITEMDATA lptvid1=(LPTVITEMDATA lparam1);
LPTVITEMDATA lptvid2=(LPTVITEMDATA lparam2);
Retrieves the hr;

Hr=lptvid1 - & gt; LpsfParent - & gt; CompareIDs (0, lptvid1 - & gt; Lpi, lptvid2 - & gt; Lpi);

If (FAILED (hr))
return 0;

Return (short) SCODE_CODE (GetScode (hr));
}

CodePudding user response:

See SortChildrenCB and SortChildren

CodePudding user response:

Will get the result of classification, and then, finally InsertItem to the CTreeCtrl,
  • Related