Re: Can't get static SolidBrush to initialize... what am I missing
Update:
"John Carson" wrote:
I think you have missed the point. I know that your code works fine without
static variables. That is because (assuming my diagnosis is correct) the
version of the code that doesn't use static variables is called *after*
GdiplusStartup is called, whereas the attempted initialization of the static
variables occurs *before* GdiplusStartup is called.
Here you have definitely missed the point. What I was saying was that you
should do something like the following. First declare:
struct GDIPlusManager
{
GDIPlusManager()
{
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
}
~GDIPlusManager()
{
Gdiplus::GdiplusShutdown(gdiplusToken);
}
private:
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
};
Ok. Well I succeeded in factoring out the GDI+ Startup stuff with a class,
and verified it worked as I can draw on my surface.
Unfortunately, this didn't fix the situation at all. Same behavior, they
remain uninitialized.
I instantiate the Gdipm like this:
Helpers::GDIPlusManager* pGdipm = new Helpers::GDIPlusManager();
a file scope level before a callback routine that the game calls which
instantiates the Cdu class (with the static brushes) once the game reaches a
state where it can do so.
Unfortunately, I limited in that I am in a .dll, and have to interfact to .c
code. So, at this point as there is only one Cdu instantiated anyway, I'm
just going to try to use class vars to simplify things.
If you get any other ideas, let me know, but I think the problem is that
somehow it still is not getting initialized soon enough.
Thanks for the help.