Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / suppress errors if an error occurs

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. suppress errors if an error occurs
#2779
Posted by: 2003-10-27 17:48:53
I wrote the following lines:

item = new wxBitmap();
if (!itemback->LoadFile(wxT("not_exist.bmp"),wxBITMAP_TYPE_BMP)) {
   delete itemback;
   itemback = NULL;
}
.....
wxPaintDC dc(this);
if (itemback != NULL) {
   dc.DrawBitmap( *itemback, 0, 0);
}

But still in Windows (I did not test Linux jet) I always get the message:
Can't open file "not_exist.bmp"

OK, the file does not exist, but I want to do the error handling myself.
How can I suppress this message and where does it come from.

Thank's
Markus
Message2. Re: suppress errors if an error occurs
#2781
Posted by: upCASE 2003-10-27 18:52:50
Hi!
Check the API for wxLogNull.

Here's the example I copied from the helpfile:

wxFile file;

  // wxFile.Open() normally complains if file can't be opened, we don't want it
  {
    wxLogNull logNo;
    if ( !file.Open("bar") )
      ... process error ourselves ...
  } // ~wxLogNull called, old log sink restored

  wxLogMessage("..."); // ok
upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: suppress errors if an error occurs
#2782
Posted by: 2003-10-27 20:14:35
Thank's,
it works, but to be honest, if you do not know, what to look for, there is almost no chance to find this solution - at least as a wx beginner.

Markus
Message4. Re: suppress errors if an error occurs
#2783
Posted by: upCASE 2003-10-27 22:21:58
True!
I'm using wxWindows for about a year now and there are still many things that I don't know and have never used...

For the next time: wxWindows uses different "log targets" to display error messages. This is indeed a very handy feature, because I often want to display status messages while programming just to make sure that the program flow is correct. Therefor I normally use a second wxFrame with nothing then a wxLogTextCtrl set as the active log target. Everytime I use wxLogMessage(), the message will appear with a time stamp...

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0