Hello
I am a complete newbie in wxWidget and c++ and i am trying to create my first GUI application. I would like to know if it is possible to print the value of a variable (double, int) on a wxMessageBox and if yes how? And something else if for example i try to use a function like wxMessageBox and i want to enter the first and the third parameter of the function how can i omit the second? ex. I want to show a message, i don't want a caption and i want to show some buttons.
Thank you
Print variable on message box
Heres an example:
with wxString::Format() you can display almost anyting as a string, using the correct format specifyer.
as for ommiting arguments, well, you cant precisely "ommit" them, but you can write their default values.
HTH
Code: Select all
int myVar = 15;
wxString msg = wxString::Format(wxT("my value is %d"), myVar);
wxMessageBox(msg, wxT("a message"), wxOK | wxCENTRE | xICON_ERROR, this);
as for ommiting arguments, well, you cant precisely "ommit" them, but you can write their default values.
HTH
Hier Kommt die Sonne...
Unfortunately is not working
It gives me this error and hangs up during execution.
main.cpp:86: warning: cannot pass objects of non-POD type `class wxString' through `...'; call will abort at runtime
I have three double variables one for storing the result of a formula. I want to find the result store it inside the variable convert it to wxString or an array and then print it on a messageBox
It gives me this error and hangs up during execution.
main.cpp:86: warning: cannot pass objects of non-POD type `class wxString' through `...'; call will abort at runtime
I have three double variables one for storing the result of a formula. I want to find the result store it inside the variable convert it to wxString or an array and then print it on a messageBox
-
- Super wx Problem Solver
- Posts: 424
- Joined: Tue Jul 12, 2005 8:44 pm
- Location: Alabama, USA
I assume you're using gcc to compile your application since I've seen that warning before. Try changing the call to this.Ago wrote:Unfortunately is not working
It gives me this error and hangs up during execution.
main.cpp:86: warning: cannot pass objects of non-POD type `class wxString' through `...'; call will abort at runtime
I have three double variables one for storing the result of a formula. I want to find the result store it inside the variable convert it to wxString or an array and then print it on a messageBox
Code: Select all
wxMessageBox(msg.mb_str(), wxT("a message"), wxOK | wxCENTRE | xICON_ERROR, this);
wxMSW 2.6.2, VS 2002, 2003 and 2005, Code::Blocks and mingw, Windows XP Pro
-
- In need of some credit
- Posts: 3
- Joined: Mon Feb 20, 2006 9:30 pm
wxString
another similar problem
because Format is defined with variable arguments
... can only be replaced by a non-POD type variable ie char* you must use .c_str() on all other wxString variables other than the first (think thats right)?
this works for me
Code: Select all
wxString msg = wxString::Format( wxT(" User is '%s' "), wxE_UserName->GetValue() );
Code: Select all
static wxString Format(const wxChar *format, ...);
Code: Select all
wxString msg = wxString::Format( wxT(" User is '%s' "), wxE_UserName->GetValue().c_str() );