| wxWidgets FAQ: Questions common to all platforms |
See also top-level FAQ page.
wxWidgets also automatically deletes some other kind of the objects, notably the sizer or constraint associated with the window -- this happens just before the window itself is deleted. The sizers, in turn, delete their child sizers automatically as well so in a typical situation you don't have to worry about freeing the sizers you create. Note, however, that if you Remove() a sizer from the window, it isn't automatically deleted any more and you are responsable for doing this.
Changing this should become possible in future versions of wxWidgets as soon as we come up with a nice API for this feature.
Here is some pseudo-code for choosing the macro to use between the remaining
possibilities, that is whether to use wxT(), use _() or not
use any of them:
if ( string should be translated )
use _("string")
else if ( string should be in Unicode in Unicode build )
use wxT("string")
else
just use "string" normally
Note that if you don't care about Unicode at all, you don't have to use wxT() at all. On the contrary, if you do, note that _() takes care of it internally so if you use it your code will compile in both the ANSI and Unicode builds.
Please see the description of these macros in the manual for more details.
wxString str;
str.Printf(wxT("My string is %s"), wxString("whatever"));
does not work. Unfortunately, it may seem to work fine under
Windows because of a compiler quirk there but passing a wxString object to a
function taking a variable number of arguments such as Printf() is
undefined behaviour in C++. Accordingly, it will simply crash under most
platforms but may even "work" on some of them.
You must use c_str() to make the above code work, i.e. write this instead:
wxString str;
str.Printf(wxT("My string is %s"), wxString("whatever").c_str());
Note that g++ should give you an error when passing an object to a vararg function like this -- another reason to compile your code with g++ even if you normally use another compiler.