Jump to content
Sign in to follow this  
Guest ba747heavy

GDI+ Shutdown

Recommended Posts

Guest ba747heavy

Gentlemen,I am at my wits end :) I have a very odd problem with my gauge. Whenever I add the GDI+ shutdown code to my PANEL_SERVICE_DISCONNECT FSAPI callback function, the gauge will not display. However, if I do not add this code my gauge works fine.I have the GDI+ handling code in its own class:ULONG_PTR GDI_FRED::gdiInit(){ GdiplusStartupInput input; ULONG_PTR token; GdiplusStartup(&token, &input, NULL); return token;}void GDI_FRED::gdiShutdown(ULONG_PTR token){ GdiplusShutdown(token);}and the API Callback function(I have stuck this stuff in a dummy gauge so that when I add tons of GDI+ gauges to this thing, it will all display just fine with no headaches; at least that is the theory, as yet untested)void FSAPI dummyCallBack ( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data ){ switch (service_id) { case PANEL_SERVICE_CONNECT_TO_WINDOW: gdiplusToken = fred.gdiInit(); break; case PANEL_SERVICE_DISCONNECT: fred.gdiShutdown(gdiplusToken); // This line, when removed, allows everything to be displayed break; }}fred is the variable that is declared as GDI_FRED fred. And yes, I do chose interesting class names :)I don't know how to proceed. I have put my code through the debugger, and from that experience I know that the drawing code is executing, there is a HDC that I think is valid, and I know that the CONNECT_TO_WINDOW case has been called one more time than the DISCONNECT case. However, no gauge is being displayed.Thank you guys!

Share this post


Link to post
Share on other sites
Guest _ak

Each gauge have module_init and module_deinit function.By default they are empty.Put GDI+ startup and shutdown there.Works fine for me.

Share this post


Link to post
Share on other sites
Guest bartels

Strange, my GdiplusStartup/GdiplusShutdown functions are also at PANEL_SERVICE_CONNECT_TO_WINDOW and PANEL_SERVICE_DISCONNECT and never caused any problems. I haven't checked yor code in detail though.Arne Bartels

Share this post


Link to post
Share on other sites
Guest ba747heavy

I have tried inserting that GDI+ stuff in the module init and deinit functions, with no joy.

Share this post


Link to post
Share on other sites

I have mine in PANEL_SERVICE_POST_INSTALL and PANEL_SERVICE_POST_KILL. Try that :-)Wade

Share this post


Link to post
Share on other sites

Hey Fred, I seem to have found an answer to the problem.citation_fred.pfd.cppcase PANEL_SERVICE_CONNECT_TO_WINDOW: gdiplusToken = fred.gdiInit(); //you forgot to add this linebreak;//now this workscase PANEL_SERVICE_DISCONNECT: fred.gdiShutdown(gdiplusToken);break;citation_fred.dummy.cpp//uncomment this linecase PANEL_SERVICE_DISCONNECT: GdiplusShutdown(gdiplusToken); //this onebreak;Now everything works very good, and the frames boosted. Talk to you on MSN tonight.Sincerely,Tiberiu Brasov

Share this post


Link to post
Share on other sites

Fred and guys, What was I thinking when I wrote this, it seems that I provided insufficient info. Here is the fix.// add this line, and everything is working goodcase PANEL_SERVICE_POST_INSTALL: gdiplusToken = fred.gdiInit();I apologise again for the mistake. Everything works good now.Sincerely,Tiberiu Brasov

Share this post


Link to post
Share on other sites
Guest ba747heavy

Tibi,It works, I just don't know why ;) Talk to you on MSN.

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...