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
);
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(PINFO pInfo
)
203 SetWindowPos(pInfo
->hGeneralPage
,
209 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
211 pInfo
->hLogon
= LoadImageW(hInst
,
212 MAKEINTRESOURCEW(IDI_LOGON
),
219 SendDlgItemMessageW(pInfo
->hGeneralPage
,
222 (WPARAM
)pInfo
->hLogon
,
226 pInfo
->hConn
= LoadImageW(hInst
,
227 MAKEINTRESOURCEW(IDI_CONN
),
234 SendDlgItemMessageW(pInfo
->hGeneralPage
,
237 (WPARAM
)pInfo
->hConn
,
241 FillServerAddesssCombo(pInfo
);
242 ReLoadGeneralPage(pInfo
);
247 GeneralDlgProc(HWND hDlg
,
252 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(GetParent(hDlg
),
258 pInfo
->hGeneralPage
= hDlg
;
259 GeneralOnInit(pInfo
);
264 switch(LOWORD(wParam
))
266 case IDC_SERVERCOMBO
:
267 if (HIWORD(wParam
) == CBN_SELCHANGE
)
271 cur
= SendDlgItemMessageW(hDlg
,
278 last
= SendDlgItemMessageW(hDlg
,
284 MessageBoxW(hDlg
, L
"SMB is not yet supported", L
"RDP error", MB_ICONERROR
);
289 SaveAllSettings(pInfo
);
290 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
308 DestroyIcon(pInfo
->hLogon
);
311 DestroyIcon(pInfo
->hConn
);
321 static PSETTINGS_ENTRY
322 GetPossibleSettings(IN LPCWSTR lpDeviceName
,
323 OUT DWORD
* pSettingsCount
,
324 OUT PSETTINGS_ENTRY
* CurrentSettings
)
327 DWORD NbSettings
= 0;
330 PSETTINGS_ENTRY Settings
= NULL
;
332 PSETTINGS_ENTRY Current
;
333 DWORD bpp
, xres
, yres
, checkbpp
;
335 /* Get current settings */
336 *CurrentSettings
= NULL
;
337 hDC
= CreateICW(NULL
, lpDeviceName
, NULL
, NULL
);
338 bpp
= GetDeviceCaps(hDC
, PLANES
);
339 bpp
*= GetDeviceCaps(hDC
, BITSPIXEL
);
340 xres
= GetDeviceCaps(hDC
, HORZRES
);
341 yres
= GetDeviceCaps(hDC
, VERTRES
);
344 /* List all settings */
345 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
346 devmode
.dmDriverExtra
= 0;
348 if (!EnumDisplaySettingsExW(lpDeviceName
, ENUM_CURRENT_SETTINGS
, &devmode
, dwFlags
))
351 while (EnumDisplaySettingsExW(lpDeviceName
, iMode
, &devmode
, dwFlags
))
353 if (devmode
.dmBitsPerPel
==8 ||
354 devmode
.dmBitsPerPel
==16 ||
355 devmode
.dmBitsPerPel
==24 ||
356 devmode
.dmBitsPerPel
==32)
363 if (devmode
.dmPelsWidth
< 640 ||
364 devmode
.dmPelsHeight
< 480 || checkbpp
== 0)
370 Current
= HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY
));
373 /* Sort resolutions by increasing height, and BPP */
374 PSETTINGS_ENTRY Previous
= NULL
;
375 PSETTINGS_ENTRY Next
= Settings
;
376 Current
->dmPelsWidth
= devmode
.dmPelsWidth
;
377 Current
->dmPelsHeight
= devmode
.dmPelsHeight
;
378 Current
->dmBitsPerPel
= devmode
.dmBitsPerPel
;
379 while (Next
!= NULL
&&
380 (Next
->dmPelsWidth
< Current
->dmPelsWidth
||
381 (Next
->dmPelsWidth
== Current
->dmPelsWidth
&& Next
->dmPelsHeight
< Current
->dmPelsHeight
) ||
382 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&&
383 Next
->dmPelsWidth
== Current
->dmPelsWidth
&&
384 Next
->dmBitsPerPel
< Current
->dmBitsPerPel
)))
389 Current
->Blink
= Previous
;
390 Current
->Flink
= Next
;
391 if (Previous
== NULL
)
394 Previous
->Flink
= Current
;
396 Next
->Blink
= Current
;
397 if (devmode
.dmPelsWidth
== xres
&& devmode
.dmPelsHeight
== yres
&& devmode
.dmBitsPerPel
== bpp
)
399 *CurrentSettings
= Current
;
406 *pSettingsCount
= NbSettings
;
412 AddDisplayDevice(PINFO pInfo
, PDISPLAY_DEVICEW DisplayDevice
)
414 PDISPLAY_DEVICE_ENTRY newEntry
= NULL
;
415 LPWSTR description
= NULL
;
419 DWORD descriptionSize
, nameSize
, keySize
, devidSize
;
420 PSETTINGS_ENTRY Current
;
421 DWORD ResolutionsCount
= 1;
424 newEntry
= HeapAlloc(GetProcessHeap(),
426 sizeof(DISPLAY_DEVICE_ENTRY
));
427 if (!newEntry
) goto ByeBye
;
428 ZeroMemory(newEntry
, sizeof(DISPLAY_DEVICE_ENTRY
));
430 newEntry
->Settings
= GetPossibleSettings(DisplayDevice
->DeviceName
,
431 &newEntry
->SettingsCount
,
432 &newEntry
->CurrentSettings
);
433 if (!newEntry
->Settings
) goto ByeBye
;
435 newEntry
->InitialSettings
.dmPelsWidth
= newEntry
->CurrentSettings
->dmPelsWidth
;
436 newEntry
->InitialSettings
.dmPelsHeight
= newEntry
->CurrentSettings
->dmPelsHeight
;
437 newEntry
->InitialSettings
.dmBitsPerPel
= newEntry
->CurrentSettings
->dmBitsPerPel
;
439 /* Count different resolutions */
440 for (Current
= newEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
442 if (Current
->Flink
!= NULL
&&
443 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
444 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
)))
450 newEntry
->Resolutions
= HeapAlloc(GetProcessHeap(),
452 ResolutionsCount
* sizeof(RESOLUTION_INFO
));
453 if (!newEntry
->Resolutions
) goto ByeBye
;
455 newEntry
->ResolutionsCount
= ResolutionsCount
;
457 /* Fill resolutions infos */
458 for (Current
= newEntry
->Settings
, i
= 0; Current
!= NULL
; Current
= Current
->Flink
)
460 if (Current
->Flink
== NULL
||
461 (Current
->Flink
!= NULL
&&
462 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) &&
463 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
))))
465 newEntry
->Resolutions
[i
].dmPelsWidth
= Current
->dmPelsWidth
;
466 newEntry
->Resolutions
[i
].dmPelsHeight
= Current
->dmPelsHeight
;
470 descriptionSize
= (wcslen(DisplayDevice
->DeviceString
) + 1) * sizeof(WCHAR
);
471 description
= HeapAlloc(GetProcessHeap(), 0, descriptionSize
);
472 if (!description
) goto ByeBye
;
474 nameSize
= (wcslen(DisplayDevice
->DeviceName
) + 1) * sizeof(WCHAR
);
475 name
= HeapAlloc(GetProcessHeap(), 0, nameSize
);
476 if (!name
) goto ByeBye
;
478 keySize
= (wcslen(DisplayDevice
->DeviceKey
) + 1) * sizeof(WCHAR
);
479 key
= HeapAlloc(GetProcessHeap(), 0, keySize
);
480 if (!key
) goto ByeBye
;
482 devidSize
= (wcslen(DisplayDevice
->DeviceID
) + 1) * sizeof(WCHAR
);
483 devid
= HeapAlloc(GetProcessHeap(), 0, devidSize
);
484 if (!devid
) goto ByeBye
;
486 memcpy(description
, DisplayDevice
->DeviceString
, descriptionSize
);
487 memcpy(name
, DisplayDevice
->DeviceName
, nameSize
);
488 memcpy(key
, DisplayDevice
->DeviceKey
, keySize
);
489 memcpy(devid
, DisplayDevice
->DeviceID
, devidSize
);
490 newEntry
->DeviceDescription
= description
;
491 newEntry
->DeviceName
= name
;
492 newEntry
->DeviceKey
= key
;
493 newEntry
->DeviceID
= devid
;
494 newEntry
->DeviceStateFlags
= DisplayDevice
->StateFlags
;
495 newEntry
->Flink
= pInfo
->DisplayDeviceList
;
496 pInfo
->DisplayDeviceList
= newEntry
;
500 if (newEntry
!= NULL
)
502 if (newEntry
->Settings
!= NULL
)
504 Current
= newEntry
->Settings
;
505 while (Current
!= NULL
)
507 PSETTINGS_ENTRY Next
= Current
->Flink
;
508 HeapFree(GetProcessHeap(), 0, Current
);
512 if (newEntry
->Resolutions
!= NULL
)
513 HeapFree(GetProcessHeap(), 0, newEntry
->Resolutions
);
514 HeapFree(GetProcessHeap(), 0, newEntry
);
516 if (description
!= NULL
)
517 HeapFree(GetProcessHeap(), 0, description
);
519 HeapFree(GetProcessHeap(), 0, name
);
521 HeapFree(GetProcessHeap(), 0, key
);
523 HeapFree(GetProcessHeap(), 0, devid
);
529 OnResolutionChanged(PINFO pInfo
, INT position
)
534 MaxSlider
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
540 if (position
== MaxSlider
)
545 sizeof(Buffer
) / sizeof(WCHAR
));
551 if (LoadStringW(hInst
,
554 sizeof(Pixel
) / sizeof(WCHAR
)))
559 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
560 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
565 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsWidth
,
566 pInfo
->DisplayDeviceList
->Resolutions
[position
].dmPelsHeight
,
572 SendDlgItemMessageW(pInfo
->hDisplayPage
,
573 IDC_SETTINGS_RESOLUTION_TEXT
,
581 FillResolutionsAndColors(PINFO pInfo
)
583 PSETTINGS_ENTRY Current
;
588 pInfo
->CurrentDisplayDevice
= pInfo
->DisplayDeviceList
; /* Update global variable */
591 SendDlgItemMessageW(pInfo
->hDisplayPage
,
596 for (Current
= pInfo
->DisplayDeviceList
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
598 if (Current
->dmBitsPerPel
> MaxBpp
)
599 MaxBpp
= Current
->dmBitsPerPel
;
604 case 24: num
= 4; break;
605 case 16: num
= 3; break;
606 case 8: num
= 1; break;
607 default: num
= 0; break;
610 types
[0] = IDS_256COLORS
;
611 types
[1] = IDS_HIGHCOLOR15
;
612 types
[2] = IDS_HIGHCOLOR16
;
613 types
[3] = IDS_HIGHCOLOR24
;
615 /* Fill color depths combo box */
616 SendDlgItemMessageW(pInfo
->hDisplayPage
,
622 for (i
= 0, Current
= pInfo
->DisplayDeviceList
->Settings
;
623 i
<= num
&& Current
!= NULL
;
624 i
++, Current
= Current
->Flink
)
627 if (LoadStringW(hInst
,
630 sizeof(Buffer
) / sizeof(WCHAR
)))
632 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
637 if (index
== (DWORD
)CB_ERR
)
639 index
= (DWORD
)SendDlgItemMessageW(pInfo
->hDisplayPage
,
644 SendDlgItemMessageW(pInfo
->hDisplayPage
,
653 /* Fill resolutions slider */
654 SendDlgItemMessageW(pInfo
->hDisplayPage
,
659 SendDlgItemMessageW(pInfo
->hDisplayPage
,
663 MAKELONG(0, pInfo
->DisplayDeviceList
->ResolutionsCount
)); //extra 1 for full screen
670 ReLoadDisplayPage(PINFO pInfo
)
673 INT width
, height
, pos
= 0;
677 /* set trackbar position */
678 width
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopwidth");
679 height
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"desktopheight");
681 if (width
!= -1 && height
!= -1)
683 for (index
= 0; index
< pInfo
->CurrentDisplayDevice
->ResolutionsCount
; index
++)
685 if (pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsWidth
== width
&&
686 pInfo
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsHeight
== height
)
694 /* set slider position */
695 SendDlgItemMessageW(pInfo
->hDisplayPage
,
701 OnResolutionChanged(pInfo
, pos
);
704 /* set color combo */
705 bpp
= GetIntegerFromSettings(pInfo
->pRdpSettings
, L
"session bpp");
707 num
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
712 for (i
= 0; i
< num
; i
++)
714 INT data
= SendDlgItemMessageW(pInfo
->hDisplayPage
,
721 SendDlgItemMessageW(pInfo
->hDisplayPage
,
733 SendDlgItemMessageW(pInfo
->hDisplayPage
,
743 DisplayOnInit(PINFO pInfo
)
745 DISPLAY_DEVICEW displayDevice
;
749 SetWindowPos(pInfo
->hDisplayPage
,
755 SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
757 pInfo
->hRemote
= LoadImageW(hInst
,
758 MAKEINTRESOURCEW(IDI_REMOTE
),
765 SendDlgItemMessageW(pInfo
->hDisplayPage
,
768 (WPARAM
)pInfo
->hRemote
,
772 pInfo
->hColor
= LoadImageW(hInst
,
773 MAKEINTRESOURCEW(IDI_COLORS
),
780 SendDlgItemMessageW(pInfo
->hDisplayPage
,
783 (WPARAM
)pInfo
->hColor
,
787 pInfo
->hSpectrum
= LoadImageW(hInst
,
788 MAKEINTRESOURCEW(IDB_SPECT
),
793 if (pInfo
->hSpectrum
)
795 GetObjectW(pInfo
->hSpectrum
,
800 /* Get video cards list */
801 displayDevice
.cb
= (DWORD
)sizeof(DISPLAY_DEVICE
);
802 while (EnumDisplayDevicesW(NULL
, iDevNum
, &displayDevice
, 0x1))
804 if ((displayDevice
.StateFlags
& DISPLAY_DEVICE_PRIMARY_DEVICE
) != 0)
806 if (AddDisplayDevice(pInfo
, &displayDevice
))
814 FillResolutionsAndColors(pInfo
);
815 ReLoadDisplayPage(pInfo
);
821 DisplayDlgProc(HWND hDlg
,
826 PINFO pInfo
= (PINFO
)GetWindowLongPtrW(GetParent(hDlg
),
832 pInfo
->hDisplayPage
= hDlg
;
833 DisplayOnInit(pInfo
);
838 LPDRAWITEMSTRUCT lpDrawItem
;
839 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
840 if(lpDrawItem
->CtlID
== IDC_COLORIMAGE
)
844 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
847 hSpecOld
= SelectObject(hdcMem
, pInfo
->hSpectrum
);
848 StretchBlt(lpDrawItem
->hDC
,
849 lpDrawItem
->rcItem
.left
,
850 lpDrawItem
->rcItem
.top
,
851 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
852 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
856 pInfo
->bitmap
.bmWidth
,
857 pInfo
->bitmap
.bmHeight
,
859 SelectObject(hdcMem
, hSpecOld
);
868 switch (LOWORD(wParam
))
878 INT newPosition
= (DWORD
)SendDlgItemMessageW(hDlg
, IDC_GEOSLIDER
, TBM_GETPOS
, 0, 0);
879 OnResolutionChanged(pInfo
, newPosition
);
884 OnResolutionChanged(pInfo
, HIWORD(wParam
));
893 DestroyIcon(pInfo
->hRemote
);
896 DestroyIcon(pInfo
->hColor
);
898 if (pInfo
->hSpectrum
)
899 DeleteObject(pInfo
->hSpectrum
);
911 OnMainCreate(HWND hwnd
,
912 PRDPSETTINGS pRdpSettings
)
918 pInfo
= HeapAlloc(GetProcessHeap(),
923 SetWindowLongPtrW(hwnd
,
929 /* add main settings pointer */
930 pInfo
->pRdpSettings
= pRdpSettings
;
932 /* set the dialog icons */
933 pInfo
->hMstscSm
= LoadImageW(hInst
,
934 MAKEINTRESOURCEW(IDI_MSTSC
),
944 (WPARAM
)pInfo
->hMstscSm
);
946 pInfo
->hMstscLg
= LoadImageW(hInst
,
947 MAKEINTRESOURCEW(IDI_MSTSC
),
957 (WPARAM
)pInfo
->hMstscLg
);
960 pInfo
->hHeader
= (HBITMAP
)LoadImageW(hInst
,
961 MAKEINTRESOURCEW(IDB_HEADER
),
968 GetObjectW(pInfo
->hHeader
,
970 &pInfo
->headerbitmap
);
974 pInfo
->hTab
= GetDlgItem(hwnd
, IDC_TAB
);
977 if (CreateDialogW(hInst
,
978 MAKEINTRESOURCEW(IDD_GENERAL
),
980 (DLGPROC
)GeneralDlgProc
))
983 ZeroMemory(&item
, sizeof(TCITEM
));
984 item
.mask
= TCIF_TEXT
;
985 if (LoadStringW(hInst
, IDS_TAB_GENERAL
, str
, 256))
987 item
.cchTextMax
= 256;
988 (void)TabCtrl_InsertItem(pInfo
->hTab
, 0, &item
);
991 if (CreateDialogW(hInst
,
992 MAKEINTRESOURCEW(IDD_DISPLAY
),
994 (DLGPROC
)DisplayDlgProc
))
997 ZeroMemory(&item
, sizeof(TCITEM
));
998 item
.mask
= TCIF_TEXT
;
999 if (LoadStringW(hInst
, IDS_TAB_DISPLAY
, str
, 256))
1001 item
.cchTextMax
= 256;
1002 (void)TabCtrl_InsertItem(pInfo
->hTab
, 1, &item
);
1005 OnTabWndSelChange(pInfo
);
1012 static void Cleanup(PINFO pInfo
)
1016 if (pInfo
->hMstscSm
)
1017 DestroyIcon(pInfo
->hMstscSm
);
1018 if (pInfo
->hMstscLg
)
1019 DestroyIcon(pInfo
->hMstscLg
);
1021 DeleteObject(pInfo
->hHeader
);
1022 if (pInfo
->hSpectrum
)
1023 DeleteObject(pInfo
->hSpectrum
);
1025 DestroyIcon(pInfo
->hRemote
);
1027 DestroyIcon(pInfo
->hLogon
);
1029 DestroyIcon(pInfo
->hConn
);
1031 DestroyIcon(pInfo
->hColor
);
1032 HeapFree(GetProcessHeap(),
1038 static INT_PTR CALLBACK
1046 /* Get the window context */
1047 pInfo
= (PINFO
)GetWindowLongPtrW(hDlg
,
1049 if (pInfo
== NULL
&& Message
!= WM_INITDIALOG
)
1051 goto HandleDefaultMessage
;
1057 OnMainCreate(hDlg
, (PRDPSETTINGS
)lParam
);
1062 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
1064 if (LOWORD(wParam
) == IDOK
)
1066 SaveAllSettings(pInfo
);
1067 SaveRdpSettingsToFile(NULL
, pInfo
->pRdpSettings
);
1070 EndDialog(hDlg
, LOWORD(wParam
));
1080 idctrl
= (int)wParam
;
1081 pnmh
= (LPNMHDR
)lParam
;
1082 if (//(pnmh->hwndFrom == pInfo->hSelf) &&
1083 (pnmh
->idFrom
== IDC_TAB
) &&
1084 (pnmh
->code
== TCN_SELCHANGE
))
1086 OnTabWndSelChange(pInfo
);
1097 hdc
= BeginPaint(hDlg
, &ps
);
1100 HDC hdcMem
= CreateCompatibleDC(hdc
);
1106 HFONT hFont
, hFontOld
;
1109 GetClientRect(pInfo
->hSelf
, &bmpRc
);
1111 hBmpOld
= SelectObject(hdcMem
, pInfo
->hHeader
);
1116 pInfo
->headerbitmap
.bmHeight
,
1120 pInfo
->headerbitmap
.bmWidth
,
1121 pInfo
->headerbitmap
.bmHeight
,
1124 SelectObject(hdcMem
, hBmpOld
);
1125 txtRc
.left
= bmpRc
.right
* 0.25;
1127 txtRc
.right
= bmpRc
.right
* 0.75;
1128 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
* 0.5;
1130 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1132 if (LoadStringW(hInst
,
1135 sizeof(szBuffer
) / sizeof(WCHAR
)))
1138 lf
.lfCharSet
= OEM_CHARSET
;
1139 lf
.lfQuality
= DEFAULT_QUALITY
;
1140 lf
.lfWeight
= FW_MEDIUM
;
1141 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1143 hFont
= CreateFontIndirectW(&lf
);
1146 hFontOld
= SelectObject(hdc
, hFont
);
1148 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1149 SetTextColor(hdc
, RGB(255,255,255));
1150 SetBkMode(hdc
, TRANSPARENT
);
1155 DT_BOTTOM
| DT_SINGLELINE
| DT_NOCLIP
);
1156 SelectObject(hdc
, hFontOld
);
1157 DeleteObject(hFont
);
1161 txtRc
.left
= bmpRc
.right
* 0.25;
1162 txtRc
.top
= txtRc
.bottom
- 5;
1163 txtRc
.right
= bmpRc
.right
* 0.75;
1164 txtRc
.bottom
= pInfo
->headerbitmap
.bmHeight
* 0.9;
1166 if (LoadStringW(hInst
,
1169 sizeof(szBuffer
) / sizeof(WCHAR
)))
1172 lf
.lfCharSet
= OEM_CHARSET
;
1173 lf
.lfQuality
= DEFAULT_QUALITY
;
1174 lf
.lfWeight
= FW_EXTRABOLD
;
1175 wcscpy(lf
.lfFaceName
, L
"Tahoma");
1177 hFont
= CreateFontIndirectW(&lf
);
1180 hFontOld
= SelectObject(hdc
, hFont
);
1182 DPtoLP(hdc
, (PPOINT
)&txtRc
, 2);
1183 SetTextColor(hdc
, RGB(255,255,255));
1184 SetBkMode(hdc
, TRANSPARENT
);
1189 DT_TOP
| DT_SINGLELINE
);
1190 SelectObject(hdc
, hFontOld
);
1191 DeleteObject(hFont
);
1198 EndPaint(hDlg
, &ps
);
1211 HandleDefaultMessage
:
1221 OpenRDPConnectDialog(HINSTANCE hInstance
,
1222 PRDPSETTINGS pRdpSettings
)
1224 INITCOMMONCONTROLSEX iccx
;
1228 iccx
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1229 iccx
.dwICC
= ICC_TAB_CLASSES
;
1230 InitCommonControlsEx(&iccx
);
1232 return (DialogBoxParamW(hInst
,
1233 MAKEINTRESOURCEW(IDD_CONNECTDIALOG
),
1236 (LPARAM
)pRdpSettings
) == IDOK
);