Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GDI+ String Making...

Featured Replies

  • Moderator

The following will draw the desired text in the proper location on the background bitmap, and will scale when the gauge is resized...However, undocking the window and resizing the window causes the text to disappear. Can anyone tell me how to either (a) force a redraw of the strings, or (:( where I should place the code to prevent this from happening?////////////////////////////////////case PANEL_SERVICE_PRE_DRAW: { PELEMENT_STATIC_IMAGE pelement = (PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]->next_element[0]); if (pelement) { HDC hdc = pelement->hdc; PIXPOINT dim = pelement->image_data.final->dim; if (hdc) { Graphics graphics(hdc); graphics.SetSmoothingMode(SmoothingModeAntiAlias); SolidBrush whiteBrush(Color(255, (255*brt)/100, (255*brt)/100, (255*brt)/100)); FontFamily Arial(L"Arial"); Font TempTitles(&Arial, 0.085*dim.y, FontStyleBold, UnitPixel); PointF pointF(0.158*dim.x, 0.176*dim.y); graphics.DrawString(L"MKR", -1, &TempTitles, pointF, &whiteBrush); PointF pointF1(0.15*dim.x, 0.245*dim.y); graphics.DrawString(L"MUTE", -1, &TempTitles, pointF1, &whiteBrush); } SET_OFF_SCREEN (pelement); } }

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Bill,PANEL_SERVICE_PRE_INITIALIZE and PANEL_SERVICE_PRE_GENERATE both get executed on a dock/undock and on a resize. For that matter, so do POST_INITIALIZE and POST_GENERATE.Try calling your draw routines from one of those cases as well.Or, have you got something in PRE_INITIALIZE that is killing your string?Doug

  • Author
  • Moderator

>Bill,>>PANEL_SERVICE_PRE_INITIALIZE and PANEL_SERVICE_PRE_GENERATE>both get executed on a dock/undock and on a resize. For that>matter, so do POST_INITIALIZE and POST_GENERATE.>Try calling your draw routines from one of those cases as>well.>Or, have you got something in PRE_INITIALIZE that is killing>your string?Actually, at the moment there is nothing in the PRE_INITIALIZE section... ;)I'm working on a "learning gauge" trying to wrap my head around GDI+ DrawString and so forth. ;)So far, XML's "scheme" is far easier and less problematic... ;)I'll try ploping the code into the PRE_INITIALIZE case and see what happens... Thanks!

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Hello Bill,I'm sorry, I didn't answer your email, no time yet ;-)But I think I have the answer to your question:I disagree with what Doug said. In my gauges, I also ignore the PANEL_SERVICE_PRE_INITIALIZE and PANEL_SERVICE_PRE_GENERATE events, and everything works fine, even when the gauges are undocked and resized.Now you may ask: what is the difference between our gauges, which makes my gauges work and not yours !!The answer is because I have coded my gauges so that when a gauge is undocked, the original gauge in the main panel does NOT draw any more. Basically, I did this to improve performance, thinking it is not necessary to draw the same gauge twice. THe consequence of this drawing mode is that the gauge draws only once, with a well-known size.The problem of your gauge is that the same gauge is designed to draw twice with 2 different displays, and 2 different sizes. As the gauges are DLLs, they share the same memory space, so the value of the variables are the same for both displays, even if it the same gauge!!I am 99% sure this is the cause of the problem.Eric

  • Author
  • Moderator

They say a picture is worth a thousand words, so perhaps a picture of what I'm trying to accomplish will make things more clear.The GMA340 in the middle is entirely XML vector drawn. The only bitmap in the entire gauge is the background image. All text uses the XML version of DrawString, and the AOM indicator lights are vector drawn graphic boxes, with DrawString labels. One of the major "features" is that the level of label illumination is continuously variable with a rotary knob on the a/c's electrical panel.The top GMA340 is a partial reproduction with just several text labels created using the "traditional" MAKE_STRING callbacks.The lower GMA340 is my initial attempt at "translating" the XML version using the GDI+ DrawString method. I'm not going to bother with more than one "button" until I've solved display and resizing issues.The specific problem I've asked about in this thread is that once "undocked" (as these three in the window are), any attempt to "resize the undocked window" is causing the "MKR MUTE" DrawString to disappear and not get redrawn.http://forums.avsim.net/user_files/117104.jpg

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author
  • Moderator

Just to put a "period" on this thread, Chris K. was kind enough to provide the simple, yet elegant solution...In the PANEL_SERVICE_PRE_KILL routine, you have to use: if(init){GdiplusShutdown(gdiplusToken);init = false;} so that after a resize or undock or full screen/window toggle it can initialize again.This works, of course, because I used a similar routine to start Gdiplus to begin with:void FSAPI PFDCallBack ( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data ){ if(!init) { GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); init = true;}I only had the GdiplusShutdown(gdiplusToken); in the PRE_KILL section initially, so it would never "restart."Thanks everyone for your kind suggestions... ;)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

In this case why not just add strings to bitmaps?

  • Author
  • Moderator

>In this case why not just add strings to bitmaps?The rationale for this was covered in another thread, but to recapitulate briefly, using conventional MAKE_STRINGs would require a total of 33 MAKE_STRING entries and associated callbacks.Worse, since I need the "backlighted text" to be a softer white, that would double the number of MAKE_STRING entries and callbacks.More importantly, you cannot use a MAKE_STRING to create the Garmin "name Logo."Finally, it is an excellent excuse for me to buckle down and learn how to use new techniques! ;)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

I would use MAKE_ICON there with strings made in Photoshop :) Even if there is 33 icons, not so much really :)I trying minimize GDI+ usage to save FPS

  • Author
  • Moderator

>I would use MAKE_ICON there with strings made in Photoshop :)>Even if there is 33 icons, not so much really :)>I trying minimize GDI+ usage to save FPSMany people complain endlessly about "blurry text" on panels and gauge subpanels.I'd rather avoid those complaints by offering crisy, legible text for them to read. ;)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.