src/video/windows/SDL_windowsmessagebox.c
changeset 9863 334d18fb5dd1
parent 9619 b94b6d0bff0f
child 9998 f67cf37e9cd4
     1.1 --- a/src/video/windows/SDL_windowsmessagebox.c	Sun Sep 13 11:29:45 2015 -0400
     1.2 +++ b/src/video/windows/SDL_windowsmessagebox.c	Mon Sep 14 11:15:25 2015 -0700
     1.3 @@ -297,9 +297,12 @@
     1.4  
     1.5          /* Font size - convert to logical font size for dialog parameter. */
     1.6          {
     1.7 -            HDC ScreenDC = GetDC(0);
     1.8 -            WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / GetDeviceCaps(ScreenDC, LOGPIXELSY));
     1.9 -            ReleaseDC(0, ScreenDC);
    1.10 +            HDC ScreenDC = GetDC(NULL);
    1.11 +            int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY);
    1.12 +            if (!LogicalPixelsY) /* This can happen if the application runs out of GDI handles */
    1.13 +                LogicalPixelsY = 72;
    1.14 +            WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY);
    1.15 +            ReleaseDC(NULL, ScreenDC);
    1.16          }
    1.17  
    1.18          if (!AddDialogData(dialog, &WordToPass, 2)) {