2 rdesktop: A Remote Desktop Protocol client.
3 Connection settings dialog
4 Copyright (C) Ged Murphy 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #define MAX_KEY_NAME 255
27 static VOID
ReLoadGeneralPage(PINFO pInfo
);
28 static VOID
ReLoadDisplayPage(PINFO pInfo
);
31 DoOpenFile(PINFO pInfo
)
34 WCHAR szFileName
[MAX_PATH
] = L
"";
35 static WCHAR szFilter
[] = L
"Remote Desktop Files (*rdp)\0*.rdp\0";
37 ZeroMemory(&ofn
, sizeof(ofn
));
38 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
39 ofn
.hwndOwner
= pInfo
->hGeneralPage
;
40 ofn
.nMaxFile
= MAX_PATH
;
41 ofn
.nMaxFileTitle
= MAX_PATH
;
42 ofn
.lpstrDefExt
= L
"rdp";
43 ofn
.lpstrFilter
= szFilter
;
44 ofn
.lpstrFile
= szFileName
;
45 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
;
47 if (GetOpenFileNameW(&ofn
))
49 LoadRdpSettingsFromFile(pInfo
->pRdpSettings
, szFileName
);
50 ReLoadGeneralPage(pInfo
);
51 ReLoadDisplayPage(pInfo
);
60 WCHAR szFileName
[MAX_PATH
] = L
"";
61 static WCHAR szFilter
[] = L
"Remote Desktop Files (*rdp)\0*.rdp\0";
63 ZeroMemory(&ofn
, sizeof(ofn
));
64 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
65 ofn
.hwndOwner
= pInfo
->hGeneralPage
;
66 ofn
.nMaxFile
= MAX_PATH
;
67 ofn
.nMaxFileTitle
= MAX_PATH
;
68 ofn
.lpstrDefExt
= L
"rdp";
69 ofn
.lpstrFilter
= szFilter
;
70 ofn
.lpstrFile
= szFileName
;
71 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
;
73 if (GetSaveFileNameW(&ofn
))
75 SaveAllSettings(pInfo
);
76 SaveRdpSettingsToFile(szFileName
, pInfo
->pRdpSettings
);
82 OnTabWndSelChange(PINFO pInfo
)
84 switch (TabCtrl_GetCurSel(pInfo
->hTab
))
87 ShowWindow(pInfo
->hGeneralPage
, SW_SHOW
);
88 ShowWindow(pInfo
->hDisplayPage
, SW_HIDE
);
89 BringWindowToTop(pInfo
->hGeneralPage
);
92 ShowWindow(pInfo
->hGeneralPage
, SW_HIDE
);
93 ShowWindow(pInfo
->hDisplayPage
, SW_SHOW
);
94 BringWindowToTop(pInfo
->hDisplayPage
);
101 LoadUsernameHint(HWND hDlg
, INT iCur
)
103 WCHAR szValue
[MAXVALUE
+1000];
104 WCHAR szName
[MAX_KEY_NAME
];
105 WCHAR szKeyName
[] = L
"Software\\Microsoft\\Terminal Server Client\\Servers";
109 LONG lRet
= ERROR_SUCCESS
;
111 DWORD dwSize
= MAX_KEY_NAME
;
113 SendDlgItemMessageW(hDlg
, IDC_SERVERCOMBO
, CB_GETLBTEXT
, (WPARAM
)iCur
, (LPARAM
)szValue
);
115 /* remove possible port number */
116 lpAddress
= wcstok(szValue
, L
":");
118 if (lpAddress
== NULL
)
121 if (RegOpenKeyExW(HKEY_CURRENT_USER
,
125 &hKey
) == ERROR_SUCCESS
)
127 while (lRet
== ERROR_SUCCESS
)
129 dwSize
= MAX_KEY_NAME
;
131 lRet
= RegEnumKeyExW(hKey
, iIndex
, szName
, &dwSize
, NULL
, NULL
, NULL
, NULL
);
133 if(lRet
== ERROR_SUCCESS
&& wcscmp(szName
, lpAddress
) == 0)
135 if(RegOpenKeyExW(hKey
, szName
, 0, KEY_READ
, &hSubKey
) != ERROR_SUCCESS
)
140 if(RegQueryValueExW(hKey
, L
"UsernameHint", 0, NULL
, (LPBYTE
)szValue
, &dwSize
) == ERROR_SUCCESS
)
142 SetDlgItemTextW(hDlg
, IDC_NAMEEDIT
, szValue
);
145 RegCloseKey(hSubKey
);
156 FillServerAddesssCombo(PINFO pInfo
)
159 WCHAR KeyName
[] = L
"Software\\Microsoft\\Terminal Server Client\\Default";
160 WCHAR Name
[MAX_KEY_NAME
];
161 LONG ret
= ERROR_SUCCESS
;
166 if (RegOpenKeyExW(HKEY_CURRENT_USER
,
170 &hKey
) == ERROR_SUCCESS
)
172 while (ret
== ERROR_SUCCESS
)
175 ret
= RegEnumValueW(hKey
,
183 if (ret
== ERROR_SUCCESS
)
186 if (RegQueryValueExW(hKey
,
191 &size
) == ERROR_SUCCESS
)
193 LPWSTR lpAddress
= HeapAlloc(GetProcessHeap(),
198 if (RegQueryValueExW(hKey
,
203 &size
) == ERROR_SUCCESS
)
205 SendDlgItemMessageW(pInfo
->hGeneralPage
,
213 HeapFree(GetProcessHeap(),
225 if (LoadStringW(hInst
,
228 sizeof(Name
) / sizeof(WCHAR
)))
230 SendDlgItemMessageW(pInfo
->hGeneralPage
,
239 SendDlgItemMessageW(pInfo
->hGeneralPage
,
244 LoadUsernameHint(pInfo
->hGeneralPage
, 0);
251 ReLoadGeneralPage(PINFO pInfo
)
255 /* add file address */
256 lpText
= GetStringFromSettings(pInfo
->pRdpSettings
,
260 SetDlgItemTextW(pInfo
->hGeneralPage
,
266 lpText
= GetStringFromSettings(pInfo
->pRdpSettings
,
270 SetDlgItemTextW(pInfo
->hGeneralPage
,
278 GeneralOnInit(HWND hwnd
,
281 SetWindowLongPtrW(hwnd
,
285 pInfo
->hGeneralPage
= hwnd
;
287 SetWindowPos(pInfo
->hGeneralPage
,
293 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
295 pInfo
->hLogon
= LoadImageW(hInst
,
296 MAKEINTRESOURCEW(IDI_LOGON
),
303 SendDlgItemMessageW(pInfo
->hGeneralPage
,
306 (WPARAM
)pInfo
->hLogon
,
310 pInfo
->hConn
= LoadImageW(hInst
,
311 MAKEINTRESOURCEW(IDI_CONN
),
318 SendDlgItemMessageW(pInfo
->hGeneralPage
,
321 (WPARAM
)pInfo
->hConn
,
325 FillServerAddesssCombo(pInfo
);
326 ReLoadGeneralPage(pInfo
);
331 GeneralDlgProc(HWND hDlg
,
336 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
342 GeneralOnInit(hDlg
, (PINFO
)lParam
);
347 switch(LOWORD(wParam
))
349 case IDC_SERVERCOMBO
:
350 if (HIWORD(wParam
) == CBN_SELCHANGE
)
354 cur
= SendDlgItemMessageW(hDlg
,
360 last
= SendDlgItemMessageW(hDlg
,
365 if ((cur
+ 1) == last
)
366 MessageBoxW(hDlg
, L
"SMB is not yet supported", L
"RDP error", MB_ICONERROR
);
369 LoadUsernameHint(hDlg
, cur
);
375 SaveAllSettings(pInfo
);
376 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
394 DestroyIcon(pInfo
->hLogon
);
397 DestroyIcon(pInfo
->hConn
);
407 static PSETTINGS_ENTRY
408 GetPossibleSettings(IN LPCWSTR lpDeviceName
,
409 OUT DWORD
* pSettingsCount
,
410 OUT PSETTINGS_ENTRY
* CurrentSettings
)
413 DWORD NbSettings
= 0;
416 PSETTINGS_ENTRY Settings
= NULL
;
418 PSETTINGS_ENTRY Current
;
419 DWORD bpp
, xres
, yres
, checkbpp
;
421 /* Get current settings */
422 *CurrentSettings
= NULL
;
423 hDC
= CreateICW(NULL
, lpDeviceName
, NULL
, NULL
);
424 bpp
= GetDeviceCaps(hDC
, PLANES
);
425 bpp
*= GetDeviceCaps(hDC
, BITSPIXEL
);
426 xres
= GetDeviceCaps(hDC
, HORZRES
);
427 yres
= GetDeviceCaps(hDC
, VERTRES
);
430 /* List all settings */
431 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
432 devmode
.dmDriverExtra
= 0;
434 if (!EnumDisplaySettingsExW(lpDeviceName
, ENUM_CURRENT_SETTINGS
, &devmode
, dwFlags
))
437 while (EnumDisplaySettingsExW(lpDeviceName
, iMode
, &devmode
, dwFlags
))
439 if (devmode
.dmBitsPerPel
==8 ||
440 devmode
.dmBitsPerPel
==16 ||
441 devmode
.dmBitsPerPel
==24 ||
442 devmode
.dmBitsPerPel
==32)
449 if (devmode
.dmPelsWidth
< 640 ||
450 devmode
.dmPelsHeight
< 480 || checkbpp
== 0)
456 Current
= HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY
));
459 /* Sort resolutions by increasing height, and BPP */
460 PSETTINGS_ENTRY Previous
= NULL
;
461 PSETTINGS_ENTRY Next
= Settings
;
462 Current
->dmPelsWidth
= devmode
.dmPelsWidth
;
463 Current
->dmPelsHeight
= devmode
.dmPelsHeight
;
464 Current
->dmBitsPerPel
= devmode
.dmBitsPerPel
;
465 while (Next
!= NULL
&&
466 (Next
->dmPelsWidth
< Current
->dmPelsWidth
||
467 (Next
->dmPelsWidth
== Current
->dmPelsWidth
&& Next
->dmPelsHeight
< Current
->dmPelsHeight
) ||
468 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&&
469 Next
->dmPelsWidth
== Current
->dmPelsWidth
&&
470 Next
->dmBitsPerPel
< Current
->dmBitsPerPel
)))
475 Current
->Blink
= Previous
;
476 Current
->Flink
= Next
;
477 if (Previous
== NULL
)
480 Previous
->Flink
= Current
;
482 Next
->Blink
= Current
;
483 if (devmode
.dmPelsWidth
== xres
&& devmode
.dmPelsHeight
== yres
&& devmode
.dmBitsPerPel
== bpp
)
485 *CurrentSettings
= Current
;
492 *pSettingsCount
= NbSettings
;
498 AddDisplayDevice(PINFO pInfo
, PDISPLAY_DEVICEW DisplayDevice
)
500 PDISPLAY_DEVICE_ENTRY newEntry
= NULL
;
501 LPWSTR description
= NULL
;
505 DWORD descriptionSize
, nameSize
, keySize
, devidSize
;
506 PSETTINGS_ENTRY Current
;
507 DWORD ResolutionsCount
= 1;
510 newEntry
= HeapAlloc(GetProcessHeap(),
512 sizeof(DISPLAY_DEVICE_ENTRY
));
513 if (!newEntry
) goto ByeBye
;
514 ZeroMemory(newEntry
, sizeof(DISPLAY_DEVICE_ENTRY
));
516 newEntry
->Settings
= GetPossibleSettings(DisplayDevice
->DeviceName
,
517 &newEntry
->SettingsCount
,
518 &newEntry
->CurrentSettings
);
519 if (!newEntry
->Settings
) goto ByeBye
;
521 newEntry
->InitialSettings
.dmPelsWidth
= newEntry
->CurrentSettings
->dmPelsWidth
;
522 newEntry
->InitialSettings
.dmPelsHeight
= newEntry
->CurrentSettings
->dmPelsHeight
;
523 newEntry
->InitialSettings
.dmBitsPerPel
= newEntry
->CurrentSettings
->dmBitsPerPel
;
525 /* Count different resolutions */
526 for (Current
= newEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
528 if (Current
->Flink
!= NULL
&&
529 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
530 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
)))
536 newEntry
->Resolutions
= HeapAlloc(GetProcessHeap(),
538 ResolutionsCount
* (sizeof(RESOLUTION_INFO
) + 1));
539 if (!newEntry
->Resolutions
) goto ByeBye
;
541 newEntry
->ResolutionsCount
= ResolutionsCount
;
543 /* Fill resolutions infos */
544 for (Current
= newEntry
->Settings
, i
= 0; Current
!= NULL
; Current
= Current
->Flink
)
546 if (Current
->Flink
== NULL
||
547 (Current
->Flink
!= NULL
&&
548 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
549 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
))))
551 newEntry
->Resolutions
[i
].dmPelsWidth
= Current
->dmPelsWidth
;
552 newEntry
->Resolutions
[i
].dmPelsHeight
= Current
->dmPelsHeight
;
558 newEntry
->Resolutions
[i
].dmPelsWidth
= GetSystemMetrics(SM_CXSCREEN
);
559 newEntry
->Resolutions
[i
].dmPelsHeight
= GetSystemMetrics(SM_CYSCREEN
);
561 descriptionSize
= (wcslen(DisplayDevice
->DeviceString
) + 1) * sizeof(WCHAR
);
562 description
= HeapAlloc(GetProcessHeap(), 0, descriptionSize
);
563 if (!description
) goto ByeBye
;
565 nameSize
= (wcslen(DisplayDevice
->DeviceName
) + 1) * sizeof(WCHAR
);
566 name
= HeapAlloc(GetProcessHeap(), 0, nameSize
);
567 if (!name
) goto ByeBye
;
569 keySize
= (wcslen(DisplayDevice
->DeviceKey
) + 1) * sizeof(WCHAR
);
570 key
= HeapAlloc(GetProcessHeap(), 0, keySize
);
571 if (!key
) goto ByeBye
;
573 devidSize
= (wcslen(DisplayDevice
->DeviceID
) + 1) * sizeof(WCHAR
);
574 devid
= HeapAlloc(GetProcessHeap(), 0, devidSize
);
575 if (!devid
) goto ByeBye
;
577 memcpy(description
, DisplayDevice
->DeviceString
, descriptionSize
);
578 memcpy(name
, DisplayDevice
->DeviceName
, nameSize
);
579 memcpy(key
, DisplayDevice
->DeviceKey
, keySize
);
580 memcpy(devid
, DisplayDevice
->DeviceID
, devidSize
);
581 newEntry
->DeviceDescription
= description
;
582 newEntry
->DeviceName
= name
;
583 newEntry
->DeviceKey
= key
;
584 newEntry
->DeviceID
= devid
;
585 newEntry
->DeviceStateFlags
= DisplayDevice
->StateFlags
;
586 newEntry
->Flink
= pInfo
->DisplayDeviceList
;
587 pInfo
->DisplayDeviceList
= newEntry
;
591 if (newEntry
!= NULL
)
593 if (newEntry
->Settings
!= NULL
)
595 Current
= newEntry
->Settings
;
596 while (Current
!= NULL
)
598 PSETTINGS_ENTRY Next
= Current
->Flink
;
599 HeapFree(GetProcessHeap(), 0, Current
);
603 if (newEntry
->Resolutions
!= NULL
)
604 HeapFree(GetProcessHeap(), 0, newEntry
->Resolutions
);
605 HeapFree(GetProcessHeap(), 0, newEntry
);
607 if (description
!= NULL
)
608 HeapFree(GetProcessHeap(), 0, description
);
610 HeapFree(GetProcessHeap(), 0, name
);
612 HeapFree(GetProcessHeap(), 0, key
);
614 HeapFree(GetProcessHeap(), 0, devid
);
620 OnResolutionChanged(PINFO pInfo
, INT position
)
625 MaxSlider
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
631 if (position
== MaxSlider
)
636 sizeof(Buffer
) / sizeof(WCHAR
));
642 if (LoadStringW(hInst
,
645 sizeof(Pixel
) / sizeof(WCHAR
)))
650 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
651 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
656 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
657 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
663 SendDlgItemMessageW(pInfo
->hDisplayPage
,
664 IDC_SETTINGS_RESOLUTION_TEXT
,
672 FillResolutionsAndColors(PINFO pInfo
)
674 PSETTINGS_ENTRY Current
;
679 pInfo
->CurrentDisplayDevice
= pInfo
->DisplayDeviceList
; /* Update global variable */
682 SendDlgItemMessageW(pInfo
->hDisplayPage
,
687 for (Current
= pInfo
->DisplayDeviceList
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
689 if (Current
->dmBitsPerPel
> MaxBpp
)
690 MaxBpp
= Current
->dmBitsPerPel
;
695 case 24: num
= 4; break;
696 case 16: num
= 3; break;
697 case 8: num
= 1; break;
698 default: num
= 0; break;
701 types
[0] = IDS_256COLORS
;
702 types
[1] = IDS_HIGHCOLOR15
;
703 types
[2] = IDS_HIGHCOLOR16
;
704 types
[3] = IDS_HIGHCOLOR24
;
706 /* Fill color depths combo box */
707 SendDlgItemMessageW(pInfo
->hDisplayPage
,
713 for (i
= 0, Current
= pInfo
->DisplayDeviceList
->Settings
;
714 i
<= num
&& Current
!= NULL
;
715 i
++, Current
= Current
->Flink
)
718 if (LoadStringW(hInst
,
721 sizeof(Buffer
) / sizeof(WCHAR
)))
723 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
728 if (index
== (DWORD
)CB_ERR
)
730 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
735 SendDlgItemMessageW(pInfo
->hDisplayPage
,
744 /* Fill resolutions slider */
745 SendDlgItemMessageW(pInfo
->hDisplayPage
,
750 SendDlgItemMessageW(pInfo
->hDisplayPage
,
754 MAKELONG(0, pInfo
->DisplayDeviceList
->ResolutionsCount
)); //extra 1 for full screen
761 ReLoadDisplayPage(PINFO pInfo
)
764 INT width
, height
, pos
= 0;
765 INT bpp
, num
, i
, screenmode
;
768 /* get fullscreen info */
769 screenmode
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"screen mode id");
771 /* set trackbar position */
772 width
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopwidth");
773 height
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopheight");
775 if (width
!= -1 && height
!= -1)
779 pos
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
787 for (index
= 0; index
< pInfo
->CurrentDisplayDevice
->ResolutionsCount
; index
++)
789 if (pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsWidth
== width
&&
790 pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsHeight
== height
)
799 /* set slider position */
800 SendDlgItemMessageW(pInfo
->hDisplayPage
,
806 OnResolutionChanged(pInfo
, pos
);
809 /* set color combo */
810 bpp
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"session bpp");
812 num
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
817 for (i
= 0; i
< num
; i
++)
819 INT data
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
826 SendDlgItemMessageW(pInfo
->hDisplayPage
,
838 SendDlgItemMessageW(pInfo
->hDisplayPage
,
848 DisplayOnInit(HWND hwnd
,
851 DISPLAY_DEVICEW displayDevice
;
855 SetWindowLongPtrW(hwnd
,
859 pInfo
->hDisplayPage
= hwnd
;
861 SetWindowPos(pInfo
->hDisplayPage
,
867 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
869 pInfo
->hRemote
= LoadImageW(hInst
,
870 MAKEINTRESOURCEW(IDI_REMOTE
),
877 SendDlgItemMessageW(pInfo
->hDisplayPage
,
880 (WPARAM
)pInfo
->hRemote
,
884 pInfo
->hColor
= LoadImageW(hInst
,
885 MAKEINTRESOURCEW(IDI_COLORS
),
892 SendDlgItemMessageW(pInfo
->hDisplayPage
,
895 (WPARAM
)pInfo
->hColor
,
899 pInfo
->hSpectrum
= LoadImageW(hInst
,
900 MAKEINTRESOURCEW(IDB_SPECT
),
905 if (pInfo
->hSpectrum
)
907 GetObjectW(pInfo
->hSpectrum
,
912 /* Get video cards list */
913 displayDevice
.cb
= (DWORD
)sizeof(DISPLAY_DEVICE
);
914 while (EnumDisplayDevicesW(NULL
, iDevNum
, &displayDevice
, 0x1))
916 if ((displayDevice
.StateFlags
& DISPLAY_DEVICE_PRIMARY_DEVICE
) != 0)
918 if (AddDisplayDevice(pInfo
, &displayDevice
))
926 FillResolutionsAndColors(pInfo
);
927 ReLoadDisplayPage(pInfo
);
933 DisplayDlgProc(HWND hDlg
,
938 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
944 DisplayOnInit(hDlg
, (PINFO
)lParam
);
949 LPDRAWITEMSTRUCT lpDrawItem
;
950 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
951 if(lpDrawItem
->CtlID
== IDC_COLORIMAGE
)
955 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
958 hSpecOld
= SelectObject(hdcMem
, pInfo
->hSpectrum
);
959 StretchBlt(lpDrawItem
->hDC
,
960 lpDrawItem
->rcItem
.left
,
961 lpDrawItem
->rcItem
.top
,
962 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
963 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
967 pInfo
->bitmap
.bmWidth
,
968 pInfo
->bitmap
.bmHeight
,
970 SelectObject(hdcMem
, hSpecOld
);
979 switch (LOWORD(wParam
))
989 INT newPosition
= (DWORD
)SendDlgItemMessageW(hDlg
, IDC_GEOSLIDER
, TBM_GETPOS
, 0, 0);
990 OnResolutionChanged(pInfo
, newPosition
);
995 OnResolutionChanged(pInfo
, HIWORD(wParam
));
1004 DestroyIcon(pInfo
->hRemote
);
1007 DestroyIcon(pInfo
->hColor
);
1009 if (pInfo
->hSpectrum
)
1010 DeleteObject(pInfo
->hSpectrum
);
1022 OnMainCreate(HWND hwnd
,
1023 PRDPSETTINGS pRdpSettings
)
1029 pInfo
= HeapAlloc(GetProcessHeap(),
1034 SetWindowLongPtrW(hwnd
,
1038 pInfo
->hSelf
= hwnd
;
1040 /* add main settings pointer */
1041 pInfo
->pRdpSettings
= pRdpSettings
;
1043 /* set the dialog icons */
1044 pInfo
->hMstscSm
= LoadImageW(hInst
,
1045 MAKEINTRESOURCEW(IDI_MSTSC
),
1050 if (pInfo
->hMstscSm
)
1055 (WPARAM
)pInfo
->hMstscSm
);
1057 pInfo
->hMstscLg
= LoadImageW(hInst
,
1058 MAKEINTRESOURCEW(IDI_MSTSC
),
1063 if (pInfo
->hMstscLg
)
1068 (WPARAM
)pInfo
->hMstscLg
);
1071 pInfo
->hHeader
= (HBITMAP
)LoadImageW(hInst
,
1072 MAKEINTRESOURCEW(IDB_HEADER
),
1079 GetObjectW(pInfo
->hHeader
,
1081 &pInfo
->headerbitmap
);
1084 /* setup the tabs */
1085 pInfo
->hTab
= GetDlgItem(hwnd
, IDC_TAB
);
1088 if (CreateDialogParamW(hInst
,
1089 MAKEINTRESOURCEW(IDD_GENERAL
),
1095 ZeroMemory(&item
, sizeof(TCITEM
));
1096 item
.mask
= TCIF_TEXT
;
1097 if (LoadStringW(hInst
, IDS_TAB_GENERAL
, str
, 256))
1099 item
.cchTextMax
= 256;
1100 (void)TabCtrl_InsertItem(pInfo
->hTab
, 0, &item
);
1103 if (CreateDialogParamW(hInst
,
1104 MAKEINTRESOURCEW(IDD_DISPLAY
),
1110 ZeroMemory(&item
, sizeof(TCITEM
));
1111 item
.mask
= TCIF_TEXT
;
1112 if (LoadStringW(hInst
, IDS_TAB_DISPLAY
, str
, 256))
1114 item
.cchTextMax
= 256;
1115 (void)TabCtrl_InsertItem(pInfo
->hTab
, 1, &item
);
1118 OnTabWndSelChange(pInfo
);
1125 static void Cleanup(PINFO pInfo
)
1129 if (pInfo
->hMstscSm
)
1130 DestroyIcon(pInfo
->hMstscSm
);
1131 if (pInfo
->hMstscLg
)
1132 DestroyIcon(pInfo
->hMstscLg
);
1134 DeleteObject(pInfo
->hHeader
);
1135 if (pInfo
->hSpectrum
)
1136 DeleteObject(pInfo
->hSpectrum
);
1138 DestroyIcon(pInfo
->hRemote
);
1140 DestroyIcon(pInfo
->hLogon
);
1142 DestroyIcon(pInfo
->hConn
);
1144 DestroyIcon(pInfo
->hColor
);
1145 HeapFree(GetProcessHeap(),
1151 static INT_PTR CALLBACK
1159 /* Get the window context */
1160 pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
1162 if (pInfo
== NULL
&& Message
!= WM_INITDIALOG
)
1164 goto HandleDefaultMessage
;
1170 OnMainCreate(hDlg
, (PRDPSETTINGS
)lParam
);
1175 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
1177 if (LOWORD(wParam
) == IDOK
)
1179 SaveAllSettings(pInfo
);
1180 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
1183 EndDialog(hDlg
, LOWORD(wParam
));
1193 //idctrl = (int)wParam;
1194 pnmh
= (LPNMHDR
)lParam
;
1195 if (//(pnmh->hwndFrom == pInfo->hSelf) &&
1196 (pnmh
->idFrom
== IDC_TAB
) &&
1197 (pnmh
->code
== TCN_SELCHANGE
))
1199 OnTabWndSelChange(pInfo
);
1210 hdc
= BeginPaint(hDlg
, &ps
);
1213 HDC hdcMem
= CreateCompatibleDC(hdc
);
1219 HFONT hFont
, hFontOld
;
1222 GetClientRect(pInfo
->hSelf
, &bmpRc
);
1224 hBmpOld
= SelectObject(hdcMem
, pInfo
->hHeader
);
1229 pInfo
->headerbitmap
.bmHeight
,
1233 pInfo
->headerbitmap
.bmWidth
,
1234 pInfo
->headerbitmap
.bmHeight
,
1237 SelectObject(hdcMem
, hBmpOld
);
1238 txtRc
.left
= bmpRc
.right
/ 4;
1240 txtRc
.right
= bmpRc
.right
* 3 / 4;
1241 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
/ 2;
1243 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1245 if (LoadStringW(hInst
,
1248 sizeof(szBuffer
) / sizeof(WCHAR
)))
1251 lf
.lfCharSet
= OEM_CHARSET
;
1252 lf
.lfQuality
= DEFAULT_QUALITY
;
1253 lf
.lfWeight
= FW_MEDIUM
;
1254 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1256 hFont
= CreateFontIndirectW(&lf
);
1259 hFontOld
= SelectObject(hdc
, hFont
);
1261 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1262 SetTextColor(hdc
, RGB(255,255,255));
1263 SetBkMode(hdc
, TRANSPARENT
);
1268 DT_BOTTOM
| DT_SINGLELINE
| DT_NOCLIP
);
1269 SelectObject(hdc
, hFontOld
);
1270 DeleteObject(hFont
);
1274 txtRc
.left
= bmpRc
.right
/ 4;
1275 txtRc
.top
= txtRc
.bottom
- 5;
1276 txtRc
.right
= bmpRc
.right
* 3 / 4;
1277 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
* 9 / 10;
1279 if (LoadStringW(hInst
,
1282 sizeof(szBuffer
) / sizeof(WCHAR
)))
1285 lf
.lfCharSet
= OEM_CHARSET
;
1286 lf
.lfQuality
= DEFAULT_QUALITY
;
1287 lf
.lfWeight
= FW_EXTRABOLD
;
1288 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1290 hFont
= CreateFontIndirectW(&lf
);
1293 hFontOld
= SelectObject(hdc
, hFont
);
1295 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1296 SetTextColor(hdc
, RGB(255,255,255));
1297 SetBkMode(hdc
, TRANSPARENT
);
1302 DT_TOP
| DT_SINGLELINE
);
1303 SelectObject(hdc
, hFontOld
);
1304 DeleteObject(hFont
);
1311 EndPaint(hDlg
, &ps
);
1324 HandleDefaultMessage
:
1334 OpenRDPConnectDialog(HINSTANCE hInstance
,
1335 PRDPSETTINGS pRdpSettings
)
1337 INITCOMMONCONTROLSEX iccx
;
1341 iccx
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1342 iccx
.dwICC
= ICC_TAB_CLASSES
;
1343 InitCommonControlsEx(&iccx
);
1345 return (DialogBoxParamW(hInst
,
1346 MAKEINTRESOURCEW(IDD_CONNECTDIALOG
),
1349 (LPARAM
)pRdpSettings
) == IDOK
);