wxCreateToolBar 'TB_GETITEMRECT' failed

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Jive Dadson
Experienced Solver
Experienced Solver
Posts: 60
Joined: Thu Sep 06, 2012 8:00 pm

wxCreateToolBar 'TB_GETITEMRECT' failed

Post by Jive Dadson »

I am getting the following error at runtime when I call

Code: Select all

 wxCreateToolBar(wxTB_HORIZONTAL | wxBORDER_NONE | wxTB_FLAT, 100)
;

..\..\src\msw\toolbar.cpp(290): 'TB_GETITEMRECT' failed with error 0x00000006 (the handle is invalid.).

The call is very early in the startup code, before anything could go wrong, one would think. It is at the top of the main Frame constructor.

Anyone know what's up with that?
Jive Dadson
Experienced Solver
Experienced Solver
Posts: 60
Joined: Thu Sep 06, 2012 8:00 pm

Re: wxCreateToolBar 'TB_GETITEMRECT' failed

Post by Jive Dadson »

Forgot to say, I am using 3.3.0, but it does the same thing with 3.0.1

Running Windows 7 64 bit
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxCreateToolBar 'TB_GETITEMRECT' failed

Post by PB »

Jive Dadson wrote:

Code: Select all

 wxCreateToolBar(wxTB_HORIZONTAL | wxBORDER_NONE | wxTB_FLAT, 100)
I am not aware of wxCreateToolBar function so I assume you meant wxFrame::CreateToolBar().

My guess would be either: (1) The frame has not been created (yet), e.g. the call is from the fram default constructor before Create() was called; (2) ID collision, generally I would suggest not to use literals for window IDs....
Jive Dadson
Experienced Solver
Experienced Solver
Posts: 60
Joined: Thu Sep 06, 2012 8:00 pm

Re: wxCreateToolBar 'TB_GETITEMRECT' failed

Post by Jive Dadson »

You are right. It is wxFrame::CreateToolBar.

I was calling the Frame constructor like so:

Code: Select all

MyFrame::MyFrame(const wxString& _title)  
	: wxFrame(NULL, wxID_ANY, _title)
	, title(_title)
	, image()
      { // etc... }
  
When I remove the call to wxFrame from the constructor list, and add

Code: Select all

Create(NULL, wxID, _title);
at the beginning of the constructor's body, the result is unchanged. No joy. (Using both is disaster.)
Jive Dadson
Experienced Solver
Experienced Solver
Posts: 60
Joined: Thu Sep 06, 2012 8:00 pm

Re: wxCreateToolBar 'TB_GETITEMRECT' failed

Post by Jive Dadson »

It just occurred to me that this might be unique to Windows. The error comes from a file in a directory " msw", namely
..\src\msw\toolbar.cpp(290):
Jive Dadson
Experienced Solver
Experienced Solver
Posts: 60
Joined: Thu Sep 06, 2012 8:00 pm

Re: wxCreateToolBar 'TB_GETITEMRECT' failed

Post by Jive Dadson »

Here's what's happening. wxFrame::CreateTooBar is calling the Windows function ::SendMessage on the handle that was returned from getHwnd(), asking for the rectangle size. (Why I could not tell you.) SendMessage is returning with 0x00000006, which means the handle returned from getHwnd is invalid. (Again, WICNTY). The wx code sets the rectangle size to all zeros, and everything proceeds just fine, except for the troubling error message.

The error message is spurious, and only shows up when debugging. I have spent a lot of time for zilch.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxCreateToolBar 'TB_GETITEMRECT' failed

Post by doublemax »

Can you build and run the "toolbar" sample and check if it does the same?

Can you get a backtrace / call stack when that error occurs?
Use the source, Luke!
Post Reply