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
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define MAX_KEY_NAME 255
27 static VOID
ReLoadGeneralPage(PINFO pInfo
);
28 static VOID
ReLoadDisplayPage(PINFO pInfo
);
32 DoOpenFile(PINFO pInfo
)
35 WCHAR szFileName
[MAX_PATH
] = L
"";
36 static WCHAR szFilter
[] = L
"Remote Desktop Files (*rdp)\0*.rdp\0";
38 ZeroMemory(&ofn
, sizeof(ofn
));
39 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
40 ofn
.hwndOwner
= pInfo
->hGeneralPage
;
41 ofn
.nMaxFile
= MAX_PATH
;
42 ofn
.nMaxFileTitle
= MAX_PATH
;
43 ofn
.lpstrDefExt
= L
"rdp";
44 ofn
.lpstrFilter
= szFilter
;
45 ofn
.lpstrFile
= szFileName
;
46 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
;
48 if (GetOpenFileNameW(&ofn
))
50 LoadRdpSettingsFromFile(pInfo
->pRdpSettings
, szFileName
);
51 ReLoadGeneralPage(pInfo
);
52 ReLoadDisplayPage(pInfo
);
61 WCHAR szFileName
[MAX_PATH
] = L
"";
62 static WCHAR szFilter
[] = L
"Remote Desktop Files (*rdp)\0*.rdp\0";
64 ZeroMemory(&ofn
, sizeof(ofn
));
65 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
66 ofn
.hwndOwner
= pInfo
->hGeneralPage
;
67 ofn
.nMaxFile
= MAX_PATH
;
68 ofn
.nMaxFileTitle
= MAX_PATH
;
69 ofn
.lpstrDefExt
= L
"rdp";
70 ofn
.lpstrFilter
= szFilter
;
71 ofn
.lpstrFile
= szFileName
;
72 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
;
74 if (GetSaveFileNameW(&ofn
))
76 SaveAllSettings(pInfo
);
77 SaveRdpSettingsToFile(szFileName
, pInfo
->pRdpSettings
);
83 OnTabWndSelChange(PINFO pInfo
)
85 switch (TabCtrl_GetCurSel(pInfo
->hTab
))
88 ShowWindow(pInfo
->hGeneralPage
, SW_SHOW
);
89 ShowWindow(pInfo
->hDisplayPage
, SW_HIDE
);
90 BringWindowToTop(pInfo
->hGeneralPage
);
93 ShowWindow(pInfo
->hGeneralPage
, SW_HIDE
);
94 ShowWindow(pInfo
->hDisplayPage
, SW_SHOW
);
95 BringWindowToTop(pInfo
->hDisplayPage
);
102 FillServerAddesssCombo(PINFO pInfo
)
105 WCHAR KeyName
[] = L
"Software\\Microsoft\\Terminal Server Client\\Default";
106 WCHAR Name
[MAX_KEY_NAME
];
107 LONG ret
= ERROR_SUCCESS
;
111 if (RegOpenKeyExW(HKEY_CURRENT_USER
,
115 &hKey
) == ERROR_SUCCESS
)
117 while (ret
== ERROR_SUCCESS
)
120 ret
= RegEnumValueW(hKey
,
128 if (ret
== ERROR_SUCCESS
)
131 if (RegQueryValueExW(hKey
,
136 &size
) == ERROR_SUCCESS
)
138 LPWSTR lpAddress
= HeapAlloc(GetProcessHeap(),
143 if (RegQueryValueExW(hKey
,
148 &size
) == ERROR_SUCCESS
)
150 SendDlgItemMessageW(pInfo
->hGeneralPage
,
157 HeapFree(GetProcessHeap(),
169 if (LoadStringW(hInst
,
172 sizeof(Name
) / sizeof(WCHAR
)))
174 SendDlgItemMessageW(pInfo
->hGeneralPage
,
184 ReLoadGeneralPage(PINFO pInfo
)
188 /* add file address */
189 lpText
= GetStringFromSettings(pInfo
->pRdpSettings
,
193 SetDlgItemTextW(pInfo
->hGeneralPage
,
201 GeneralOnInit(HWND hwnd
,
204 SetWindowLongPtrW(hwnd
,
208 pInfo
->hGeneralPage
= hwnd
;
210 SetWindowPos(pInfo
->hGeneralPage
,
216 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
218 pInfo
->hLogon
= LoadImageW(hInst
,
219 MAKEINTRESOURCEW(IDI_LOGON
),
226 SendDlgItemMessageW(pInfo
->hGeneralPage
,
229 (WPARAM
)pInfo
->hLogon
,
233 pInfo
->hConn
= LoadImageW(hInst
,
234 MAKEINTRESOURCEW(IDI_CONN
),
241 SendDlgItemMessageW(pInfo
->hGeneralPage
,
244 (WPARAM
)pInfo
->hConn
,
248 FillServerAddesssCombo(pInfo
);
249 ReLoadGeneralPage(pInfo
);
254 GeneralDlgProc(HWND hDlg
,
259 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
265 GeneralOnInit(hDlg
, (PINFO
)lParam
);
270 switch(LOWORD(wParam
))
272 case IDC_SERVERCOMBO
:
273 if (HIWORD(wParam
) == CBN_SELCHANGE
)
277 cur
= SendDlgItemMessageW(hDlg
,
284 last
= SendDlgItemMessageW(hDlg
,
290 MessageBoxW(hDlg
, L
"SMB is not yet supported", L
"RDP error", MB_ICONERROR
);
295 SaveAllSettings(pInfo
);
296 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
314 DestroyIcon(pInfo
->hLogon
);
317 DestroyIcon(pInfo
->hConn
);
327 static PSETTINGS_ENTRY
328 GetPossibleSettings(IN LPCWSTR lpDeviceName
,
329 OUT DWORD
* pSettingsCount
,
330 OUT PSETTINGS_ENTRY
* CurrentSettings
)
333 DWORD NbSettings
= 0;
336 PSETTINGS_ENTRY Settings
= NULL
;
338 PSETTINGS_ENTRY Current
;
339 DWORD bpp
, xres
, yres
, checkbpp
;
341 /* Get current settings */
342 *CurrentSettings
= NULL
;
343 hDC
= CreateICW(NULL
, lpDeviceName
, NULL
, NULL
);
344 bpp
= GetDeviceCaps(hDC
, PLANES
);
345 bpp
*= GetDeviceCaps(hDC
, BITSPIXEL
);
346 xres
= GetDeviceCaps(hDC
, HORZRES
);
347 yres
= GetDeviceCaps(hDC
, VERTRES
);
350 /* List all settings */
351 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
352 devmode
.dmDriverExtra
= 0;
354 if (!EnumDisplaySettingsExW(lpDeviceName
, ENUM_CURRENT_SETTINGS
, &devmode
, dwFlags
))
357 while (EnumDisplaySettingsExW(lpDeviceName
, iMode
, &devmode
, dwFlags
))
359 if (devmode
.dmBitsPerPel
==8 ||
360 devmode
.dmBitsPerPel
==16 ||
361 devmode
.dmBitsPerPel
==24 ||
362 devmode
.dmBitsPerPel
==32)
369 if (devmode
.dmPelsWidth
< 640 ||
370 devmode
.dmPelsHeight
< 480 || checkbpp
== 0)
376 Current
= HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY
));
379 /* Sort resolutions by increasing height, and BPP */
380 PSETTINGS_ENTRY Previous
= NULL
;
381 PSETTINGS_ENTRY Next
= Settings
;
382 Current
->dmPelsWidth
= devmode
.dmPelsWidth
;
383 Current
->dmPelsHeight
= devmode
.dmPelsHeight
;
384 Current
->dmBitsPerPel
= devmode
.dmBitsPerPel
;
385 while (Next
!= NULL
&&
386 (Next
->dmPelsWidth
< Current
->dmPelsWidth
||
387 (Next
->dmPelsWidth
== Current
->dmPelsWidth
&& Next
->dmPelsHeight
< Current
->dmPelsHeight
) ||
388 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&&
389 Next
->dmPelsWidth
== Current
->dmPelsWidth
&&
390 Next
->dmBitsPerPel
< Current
->dmBitsPerPel
)))
395 Current
->Blink
= Previous
;
396 Current
->Flink
= Next
;
397 if (Previous
== NULL
)
400 Previous
->Flink
= Current
;
402 Next
->Blink
= Current
;
403 if (devmode
.dmPelsWidth
== xres
&& devmode
.dmPelsHeight
== yres
&& devmode
.dmBitsPerPel
== bpp
)
405 *CurrentSettings
= Current
;
412 *pSettingsCount
= NbSettings
;
418 AddDisplayDevice(PINFO pInfo
, PDISPLAY_DEVICEW DisplayDevice
)
420 PDISPLAY_DEVICE_ENTRY newEntry
= NULL
;
421 LPWSTR description
= NULL
;
425 DWORD descriptionSize
, nameSize
, keySize
, devidSize
;
426 PSETTINGS_ENTRY Current
;
427 DWORD ResolutionsCount
= 1;
430 newEntry
= HeapAlloc(GetProcessHeap(),
432 sizeof(DISPLAY_DEVICE_ENTRY
));
433 if (!newEntry
) goto ByeBye
;
434 ZeroMemory(newEntry
, sizeof(DISPLAY_DEVICE_ENTRY
));
436 newEntry
->Settings
= GetPossibleSettings(DisplayDevice
->DeviceName
,
437 &newEntry
->SettingsCount
,
438 &newEntry
->CurrentSettings
);
439 if (!newEntry
->Settings
) goto ByeBye
;
441 newEntry
->InitialSettings
.dmPelsWidth
= newEntry
->CurrentSettings
->dmPelsWidth
;
442 newEntry
->InitialSettings
.dmPelsHeight
= newEntry
->CurrentSettings
->dmPelsHeight
;
443 newEntry
->InitialSettings
.dmBitsPerPel
= newEntry
->CurrentSettings
->dmBitsPerPel
;
445 /* Count different resolutions */
446 for (Current
= newEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
448 if (Current
->Flink
!= NULL
&&
449 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
450 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
)))
456 newEntry
->Resolutions
= HeapAlloc(GetProcessHeap(),
458 ResolutionsCount
* sizeof(RESOLUTION_INFO
));
459 if (!newEntry
->Resolutions
) goto ByeBye
;
461 newEntry
->ResolutionsCount
= ResolutionsCount
;
463 /* Fill resolutions infos */
464 for (Current
= newEntry
->Settings
, i
= 0; Current
!= NULL
; Current
= Current
->Flink
)
466 if (Current
->Flink
== NULL
||
467 (Current
->Flink
!= NULL
&&
468 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
469 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
))))
471 newEntry
->Resolutions
[i
].dmPelsWidth
= Current
->dmPelsWidth
;
472 newEntry
->Resolutions
[i
].dmPelsHeight
= Current
->dmPelsHeight
;
476 descriptionSize
= (wcslen(DisplayDevice
->DeviceString
) + 1) * sizeof(WCHAR
);
477 description
= HeapAlloc(GetProcessHeap(), 0, descriptionSize
);
478 if (!description
) goto ByeBye
;
480 nameSize
= (wcslen(DisplayDevice
->DeviceName
) + 1) * sizeof(WCHAR
);
481 name
= HeapAlloc(GetProcessHeap(), 0, nameSize
);
482 if (!name
) goto ByeBye
;
484 keySize
= (wcslen(DisplayDevice
->DeviceKey
) + 1) * sizeof(WCHAR
);
485 key
= HeapAlloc(GetProcessHeap(), 0, keySize
);
486 if (!key
) goto ByeBye
;
488 devidSize
= (wcslen(DisplayDevice
->DeviceID
) + 1) * sizeof(WCHAR
);
489 devid
= HeapAlloc(GetProcessHeap(), 0, devidSize
);
490 if (!devid
) goto ByeBye
;
492 memcpy(description
, DisplayDevice
->DeviceString
, descriptionSize
);
493 memcpy(name
, DisplayDevice
->DeviceName
, nameSize
);
494 memcpy(key
, DisplayDevice
->DeviceKey
, keySize
);
495 memcpy(devid
, DisplayDevice
->DeviceID
, devidSize
);
496 newEntry
->DeviceDescription
= description
;
497 newEntry
->DeviceName
= name
;
498 newEntry
->DeviceKey
= key
;
499 newEntry
->DeviceID
= devid
;
500 newEntry
->DeviceStateFlags
= DisplayDevice
->StateFlags
;
501 newEntry
->Flink
= pInfo
->DisplayDeviceList
;
502 pInfo
->DisplayDeviceList
= newEntry
;
506 if (newEntry
!= NULL
)
508 if (newEntry
->Settings
!= NULL
)
510 Current
= newEntry
->Settings
;
511 while (Current
!= NULL
)
513 PSETTINGS_ENTRY Next
= Current
->Flink
;
514 HeapFree(GetProcessHeap(), 0, Current
);
518 if (newEntry
->Resolutions
!= NULL
)
519 HeapFree(GetProcessHeap(), 0, newEntry
->Resolutions
);
520 HeapFree(GetProcessHeap(), 0, newEntry
);
522 if (description
!= NULL
)
523 HeapFree(GetProcessHeap(), 0, description
);
525 HeapFree(GetProcessHeap(), 0, name
);
527 HeapFree(GetProcessHeap(), 0, key
);
529 HeapFree(GetProcessHeap(), 0, devid
);
535 OnResolutionChanged(PINFO pInfo
, INT position
)
540 MaxSlider
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
546 if (position
== MaxSlider
)
551 sizeof(Buffer
) / sizeof(WCHAR
));
557 if (LoadStringW(hInst
,
560 sizeof(Pixel
) / sizeof(WCHAR
)))
565 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
566 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
571 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
572 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
578 SendDlgItemMessageW(pInfo
->hDisplayPage
,
579 IDC_SETTINGS_RESOLUTION_TEXT
,
587 FillResolutionsAndColors(PINFO pInfo
)
589 PSETTINGS_ENTRY Current
;
594 pInfo
->CurrentDisplayDevice
= pInfo
->DisplayDeviceList
; /* Update global variable */
597 SendDlgItemMessageW(pInfo
->hDisplayPage
,
602 for (Current
= pInfo
->DisplayDeviceList
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
604 if (Current
->dmBitsPerPel
> MaxBpp
)
605 MaxBpp
= Current
->dmBitsPerPel
;
610 case 24: num
= 4; break;
611 case 16: num
= 3; break;
612 case 8: num
= 1; break;
613 default: num
= 0; break;
616 types
[0] = IDS_256COLORS
;
617 types
[1] = IDS_HIGHCOLOR15
;
618 types
[2] = IDS_HIGHCOLOR16
;
619 types
[3] = IDS_HIGHCOLOR24
;
621 /* Fill color depths combo box */
622 SendDlgItemMessageW(pInfo
->hDisplayPage
,
628 for (i
= 0, Current
= pInfo
->DisplayDeviceList
->Settings
;
629 i
<= num
&& Current
!= NULL
;
630 i
++, Current
= Current
->Flink
)
633 if (LoadStringW(hInst
,
636 sizeof(Buffer
) / sizeof(WCHAR
)))
638 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
643 if (index
== (DWORD
)CB_ERR
)
645 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
650 SendDlgItemMessageW(pInfo
->hDisplayPage
,
659 /* Fill resolutions slider */
660 SendDlgItemMessageW(pInfo
->hDisplayPage
,
665 SendDlgItemMessageW(pInfo
->hDisplayPage
,
669 MAKELONG(0, pInfo
->DisplayDeviceList
->ResolutionsCount
)); //extra 1 for full screen
676 ReLoadDisplayPage(PINFO pInfo
)
679 INT width
, height
, pos
= 0;
683 /* set trackbar position */
684 width
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopwidth");
685 height
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopheight");
687 if (width
!= -1 && height
!= -1)
689 for (index
= 0; index
< pInfo
->CurrentDisplayDevice
->ResolutionsCount
; index
++)
691 if (pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsWidth
== width
&&
692 pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsHeight
== height
)
700 /* set slider position */
701 SendDlgItemMessageW(pInfo
->hDisplayPage
,
707 OnResolutionChanged(pInfo
, pos
);
710 /* set color combo */
711 bpp
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"session bpp");
713 num
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
718 for (i
= 0; i
< num
; i
++)
720 INT data
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
727 SendDlgItemMessageW(pInfo
->hDisplayPage
,
739 SendDlgItemMessageW(pInfo
->hDisplayPage
,
749 DisplayOnInit(HWND hwnd
,
752 DISPLAY_DEVICEW displayDevice
;
756 SetWindowLongPtrW(hwnd
,
760 pInfo
->hDisplayPage
= hwnd
;
762 SetWindowPos(pInfo
->hDisplayPage
,
768 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
770 pInfo
->hRemote
= LoadImageW(hInst
,
771 MAKEINTRESOURCEW(IDI_REMOTE
),
778 SendDlgItemMessageW(pInfo
->hDisplayPage
,
781 (WPARAM
)pInfo
->hRemote
,
785 pInfo
->hColor
= LoadImageW(hInst
,
786 MAKEINTRESOURCEW(IDI_COLORS
),
793 SendDlgItemMessageW(pInfo
->hDisplayPage
,
796 (WPARAM
)pInfo
->hColor
,
800 pInfo
->hSpectrum
= LoadImageW(hInst
,
801 MAKEINTRESOURCEW(IDB_SPECT
),
806 if (pInfo
->hSpectrum
)
808 GetObjectW(pInfo
->hSpectrum
,
813 /* Get video cards list */
814 displayDevice
.cb
= (DWORD
)sizeof(DISPLAY_DEVICE
);
815 while (EnumDisplayDevicesW(NULL
, iDevNum
, &displayDevice
, 0x1))
817 if ((displayDevice
.StateFlags
& DISPLAY_DEVICE_PRIMARY_DEVICE
) != 0)
819 if (AddDisplayDevice(pInfo
, &displayDevice
))
827 FillResolutionsAndColors(pInfo
);
828 ReLoadDisplayPage(pInfo
);
834 DisplayDlgProc(HWND hDlg
,
839 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
845 DisplayOnInit(hDlg
, (PINFO
)lParam
);
850 LPDRAWITEMSTRUCT lpDrawItem
;
851 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
852 if(lpDrawItem
->CtlID
== IDC_COLORIMAGE
)
856 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
859 hSpecOld
= SelectObject(hdcMem
, pInfo
->hSpectrum
);
860 StretchBlt(lpDrawItem
->hDC
,
861 lpDrawItem
->rcItem
.left
,
862 lpDrawItem
->rcItem
.top
,
863 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
864 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
868 pInfo
->bitmap
.bmWidth
,
869 pInfo
->bitmap
.bmHeight
,
871 SelectObject(hdcMem
, hSpecOld
);
880 switch (LOWORD(wParam
))
890 INT newPosition
= (DWORD
)SendDlgItemMessageW(hDlg
, IDC_GEOSLIDER
, TBM_GETPOS
, 0, 0);
891 OnResolutionChanged(pInfo
, newPosition
);
896 OnResolutionChanged(pInfo
, HIWORD(wParam
));
905 DestroyIcon(pInfo
->hRemote
);
908 DestroyIcon(pInfo
->hColor
);
910 if (pInfo
->hSpectrum
)
911 DeleteObject(pInfo
->hSpectrum
);
923 OnMainCreate(HWND hwnd
,
924 PRDPSETTINGS pRdpSettings
)
930 pInfo
= HeapAlloc(GetProcessHeap(),
935 SetWindowLongPtrW(hwnd
,
941 /* add main settings pointer */
942 pInfo
->pRdpSettings
= pRdpSettings
;
944 /* set the dialog icons */
945 pInfo
->hMstscSm
= LoadImageW(hInst
,
946 MAKEINTRESOURCEW(IDI_MSTSC
),
956 (WPARAM
)pInfo
->hMstscSm
);
958 pInfo
->hMstscLg
= LoadImageW(hInst
,
959 MAKEINTRESOURCEW(IDI_MSTSC
),
969 (WPARAM
)pInfo
->hMstscLg
);
972 pInfo
->hHeader
= (HBITMAP
)LoadImageW(hInst
,
973 MAKEINTRESOURCEW(IDB_HEADER
),
980 GetObjectW(pInfo
->hHeader
,
982 &pInfo
->headerbitmap
);
986 pInfo
->hTab
= GetDlgItem(hwnd
, IDC_TAB
);
989 if (CreateDialogParamW(hInst
,
990 MAKEINTRESOURCEW(IDD_GENERAL
),
992 (DLGPROC
)GeneralDlgProc
,
996 ZeroMemory(&item
, sizeof(TCITEM
));
997 item
.mask
= TCIF_TEXT
;
998 if (LoadStringW(hInst
, IDS_TAB_GENERAL
, str
, 256))
1000 item
.cchTextMax
= 256;
1001 (void)TabCtrl_InsertItem(pInfo
->hTab
, 0, &item
);
1004 if (CreateDialogParamW(hInst
,
1005 MAKEINTRESOURCEW(IDD_DISPLAY
),
1007 (DLGPROC
)DisplayDlgProc
,
1011 ZeroMemory(&item
, sizeof(TCITEM
));
1012 item
.mask
= TCIF_TEXT
;
1013 if (LoadStringW(hInst
, IDS_TAB_DISPLAY
, str
, 256))
1015 item
.cchTextMax
= 256;
1016 (void)TabCtrl_InsertItem(pInfo
->hTab
, 1, &item
);
1019 OnTabWndSelChange(pInfo
);
1026 static void Cleanup(PINFO pInfo
)
1030 if (pInfo
->hMstscSm
)
1031 DestroyIcon(pInfo
->hMstscSm
);
1032 if (pInfo
->hMstscLg
)
1033 DestroyIcon(pInfo
->hMstscLg
);
1035 DeleteObject(pInfo
->hHeader
);
1036 if (pInfo
->hSpectrum
)
1037 DeleteObject(pInfo
->hSpectrum
);
1039 DestroyIcon(pInfo
->hRemote
);
1041 DestroyIcon(pInfo
->hLogon
);
1043 DestroyIcon(pInfo
->hConn
);
1045 DestroyIcon(pInfo
->hColor
);
1046 HeapFree(GetProcessHeap(),
1052 static BOOL CALLBACK
1060 /* Get the window context */
1061 pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
1063 if (pInfo
== NULL
&& Message
!= WM_INITDIALOG
)
1065 goto HandleDefaultMessage
;
1071 OnMainCreate(hDlg
, (PRDPSETTINGS
)lParam
);
1076 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
1078 if (LOWORD(wParam
) == IDOK
)
1080 SaveAllSettings(pInfo
);
1081 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
1084 EndDialog(hDlg
, LOWORD(wParam
));
1094 idctrl
= (int)wParam
;
1095 pnmh
= (LPNMHDR
)lParam
;
1096 if (//(pnmh->hwndFrom == pInfo->hSelf) &&
1097 (pnmh
->idFrom
== IDC_TAB
) &&
1098 (pnmh
->code
== TCN_SELCHANGE
))
1100 OnTabWndSelChange(pInfo
);
1111 hdc
= BeginPaint(hDlg
, &ps
);
1114 HDC hdcMem
= CreateCompatibleDC(hdc
);
1120 HFONT hFont
, hFontOld
;
1123 GetClientRect(pInfo
->hSelf
, &bmpRc
);
1125 hBmpOld
= SelectObject(hdcMem
, pInfo
->hHeader
);
1130 pInfo
->headerbitmap
.bmHeight
,
1134 pInfo
->headerbitmap
.bmWidth
,
1135 pInfo
->headerbitmap
.bmHeight
,
1138 SelectObject(hdcMem
, hBmpOld
);
1139 txtRc
.left
= bmpRc
.right
* 0.25;
1141 txtRc
.right
= bmpRc
.right
* 0.75;
1142 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
* 0.5;
1144 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1146 if (LoadStringW(hInst
,
1149 sizeof(szBuffer
) / sizeof(WCHAR
)))
1152 lf
.lfCharSet
= OEM_CHARSET
;
1153 lf
.lfQuality
= DEFAULT_QUALITY
;
1154 lf
.lfWeight
= FW_MEDIUM
;
1155 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1157 hFont
= CreateFontIndirectW(&lf
);
1160 hFontOld
= SelectObject(hdc
, hFont
);
1162 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1163 SetTextColor(hdc
, RGB(255,255,255));
1164 SetBkMode(hdc
, TRANSPARENT
);
1169 DT_BOTTOM
| DT_SINGLELINE
| DT_NOCLIP
);
1170 SelectObject(hdc
, hFontOld
);
1171 DeleteObject(hFont
);
1175 txtRc
.left
= bmpRc
.right
* 0.25;
1176 txtRc
.top
= txtRc
.bottom
- 5;
1177 txtRc
.right
= bmpRc
.right
* 0.75;
1178 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
* 0.9;
1180 if (LoadStringW(hInst
,
1183 sizeof(szBuffer
) / sizeof(WCHAR
)))
1186 lf
.lfCharSet
= OEM_CHARSET
;
1187 lf
.lfQuality
= DEFAULT_QUALITY
;
1188 lf
.lfWeight
= FW_EXTRABOLD
;
1189 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1191 hFont
= CreateFontIndirectW(&lf
);
1194 hFontOld
= SelectObject(hdc
, hFont
);
1196 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1197 SetTextColor(hdc
, RGB(255,255,255));
1198 SetBkMode(hdc
, TRANSPARENT
);
1203 DT_TOP
| DT_SINGLELINE
);
1204 SelectObject(hdc
, hFontOld
);
1205 DeleteObject(hFont
);
1212 EndPaint(hDlg
, &ps
);
1225 HandleDefaultMessage
:
1235 OpenRDPConnectDialog(HINSTANCE hInstance
,
1236 PRDPSETTINGS pRdpSettings
)
1238 INITCOMMONCONTROLSEX iccx
;
1242 iccx
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1243 iccx
.dwICC
= ICC_TAB_CLASSES
;
1244 InitCommonControlsEx(&iccx
);
1246 return (DialogBoxParamW(hInst
,
1247 MAKEINTRESOURCEW(IDD_CONNECTDIALOG
),
1250 (LPARAM
)pRdpSettings
) == IDOK
);