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

  • Home
  • SEARCH
  • 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 8579277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:34:42+00:00 2026-06-11T20:34:42+00:00

On a few computers computers (meaning most are fine), when adding an item to

  • 0

On a few computers computers (meaning most are fine), when adding an item to a tree control, for some reason TreeView_InsertItem returns NULL (Indicating something went wrong).
Unfortunately the MSDN site doesn’t specify that an error code is set (and indeed, calling GetLastError simply tells me: 0 = The operation completed successfully.
Neither does it specify what could cause a failure or how to deal with one.

So I’m wondering if anyone has encountered this before, or has any suggestions as to how to debug the problem.

The machines are all running Windows 7.

A disclaimer: I’m actually going through wxWidgets, but we’ve dug into the code and the problem appears to lie at the windows api level, and not with wx itself.

Update:
Basically, the idea is, you inherit from this class, and then implement populate, which simply calls AddItem(). There is also a version of AddItem() for specifying the root item, but since I fail on the first call to Append(), it’s presence doesn’t help.
The tree is created in wxFormBuilder with the following flags: wxTR_DEFAULT_STYLE, wxTR_HAS_BUTTONS, wxTR_HIDE_ROOT, wxTR_LINES_AT_ROOT, wxTR_SINGLE

This also works perfectly fine from my own PC

ItemSelector::ItemSelector( wxWindow* parent )
:    m_tree( NULL ),
    m_initialised( false )
{
    wxXmlResource::Get()->LoadFrame( this, parent, wxT( "ItemSelector" ) );

    m_tree = XRCCTRL( *this, "itemTree", wxTreeCtrl );

    m_rootItem = m_tree->AddRoot( wxT( "ROOT" ) );

    Bind( wxEVT_SHOW, &ItemSelector::OnShow, this );

    MakeModal( true );
}

void ItemSelector::OnShow( wxShowEvent& event )
{
    if( event.IsShown() )
    {
        if( !m_initialised )
        {
            Populate();
            m_initialised = true;
        }

        m_tree->SetFocus();
        Layout();
    }
}

void ItemSelector::AddItem( const wxString& name, void* someData )
{
    //Also tried m_tree->AppendItem( m_rootItem, wxT( "Test" ) ) - same problem
    wxTreeItemId newItem = m_tree->AppendItem( m_rootItem, name, -1, -1, new TreeDataClass( someData ) );
}
  • 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-06-11T20:34:43+00:00Added an answer on June 11, 2026 at 8:34 pm

    It looks like the problem was due to the fact that I was calling Populate() from an wxEVT_SHOW event.

    I’ve discovered that this must be a known problem, because wxDialog has a [wxEVT_INIT_DIALOG][1] event, precisely for this purpose

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

Sidebar

Related Questions

I'm new to the Version Control topic. I have a few computers on my
I have a few related applications that I want to deploy to different computers.
I have around 100 computers and few workers on each of them. The already
We have a desktop application run on a few thousand client computers. We want
we are using SharePoint Server (MOSS 2007) with Windows Integrated Security. A few computers
I am running a few commands on the domain computers. I would like to
Ok so I am going through wiping some computers for a business. The business
We use TWebBrowser in our application. on some of my customers computers (IE9/Win7) after
We write a Windows desktop application that is installed on a few thousand computers
I've switched computers a few times recently, and somewhere along the way I lost

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.