src/video/windows/SDL_windowsmessagebox.c
changeset 11303 23000b73ce4e
parent 11236 8c3cba28b1fd
child 11375 2dd1cac9e43a
equal deleted inserted replaced
11302:657c10a0a705 11303:23000b73ce4e
   409     SelectObject(FontDC, DialogFont);
   409     SelectObject(FontDC, DialogFont);
   410 
   410 
   411     {
   411     {
   412         /* Get the metrics to try and figure our DLU conversion. */
   412         /* Get the metrics to try and figure our DLU conversion. */
   413         GetTextMetrics(FontDC, &TM);
   413         GetTextMetrics(FontDC, &TM);
   414         s_BaseUnitsX = TM.tmAveCharWidth + 1;
   414 
       
   415         /* Calculation from the following documentation:
       
   416          * https://support.microsoft.com/en-gb/help/125681/how-to-calculate-dialog-base-units-with-non-system-based-font
       
   417          * This fixes bug 2137, dialog box calculation with a fixed-width system font
       
   418          */
       
   419         {
       
   420             SIZE extent;
       
   421             GetTextExtentPoint32A(FontDC, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &extent);
       
   422             s_BaseUnitsX = (extent.cx / 26 + 1) / 2;
       
   423         }
       
   424         /*s_BaseUnitsX = TM.tmAveCharWidth + 1;*/
   415         s_BaseUnitsY = TM.tmHeight;
   425         s_BaseUnitsY = TM.tmHeight;
   416     }
   426     }
   417 
   427 
   418     /* Measure the *pixel* size of the string. */
   428     /* Measure the *pixel* size of the string. */
   419     wmessage = WIN_UTF8ToString(messageboxdata->message);
   429     wmessage = WIN_UTF8ToString(messageboxdata->message);
   420     SDL_zero(TextSize);
   430     SDL_zero(TextSize);
   421     Size.cx = DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT);
   431     DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT);
   422 
   432 
   423     /* Add some padding for hangs, etc. */
   433     /* Add some padding for hangs, etc. */
   424     TextSize.right += 2;
   434     TextSize.right += 2;
   425     TextSize.bottom += 2;
   435     TextSize.bottom += 2;
   426 
   436