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.
26 #define MAX_KEY_NAME 255
30 static VOID
ReLoadGeneralPage(PINFO pInfo
);
31 static VOID
ReLoadDisplayPage(PINFO pInfo
);
34 DoOpenFile(PINFO pInfo
)
37 WCHAR szFileName
[MAX_PATH
] = L
"Default.rdp";
38 static WCHAR szFilter
[] = L
"Remote Desktop Files (*.RDP)\0*.rdp\0";
40 ZeroMemory(&ofn
, sizeof(ofn
));
41 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
42 ofn
.hwndOwner
= pInfo
->hGeneralPage
;
43 ofn
.nMaxFile
= MAX_PATH
;
44 ofn
.nMaxFileTitle
= MAX_PATH
;
45 ofn
.lpstrDefExt
= L
"RDP";
46 ofn
.lpstrFilter
= szFilter
;
47 ofn
.lpstrFile
= szFileName
;
48 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
;
50 if (GetOpenFileNameW(&ofn
))
52 LoadRdpSettingsFromFile(pInfo
->pRdpSettings
, szFileName
);
53 ReLoadGeneralPage(pInfo
);
54 ReLoadDisplayPage(pInfo
);
63 WCHAR szFileName
[MAX_PATH
] = L
"Default.rdp";
64 static WCHAR szFilter
[] = L
"Remote Desktop Files (*.RDP)\0*.rdp\0";
66 ZeroMemory(&ofn
, sizeof(ofn
));
67 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
68 ofn
.hwndOwner
= pInfo
->hGeneralPage
;
69 ofn
.nMaxFile
= MAX_PATH
;
70 ofn
.nMaxFileTitle
= MAX_PATH
;
71 ofn
.lpstrDefExt
= L
"RDP";
72 ofn
.lpstrFilter
= szFilter
;
73 ofn
.lpstrFile
= szFileName
;
74 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
;
76 if (GetSaveFileNameW(&ofn
))
78 SaveAllSettings(pInfo
);
79 SaveRdpSettingsToFile(szFileName
, pInfo
->pRdpSettings
);
85 OnTabWndSelChange(PINFO pInfo
)
87 switch (TabCtrl_GetCurSel(pInfo
->hTab
))
90 ShowWindow(pInfo
->hGeneralPage
, SW_SHOW
);
91 ShowWindow(pInfo
->hDisplayPage
, SW_HIDE
);
92 BringWindowToTop(pInfo
->hGeneralPage
);
95 ShowWindow(pInfo
->hGeneralPage
, SW_HIDE
);
96 ShowWindow(pInfo
->hDisplayPage
, SW_SHOW
);
97 BringWindowToTop(pInfo
->hDisplayPage
);
104 LoadUsernameHint(HWND hDlg
, INT iCur
)
106 WCHAR szValue
[MAXVALUE
+1000];
107 WCHAR szName
[MAX_KEY_NAME
];
108 WCHAR szKeyName
[] = L
"Software\\Microsoft\\Terminal Server Client\\Servers";
112 LONG lRet
= ERROR_SUCCESS
;
114 DWORD dwSize
= MAX_KEY_NAME
;
116 SendDlgItemMessageW(hDlg
, IDC_SERVERCOMBO
, CB_GETLBTEXT
, (WPARAM
)iCur
, (LPARAM
)szValue
);
118 /* remove possible port number */
119 lpAddress
= wcstok(szValue
, L
":");
121 if (lpAddress
== NULL
)
124 if (RegOpenKeyExW(HKEY_CURRENT_USER
,
128 &hKey
) == ERROR_SUCCESS
)
130 while (lRet
== ERROR_SUCCESS
)
132 dwSize
= MAX_KEY_NAME
;
134 lRet
= RegEnumKeyExW(hKey
, iIndex
, szName
, &dwSize
, NULL
, NULL
, NULL
, NULL
);
136 if(lRet
== ERROR_SUCCESS
&& wcscmp(szName
, lpAddress
) == 0)
138 if(RegOpenKeyExW(hKey
, szName
, 0, KEY_READ
, &hSubKey
) != ERROR_SUCCESS
)
141 dwSize
= MAXVALUE
* sizeof(WCHAR
);
143 if(RegQueryValueExW(hKey
, L
"UsernameHint", 0, NULL
, (LPBYTE
)szValue
, &dwSize
) == ERROR_SUCCESS
)
145 SetDlgItemTextW(hDlg
, IDC_NAMEEDIT
, szValue
);
148 RegCloseKey(hSubKey
);
159 FillServerAddressCombo(PINFO pInfo
)
162 WCHAR KeyName
[] = L
"Software\\Microsoft\\Terminal Server Client\\Default";
163 WCHAR Name
[MAX_KEY_NAME
];
164 LONG ret
= ERROR_SUCCESS
;
169 if (RegOpenKeyExW(HKEY_CURRENT_USER
,
173 &hKey
) == ERROR_SUCCESS
)
175 while (ret
== ERROR_SUCCESS
)
178 ret
= RegEnumValueW(hKey
,
186 if (ret
== ERROR_SUCCESS
)
189 if (RegQueryValueExW(hKey
,
194 &size
) == ERROR_SUCCESS
)
196 LPWSTR lpAddress
= HeapAlloc(GetProcessHeap(),
201 if (RegQueryValueExW(hKey
,
206 &size
) == ERROR_SUCCESS
)
208 SendDlgItemMessageW(pInfo
->hGeneralPage
,
216 HeapFree(GetProcessHeap(),
228 if (LoadStringW(hInst
,
231 sizeof(Name
) / sizeof(WCHAR
)))
233 SendDlgItemMessageW(pInfo
->hGeneralPage
,
242 SendDlgItemMessageW(pInfo
->hGeneralPage
,
247 LoadUsernameHint(pInfo
->hGeneralPage
, 0);
254 ReLoadGeneralPage(PINFO pInfo
)
258 /* add file address */
259 lpText
= GetStringFromSettings(pInfo
->pRdpSettings
,
263 SetDlgItemTextW(pInfo
->hGeneralPage
,
269 lpText
= GetStringFromSettings(pInfo
->pRdpSettings
,
273 SetDlgItemTextW(pInfo
->hGeneralPage
,
281 GeneralOnInit(HWND hwnd
,
284 SetWindowLongPtrW(hwnd
,
288 pInfo
->hGeneralPage
= hwnd
;
290 SetWindowPos(pInfo
->hGeneralPage
,
296 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
298 pInfo
->hLogon
= LoadImageW(hInst
,
299 MAKEINTRESOURCEW(IDI_LOGON
),
306 SendDlgItemMessageW(pInfo
->hGeneralPage
,
309 (WPARAM
)pInfo
->hLogon
,
313 pInfo
->hConn
= LoadImageW(hInst
,
314 MAKEINTRESOURCEW(IDI_CONN
),
321 SendDlgItemMessageW(pInfo
->hGeneralPage
,
324 (WPARAM
)pInfo
->hConn
,
328 FillServerAddressCombo(pInfo
);
329 ReLoadGeneralPage(pInfo
);
334 GeneralDlgProc(HWND hDlg
,
339 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
345 GeneralOnInit(hDlg
, (PINFO
)lParam
);
350 switch(LOWORD(wParam
))
352 case IDC_SERVERCOMBO
:
353 if (HIWORD(wParam
) == CBN_SELCHANGE
)
357 cur
= SendDlgItemMessageW(hDlg
,
363 last
= SendDlgItemMessageW(hDlg
,
368 if ((cur
+ 1) == last
)
369 MessageBoxW(hDlg
, L
"SMB is not yet supported", L
"RDP error", MB_ICONERROR
);
372 LoadUsernameHint(hDlg
, cur
);
378 SaveAllSettings(pInfo
);
379 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
397 DestroyIcon(pInfo
->hLogon
);
400 DestroyIcon(pInfo
->hConn
);
410 static PSETTINGS_ENTRY
411 GetPossibleSettings(IN LPCWSTR lpDeviceName
,
412 OUT DWORD
* pSettingsCount
,
413 OUT PSETTINGS_ENTRY
* CurrentSettings
)
416 DWORD NbSettings
= 0;
419 PSETTINGS_ENTRY Settings
= NULL
;
421 PSETTINGS_ENTRY Current
;
422 DWORD bpp
, xres
, yres
, checkbpp
;
424 /* Get current settings */
425 *CurrentSettings
= NULL
;
426 hDC
= CreateICW(NULL
, lpDeviceName
, NULL
, NULL
);
427 bpp
= GetDeviceCaps(hDC
, PLANES
);
428 bpp
*= GetDeviceCaps(hDC
, BITSPIXEL
);
429 xres
= GetDeviceCaps(hDC
, HORZRES
);
430 yres
= GetDeviceCaps(hDC
, VERTRES
);
433 /* List all settings */
434 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
435 devmode
.dmDriverExtra
= 0;
437 if (!EnumDisplaySettingsExW(lpDeviceName
, ENUM_CURRENT_SETTINGS
, &devmode
, dwFlags
))
440 while (EnumDisplaySettingsExW(lpDeviceName
, iMode
, &devmode
, dwFlags
))
442 if (devmode
.dmBitsPerPel
==8 ||
443 devmode
.dmBitsPerPel
==16 ||
444 devmode
.dmBitsPerPel
==24 ||
445 devmode
.dmBitsPerPel
==32)
452 if (devmode
.dmPelsWidth
< 640 ||
453 devmode
.dmPelsHeight
< 480 || checkbpp
== 0)
459 Current
= HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY
));
462 /* Sort resolutions by increasing height, and BPP */
463 PSETTINGS_ENTRY Previous
= NULL
;
464 PSETTINGS_ENTRY Next
= Settings
;
465 Current
->dmPelsWidth
= devmode
.dmPelsWidth
;
466 Current
->dmPelsHeight
= devmode
.dmPelsHeight
;
467 Current
->dmBitsPerPel
= devmode
.dmBitsPerPel
;
468 while (Next
!= NULL
&&
469 (Next
->dmPelsWidth
< Current
->dmPelsWidth
||
470 (Next
->dmPelsWidth
== Current
->dmPelsWidth
&& Next
->dmPelsHeight
< Current
->dmPelsHeight
) ||
471 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&&
472 Next
->dmPelsWidth
== Current
->dmPelsWidth
&&
473 Next
->dmBitsPerPel
< Current
->dmBitsPerPel
)))
478 Current
->Blink
= Previous
;
479 Current
->Flink
= Next
;
480 if (Previous
== NULL
)
483 Previous
->Flink
= Current
;
485 Next
->Blink
= Current
;
486 if (devmode
.dmPelsWidth
== xres
&& devmode
.dmPelsHeight
== yres
&& devmode
.dmBitsPerPel
== bpp
)
488 *CurrentSettings
= Current
;
495 *pSettingsCount
= NbSettings
;
501 AddDisplayDevice(PINFO pInfo
, PDISPLAY_DEVICEW DisplayDevice
)
503 PDISPLAY_DEVICE_ENTRY newEntry
= NULL
;
504 LPWSTR description
= NULL
;
508 DWORD descriptionSize
, nameSize
, keySize
, devidSize
;
509 PSETTINGS_ENTRY Current
;
510 DWORD ResolutionsCount
= 1;
513 newEntry
= HeapAlloc(GetProcessHeap(),
515 sizeof(DISPLAY_DEVICE_ENTRY
));
516 if (!newEntry
) goto ByeBye
;
517 ZeroMemory(newEntry
, sizeof(DISPLAY_DEVICE_ENTRY
));
519 newEntry
->Settings
= GetPossibleSettings(DisplayDevice
->DeviceName
,
520 &newEntry
->SettingsCount
,
521 &newEntry
->CurrentSettings
);
522 if (!newEntry
->Settings
) goto ByeBye
;
524 newEntry
->InitialSettings
.dmPelsWidth
= newEntry
->CurrentSettings
->dmPelsWidth
;
525 newEntry
->InitialSettings
.dmPelsHeight
= newEntry
->CurrentSettings
->dmPelsHeight
;
526 newEntry
->InitialSettings
.dmBitsPerPel
= newEntry
->CurrentSettings
->dmBitsPerPel
;
528 /* Count different resolutions */
529 for (Current
= newEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
531 if (Current
->Flink
!= NULL
&&
532 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
533 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
)))
539 newEntry
->Resolutions
= HeapAlloc(GetProcessHeap(),
541 ResolutionsCount
* (sizeof(RESOLUTION_INFO
) + 1));
542 if (!newEntry
->Resolutions
) goto ByeBye
;
544 newEntry
->ResolutionsCount
= ResolutionsCount
;
546 /* Fill resolutions infos */
547 for (Current
= newEntry
->Settings
, i
= 0; Current
!= NULL
; Current
= Current
->Flink
)
549 if (Current
->Flink
== NULL
||
550 (Current
->Flink
!= NULL
&&
551 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
552 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
))))
554 newEntry
->Resolutions
[i
].dmPelsWidth
= Current
->dmPelsWidth
;
555 newEntry
->Resolutions
[i
].dmPelsHeight
= Current
->dmPelsHeight
;
561 newEntry
->Resolutions
[i
].dmPelsWidth
= GetSystemMetrics(SM_CXSCREEN
);
562 newEntry
->Resolutions
[i
].dmPelsHeight
= GetSystemMetrics(SM_CYSCREEN
);
564 descriptionSize
= (wcslen(DisplayDevice
->DeviceString
) + 1) * sizeof(WCHAR
);
565 description
= HeapAlloc(GetProcessHeap(), 0, descriptionSize
);
566 if (!description
) goto ByeBye
;
568 nameSize
= (wcslen(DisplayDevice
->DeviceName
) + 1) * sizeof(WCHAR
);
569 name
= HeapAlloc(GetProcessHeap(), 0, nameSize
);
570 if (!name
) goto ByeBye
;
572 keySize
= (wcslen(DisplayDevice
->DeviceKey
) + 1) * sizeof(WCHAR
);
573 key
= HeapAlloc(GetProcessHeap(), 0, keySize
);
574 if (!key
) goto ByeBye
;
576 devidSize
= (wcslen(DisplayDevice
->DeviceID
) + 1) * sizeof(WCHAR
);
577 devid
= HeapAlloc(GetProcessHeap(), 0, devidSize
);
578 if (!devid
) goto ByeBye
;
580 memcpy(description
, DisplayDevice
->DeviceString
, descriptionSize
);
581 memcpy(name
, DisplayDevice
->DeviceName
, nameSize
);
582 memcpy(key
, DisplayDevice
->DeviceKey
, keySize
);
583 memcpy(devid
, DisplayDevice
->DeviceID
, devidSize
);
584 newEntry
->DeviceDescription
= description
;
585 newEntry
->DeviceName
= name
;
586 newEntry
->DeviceKey
= key
;
587 newEntry
->DeviceID
= devid
;
588 newEntry
->DeviceStateFlags
= DisplayDevice
->StateFlags
;
589 newEntry
->Flink
= pInfo
->DisplayDeviceList
;
590 pInfo
->DisplayDeviceList
= newEntry
;
594 if (newEntry
!= NULL
)
596 if (newEntry
->Settings
!= NULL
)
598 Current
= newEntry
->Settings
;
599 while (Current
!= NULL
)
601 PSETTINGS_ENTRY Next
= Current
->Flink
;
602 HeapFree(GetProcessHeap(), 0, Current
);
606 if (newEntry
->Resolutions
!= NULL
)
607 HeapFree(GetProcessHeap(), 0, newEntry
->Resolutions
);
608 HeapFree(GetProcessHeap(), 0, newEntry
);
610 if (description
!= NULL
)
611 HeapFree(GetProcessHeap(), 0, description
);
613 HeapFree(GetProcessHeap(), 0, name
);
615 HeapFree(GetProcessHeap(), 0, key
);
617 HeapFree(GetProcessHeap(), 0, devid
);
623 OnResolutionChanged(PINFO pInfo
, INT position
)
628 MaxSlider
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
634 if (position
== MaxSlider
)
639 sizeof(Buffer
) / sizeof(WCHAR
));
645 if (LoadStringW(hInst
,
648 sizeof(Pixel
) / sizeof(WCHAR
)))
652 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
653 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
658 SendDlgItemMessageW(pInfo
->hDisplayPage
,
659 IDC_SETTINGS_RESOLUTION_TEXT
,
667 FillResolutionsAndColors(PINFO pInfo
)
669 PSETTINGS_ENTRY Current
;
674 pInfo
->CurrentDisplayDevice
= pInfo
->DisplayDeviceList
; /* Update global variable */
677 SendDlgItemMessageW(pInfo
->hDisplayPage
,
682 for (Current
= pInfo
->DisplayDeviceList
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
684 if (Current
->dmBitsPerPel
> MaxBpp
)
685 MaxBpp
= Current
->dmBitsPerPel
;
689 case 32: num
= 4; break;
690 case 24: num
= 3; break;
691 case 16: num
= 2; break;
692 case 15: num
= 1; break;
693 case 8: num
= 0; break;
694 default: num
= 0; break;
697 types
[0] = IDS_256COLORS
;
698 types
[1] = IDS_HIGHCOLOR15
;
699 types
[2] = IDS_HIGHCOLOR16
;
700 types
[3] = IDS_HIGHCOLOR24
;
701 types
[4] = IDS_HIGHCOLOR32
;
703 /* Fill color depths combo box */
704 SendDlgItemMessageW(pInfo
->hDisplayPage
,
710 for (i
= 0, Current
= pInfo
->DisplayDeviceList
->Settings
;
711 i
<= num
&& Current
!= NULL
;
712 i
++, Current
= Current
->Flink
)
715 if (LoadStringW(hInst
,
718 sizeof(Buffer
) / sizeof(WCHAR
)))
720 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
725 if (index
== (DWORD
)CB_ERR
)
727 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
732 SendDlgItemMessageW(pInfo
->hDisplayPage
,
741 /* Fill resolutions slider */
742 SendDlgItemMessageW(pInfo
->hDisplayPage
,
747 SendDlgItemMessageW(pInfo
->hDisplayPage
,
751 MAKELONG(0, pInfo
->DisplayDeviceList
->ResolutionsCount
)); //extra 1 for full screen
758 ReLoadDisplayPage(PINFO pInfo
)
761 INT width
, height
, pos
= 0;
762 INT bpp
, num
, i
, screenmode
;
765 /* get fullscreen info */
766 screenmode
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"screen mode id");
768 /* set trackbar position */
769 width
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopwidth");
770 height
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopheight");
772 if (width
!= -1 && height
!= -1)
776 pos
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
784 for (index
= 0; index
< pInfo
->CurrentDisplayDevice
->ResolutionsCount
; index
++)
786 if (pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsWidth
== width
&&
787 pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsHeight
== height
)
796 /* set slider position */
797 SendDlgItemMessageW(pInfo
->hDisplayPage
,
803 OnResolutionChanged(pInfo
, pos
);
806 /* set color combo */
807 bpp
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"session bpp");
809 num
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
814 for (i
= 0; i
< num
; i
++)
816 INT data
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
823 SendDlgItemMessageW(pInfo
->hDisplayPage
,
835 SendDlgItemMessageW(pInfo
->hDisplayPage
,
845 DisplayOnInit(HWND hwnd
,
848 DISPLAY_DEVICEW displayDevice
;
852 SetWindowLongPtrW(hwnd
,
856 pInfo
->hDisplayPage
= hwnd
;
858 SetWindowPos(pInfo
->hDisplayPage
,
864 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
866 pInfo
->hRemote
= LoadImageW(hInst
,
867 MAKEINTRESOURCEW(IDI_REMOTE
),
874 SendDlgItemMessageW(pInfo
->hDisplayPage
,
877 (WPARAM
)pInfo
->hRemote
,
881 pInfo
->hColor
= LoadImageW(hInst
,
882 MAKEINTRESOURCEW(IDI_COLORS
),
889 SendDlgItemMessageW(pInfo
->hDisplayPage
,
892 (WPARAM
)pInfo
->hColor
,
896 pInfo
->hSpectrum
= LoadImageW(hInst
,
897 MAKEINTRESOURCEW(IDB_SPECT
),
902 if (pInfo
->hSpectrum
)
904 GetObjectW(pInfo
->hSpectrum
,
909 /* Get video cards list */
910 displayDevice
.cb
= (DWORD
)sizeof(DISPLAY_DEVICE
);
911 while (EnumDisplayDevicesW(NULL
, iDevNum
, &displayDevice
, 0x1))
913 if ((displayDevice
.StateFlags
& DISPLAY_DEVICE_PRIMARY_DEVICE
) != 0)
915 if (AddDisplayDevice(pInfo
, &displayDevice
))
923 FillResolutionsAndColors(pInfo
);
924 ReLoadDisplayPage(pInfo
);
930 DisplayDlgProc(HWND hDlg
,
935 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
941 DisplayOnInit(hDlg
, (PINFO
)lParam
);
946 LPDRAWITEMSTRUCT lpDrawItem
;
947 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
948 if(lpDrawItem
->CtlID
== IDC_COLORIMAGE
)
952 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
955 hSpecOld
= SelectObject(hdcMem
, pInfo
->hSpectrum
);
956 StretchBlt(lpDrawItem
->hDC
,
957 lpDrawItem
->rcItem
.left
,
958 lpDrawItem
->rcItem
.top
,
959 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
960 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
964 pInfo
->bitmap
.bmWidth
,
965 pInfo
->bitmap
.bmHeight
,
967 SelectObject(hdcMem
, hSpecOld
);
976 switch (LOWORD(wParam
))
986 INT newPosition
= (DWORD
)SendDlgItemMessageW(hDlg
, IDC_GEOSLIDER
, TBM_GETPOS
, 0, 0);
987 OnResolutionChanged(pInfo
, newPosition
);
992 OnResolutionChanged(pInfo
, HIWORD(wParam
));
1001 DestroyIcon(pInfo
->hRemote
);
1004 DestroyIcon(pInfo
->hColor
);
1006 if (pInfo
->hSpectrum
)
1007 DeleteObject(pInfo
->hSpectrum
);
1019 OnMainCreate(HWND hwnd
,
1020 PRDPSETTINGS pRdpSettings
)
1026 pInfo
= HeapAlloc(GetProcessHeap(),
1031 SetWindowLongPtrW(hwnd
,
1035 pInfo
->hSelf
= hwnd
;
1037 /* add main settings pointer */
1038 pInfo
->pRdpSettings
= pRdpSettings
;
1040 /* set the dialog icons */
1041 pInfo
->hMstscSm
= LoadImageW(hInst
,
1042 MAKEINTRESOURCEW(IDI_MSTSC
),
1047 if (pInfo
->hMstscSm
)
1052 (WPARAM
)pInfo
->hMstscSm
);
1054 pInfo
->hMstscLg
= LoadImageW(hInst
,
1055 MAKEINTRESOURCEW(IDI_MSTSC
),
1060 if (pInfo
->hMstscLg
)
1065 (WPARAM
)pInfo
->hMstscLg
);
1068 pInfo
->hHeader
= (HBITMAP
)LoadImageW(hInst
,
1069 MAKEINTRESOURCEW(IDB_HEADER
),
1076 GetObjectW(pInfo
->hHeader
,
1078 &pInfo
->headerbitmap
);
1081 /* setup the tabs */
1082 pInfo
->hTab
= GetDlgItem(hwnd
, IDC_TAB
);
1085 if (CreateDialogParamW(hInst
,
1086 MAKEINTRESOURCEW(IDD_GENERAL
),
1092 ZeroMemory(&item
, sizeof(TCITEM
));
1093 item
.mask
= TCIF_TEXT
;
1094 if (LoadStringW(hInst
, IDS_TAB_GENERAL
, str
, 256))
1096 item
.cchTextMax
= 256;
1097 (void)TabCtrl_InsertItem(pInfo
->hTab
, 0, &item
);
1100 if (CreateDialogParamW(hInst
,
1101 MAKEINTRESOURCEW(IDD_DISPLAY
),
1107 ZeroMemory(&item
, sizeof(TCITEM
));
1108 item
.mask
= TCIF_TEXT
;
1109 if (LoadStringW(hInst
, IDS_TAB_DISPLAY
, str
, 256))
1111 item
.cchTextMax
= 256;
1112 (void)TabCtrl_InsertItem(pInfo
->hTab
, 1, &item
);
1115 OnTabWndSelChange(pInfo
);
1122 static void Cleanup(PINFO pInfo
)
1126 if (pInfo
->hMstscSm
)
1127 DestroyIcon(pInfo
->hMstscSm
);
1128 if (pInfo
->hMstscLg
)
1129 DestroyIcon(pInfo
->hMstscLg
);
1131 DeleteObject(pInfo
->hHeader
);
1132 if (pInfo
->hSpectrum
)
1133 DeleteObject(pInfo
->hSpectrum
);
1135 DestroyIcon(pInfo
->hRemote
);
1137 DestroyIcon(pInfo
->hLogon
);
1139 DestroyIcon(pInfo
->hConn
);
1141 DestroyIcon(pInfo
->hColor
);
1142 HeapFree(GetProcessHeap(),
1148 static INT_PTR CALLBACK
1156 /* Get the window context */
1157 pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
1159 if (pInfo
== NULL
&& Message
!= WM_INITDIALOG
)
1161 goto HandleDefaultMessage
;
1167 OnMainCreate(hDlg
, (PRDPSETTINGS
)lParam
);
1172 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
1174 if (LOWORD(wParam
) == IDOK
)
1176 SaveAllSettings(pInfo
);
1177 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
1180 EndDialog(hDlg
, LOWORD(wParam
));
1190 //idctrl = (int)wParam;
1191 pnmh
= (LPNMHDR
)lParam
;
1192 if (//(pnmh->hwndFrom == pInfo->hSelf) &&
1193 (pnmh
->idFrom
== IDC_TAB
) &&
1194 (pnmh
->code
== TCN_SELCHANGE
))
1196 OnTabWndSelChange(pInfo
);
1207 hdc
= BeginPaint(hDlg
, &ps
);
1210 HDC hdcMem
= CreateCompatibleDC(hdc
);
1216 HFONT hFont
, hFontOld
;
1219 GetClientRect(pInfo
->hSelf
, &bmpRc
);
1221 hBmpOld
= SelectObject(hdcMem
, pInfo
->hHeader
);
1226 pInfo
->headerbitmap
.bmHeight
,
1230 pInfo
->headerbitmap
.bmWidth
,
1231 pInfo
->headerbitmap
.bmHeight
,
1234 SelectObject(hdcMem
, hBmpOld
);
1235 txtRc
.left
= bmpRc
.right
/ 4;
1237 txtRc
.right
= bmpRc
.right
* 3 / 4;
1238 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
/ 2;
1240 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1242 if (LoadStringW(hInst
,
1245 sizeof(szBuffer
) / sizeof(WCHAR
)))
1248 lf
.lfCharSet
= OEM_CHARSET
;
1249 lf
.lfQuality
= DEFAULT_QUALITY
;
1250 lf
.lfWeight
= FW_MEDIUM
;
1251 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1253 hFont
= CreateFontIndirectW(&lf
);
1256 hFontOld
= SelectObject(hdc
, hFont
);
1258 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1259 SetTextColor(hdc
, RGB(255,255,255));
1260 SetBkMode(hdc
, TRANSPARENT
);
1265 DT_BOTTOM
| DT_SINGLELINE
| DT_NOCLIP
);
1266 SelectObject(hdc
, hFontOld
);
1267 DeleteObject(hFont
);
1271 txtRc
.left
= bmpRc
.right
/ 4;
1272 txtRc
.top
= txtRc
.bottom
- 5;
1274 txtRc
.right
= bmpRc
.right
* 4 / 5;
1276 txtRc
.right
= bmpRc
.right
* 3 / 4;
1278 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
* 9 / 10;
1280 if (LoadStringW(hInst
,
1283 sizeof(szBuffer
) / sizeof(WCHAR
)))
1286 lf
.lfCharSet
= OEM_CHARSET
;
1287 lf
.lfQuality
= DEFAULT_QUALITY
;
1288 lf
.lfWeight
= FW_EXTRABOLD
;
1289 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1291 hFont
= CreateFontIndirectW(&lf
);
1294 hFontOld
= SelectObject(hdc
, hFont
);
1296 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1297 SetTextColor(hdc
, RGB(255,255,255));
1298 SetBkMode(hdc
, TRANSPARENT
);
1303 DT_TOP
| DT_SINGLELINE
);
1304 SelectObject(hdc
, hFontOld
);
1305 DeleteObject(hFont
);
1312 EndPaint(hDlg
, &ps
);
1325 HandleDefaultMessage
:
1335 OpenRDPConnectDialog(HINSTANCE hInstance
,
1336 PRDPSETTINGS pRdpSettings
)
1338 INITCOMMONCONTROLSEX iccx
;
1342 iccx
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1343 iccx
.dwICC
= ICC_TAB_CLASSES
;
1344 InitCommonControlsEx(&iccx
);
1346 return (DialogBoxParamW(hInst
,
1347 MAKEINTRESOURCEW(IDD_CONNECTDIALOG
),
1350 (LPARAM
)pRdpSettings
) == IDOK
);