November 6, 200619 yr I seem to be unable to initialize a static SolidBrush in C++.This is what I attempt:In a class .h I declare a static SolidBrush like this: static SolidBrush brush_Mfd_Blk; // Cannot initialize herethen in the class .cpp file I define & attempt to initialize it like this: SolidBrush Cdu::brush_Mfd_Blk(Color(255, 0, 0, 0));and then attempt to use it in a classes draw() method like this: m_pGraphics->FillRectangle(&brush_Mfd_Blk, RectF(0, 0, m_bmp_w, m_bmp_h));and while everything compiles fine... I can see in the debugger that the Brush never gets initialilzed!Do you know what I am doing wrong? It seems that the Color constructor is not getting called.
November 6, 200619 yr Turns out the solution was just hard to see.Basically, GDI+ wasn't initialized before the static objects attempted to run their constructors, and this was because that initialization was in the constructor of the same class.Solution was to just to refactor that init stuff out and do it before anything else.
November 8, 200619 yr >Basically, GDI+ wasn't initialized before the static objectsattempted to run their constructors, and this was becausethat initialization was in the constructor of the same class.:) I hate errors like that... they tend to drive me nuts. In fact, I think I need a beer just thinking about it.Matt
Create an account or sign in to comment