Jump to content
Sign in to follow this  
Guest 777jockey

Can't initialize static SolidBrushes

Recommended Posts

Guest Patrick_Waugh

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
Guest Patrick_Waugh

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
Guest 777jockey

>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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...