[MSGINA] gui: Improve DlgData_LoadBitmaps() (#2520)
authorSerge Gautherie <32623169+SergeGautherie@users.noreply.github.com>
Mon, 1 Jun 2020 09:26:53 +0000 (11:26 +0200)
committerGitHub <noreply@github.com>
Mon, 1 Jun 2020 09:26:53 +0000 (12:26 +0300)
And let bar timer depend on the bar image only.

Addendum to 623dd26ccea5e79001aee769c230fb4f8e304fc8.

dll/win32/msgina/gui.c

index 6301a19..3cb30bb 100644 (file)
@@ -56,28 +56,34 @@ DlgData_Create(HWND hwndDlg, PGINA_CONTEXT pgContext)
     return pDlgData;
 }
 
-static BOOL
-DlgData_LoadBitmaps(PDLG_DATA pDlgData)
+static VOID
+DlgData_LoadBitmaps(_Inout_ PDLG_DATA pDlgData)
 {
     BITMAP bm;
 
     if (!pDlgData)
-        return FALSE;
+    {
+        return;
+    }
 
     pDlgData->hLogoBitmap = LoadImageW(pDlgData->pgContext->hDllInstance,
                                        MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP,
                                        0, 0, LR_DEFAULTCOLOR);
-    GetObject(pDlgData->hLogoBitmap, sizeof(bm), &bm);
-    pDlgData->LogoWidth = bm.bmWidth;
-    pDlgData->LogoHeight = bm.bmHeight;
+    if (pDlgData->hLogoBitmap)
+    {
+        GetObject(pDlgData->hLogoBitmap, sizeof(bm), &bm);
+        pDlgData->LogoWidth = bm.bmWidth;
+        pDlgData->LogoHeight = bm.bmHeight;
+    }
 
     pDlgData->hBarBitmap = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_BAR),
                                       IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
-    GetObject(pDlgData->hBarBitmap, sizeof(bm), &bm);
-    pDlgData->BarWidth = bm.bmWidth;
-    pDlgData->BarHeight = bm.bmHeight;
-
-    return (pDlgData->hLogoBitmap != NULL && pDlgData->hBarBitmap != NULL);
+    if (pDlgData->hBarBitmap)
+    {
+        GetObject(pDlgData->hBarBitmap, sizeof(bm), &bm);
+        pDlgData->BarWidth = bm.bmWidth;
+        pDlgData->BarHeight = bm.bmHeight;
+    }
 }
 
 static void
@@ -192,15 +198,18 @@ StatusDialogProc(
             if (pDlgData == NULL)
                 return FALSE;
 
-            if (DlgData_LoadBitmaps(pDlgData))
+            DlgData_LoadBitmaps(pDlgData);
+            if (pDlgData->hBarBitmap)
             {
                 if (SetTimer(hwndDlg, IDT_BAR, 20, NULL) == 0)
                 {
                     ERR("SetTimer(IDT_BAR) failed: %d\n", GetLastError());
                 }
-
-                /* Get the animation bar control */
-                pDlgData->hWndBarCtrl = GetDlgItem(hwndDlg, IDC_BAR);
+                else
+                {
+                    /* Get the animation bar control */
+                    pDlgData->hWndBarCtrl = GetDlgItem(hwndDlg, IDC_BAR);
+                }
             }
             return TRUE;
         }