Sign in to follow this  
Guest 777jockey

Can't initialize static SolidBrushes

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

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.

Share this post


Link to post
Share on other sites

>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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this