i++;
}
+ RegCloseKey(hKey);
}
if (LoadStringW(hInst,
if(lpDrawItem->CtlID == IDC_COLORIMAGE)
{
HDC hdcMem;
+ HBITMAP hSpecOld;
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL)
{
- SelectObject(hdcMem, pInfo->hSpectrum);
+ hSpecOld = SelectObject(hdcMem, pInfo->hSpectrum);
StretchBlt(lpDrawItem->hDC,
lpDrawItem->rcItem.left,
lpDrawItem->rcItem.top,
pInfo->bitmap.bmWidth,
pInfo->bitmap.bmHeight,
SRCCOPY);
+ SelectObject(hdcMem, hSpecOld);
DeleteDC(hdcMem);
}
}
return bRet;
}
+static void Cleanup(PINFO pInfo)
+{
+ if (pInfo)
+ {
+ if (pInfo->hMstscSm)
+ DestroyIcon(pInfo->hMstscSm);
+ if (pInfo->hMstscLg)
+ DestroyIcon(pInfo->hMstscLg);
+ if (pInfo->hHeader)
+ DeleteObject(pInfo->hHeader);
+ if (pInfo->hSpectrum)
+ DeleteObject(pInfo->hSpectrum);
+ if (pInfo->hRemote)
+ DestroyIcon(pInfo->hRemote);
+ if (pInfo->hLogon)
+ DestroyIcon(pInfo->hLogon);
+ if (pInfo->hConn)
+ DestroyIcon(pInfo->hConn);
+ if (pInfo->hColor)
+ DestroyIcon(pInfo->hColor);
+ HeapFree(GetProcessHeap(),
+ 0,
+ pInfo);
+ }
+}
static INT_PTR CALLBACK
DlgProc(HWND hDlg,
SaveAllSettings(pInfo);
SaveRdpSettingsToFile(NULL, pInfo->pRdpSettings);
}
-
- if (pInfo)
- {
- HeapFree(GetProcessHeap(),
- 0,
- pInfo);
- }
-
+ Cleanup(pInfo);
EndDialog(hDlg, LOWORD(wParam));
}
WCHAR szBuffer[32];
RECT bmpRc, txtRc;
LOGFONTW lf;
- HFONT hFont;
+ HFONT hFont, hFontOld;
+ HBITMAP hBmpOld;
GetClientRect(pInfo->hSelf, &bmpRc);
- SelectObject(hdcMem, pInfo->hHeader);
+ hBmpOld = SelectObject(hdcMem, pInfo->hHeader);
StretchBlt(hdc,
0,
0,
pInfo->headerbitmap.bmHeight,
SRCCOPY);
+ SelectObject(hdcMem, hBmpOld);
txtRc.left = bmpRc.right * 0.25;
txtRc.top = 10;
txtRc.right = bmpRc.right * 0.75;
hFont = CreateFontIndirectW(&lf);
if (hFont)
{
- SelectObject(hdc, hFont);
+ hFontOld = SelectObject(hdc, hFont);
DPtoLP(hdc, (PPOINT)&txtRc, 2);
SetTextColor(hdc, RGB(255,255,255));
-1,
&txtRc,
DT_BOTTOM | DT_SINGLELINE | DT_NOCLIP);
+ SelectObject(hdc, hFontOld);
DeleteObject(hFont);
}
}
hFont = CreateFontIndirectW(&lf);
if (hFont)
{
- SelectObject(hdc, hFont);
+ hFontOld = SelectObject(hdc, hFont);
DPtoLP(hdc, (PPOINT)&txtRc, 2);
SetTextColor(hdc, RGB(255,255,255));
-1,
&txtRc,
DT_TOP | DT_SINGLELINE);
+ SelectObject(hdc, hFontOld);
+ DeleteObject(hFont);
}
}
case WM_CLOSE:
{
- if (pInfo)
- {
- if (pInfo->hMstscSm)
- DestroyIcon(pInfo->hMstscSm);
- if (pInfo->hMstscLg)
- DestroyIcon(pInfo->hMstscLg);
- if (pInfo->hHeader)
- DeleteObject(pInfo->hHeader);
-
- HeapFree(GetProcessHeap(),
- 0,
- pInfo);
- }
-
+ Cleanup(pInfo);
EndDialog(hDlg, 0);
}
break;