Invalid DC for DoGetTextExtent Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ninja9578
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 236
Joined: Thu Jan 29, 2009 3:33 pm

Invalid DC for DoGetTextExtent

Post by ninja9578 » Mon Mar 09, 2009 9:02 pm

This code is giving me a problem:

Code: Select all

     wxMemoryDC memdc;
     long int x, y;
     string temp = "Hello World!";
     if (ffont -> Ok()){
        memdc.SetFont(*ffont);
        memdc.GetTextExtent(wxString::FromAscii(temp.c_str()), &x, &y);
     }
It works under windows, but not under OSX. A popup window comes up displaying:
../src/common/dcgraph.cpp(825): assert "Ok()" failed in DoGetTextExtent(): wxGCDC(cg)::DoGetTextExtent - invalid DC

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Tue Mar 10, 2009 9:13 am

wxBitmap bmp( 1, 1 );
wxMemoryDC memdc( bmp );

?

ninja9578
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 236
Joined: Thu Jan 29, 2009 3:33 pm

Post by ninja9578 » Tue Mar 10, 2009 4:59 pm

Guess what... you're the man :D

Post Reply