Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6909841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:44:24+00:00 2026-05-27T08:44:24+00:00

I’ve been working on a TreeView system using the WinAPI. I built wrappers around

  • 0

I’ve been working on a TreeView system using the WinAPI. I built wrappers around some functions which allow me to insert new items, remove items and move items in a control. However, moving items seems to be a real pain in the ass. I could not find any function in the MSDN (http://msdn.microsoft.com/en-us/library/aa925848.aspx) that could solve my problem.


Therefore, I had to create a dirty-hack which saves the attributes of an item, deletes the old item and inserts the item at the new location. Here’s a little code snippet:

TVITEM tvitem;
char chrTextBuffer[33];

tvitem.mask = TVIF_TEXT;
tvitem.cchTextMax = sizeof(chrTextBuffer); // \0 termination included?
tvitem.pszText = chrTextBuffer;
tvitem.hItem = olditem; // different in the original code, don't want to post the entire function
TreeView_GetItem(GUIVars.Controls.GUI_Chat.ChannelTree, &tvitem);

The TVITEM struct is used to retrieve information about the item. I won’t explain these structs in detail, because it’s not important right now. Well, this information is now being inserted into a TV_INSERTSTRUCT and sent to the TreeView via

TreeView_Insert(mytreeview, &insertstruct);

The old item gets deleted:

TreeView_DeleteItem(mytreeview, olditem);

Obviously, this is quite dirty. Is there any other possibility to achieve the desired functionality? I am only using pure WinAPI in Pelles C for Windows (http://www.smorgasbordet.com/pellesc/), so libraries are no option.


Furthermore, I had to think about a way which allows to move all the children and the children’s children too. Each item is saved in a structure (in the HTREEITEM Handle)

struct cTreeItem
{
    uint8 Type;
    uint8 Used;
    uint16 Depth;
    int32 ParentID;
    HTREEITEM Handle;
};

which provides information, especially the ParentID. I could just loop through all my items (which are all saved in a dynamically allocated growing array) and check if their ParentID matches one of the nodes that has to be moved until I reach the last level of item-depth, but a native alternative would be better of course.

I hope my questions are understandable, I need a way to move items in a TreeView, preferably also moving their children and children’s children (…).


Edit: Btw, I found a lot of stuff solving this problem, but unfortunately only in C#, VB etc..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:44:25+00:00Added an answer on May 27, 2026 at 8:44 am

    The TreeView common control does not support moving items to a new parent. If you want to move an item relative to its siblings (but remain under the same parent), you can use TreeView_SortChildrenCB and pass a custom sort function that orders the children the way you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.