Author: gedmurphy
Date: Sun Nov 4 16:49:47 2007
New Revision: 30110
URL:
http://svn.reactos.org/svn/reactos?rev=30110&view=rev
Log:
adjust and rearrange some init code
Modified:
trunk/reactos/base/applications/mstsc/connectdialog.c
trunk/reactos/base/applications/mstsc/win32.c
Modified: trunk/reactos/base/applications/mstsc/connectdialog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/co…
==============================================================================
--- trunk/reactos/base/applications/mstsc/connectdialog.c (original)
+++ trunk/reactos/base/applications/mstsc/connectdialog.c Sun Nov 4 16:49:47 2007
@@ -30,9 +30,16 @@
HWND hDisplayPage;
HBITMAP hHeader;
BITMAP headerbitmap;
+ HICON hLogon;
+ HICON hConn;
+ HICON hRemote;
+ HICON hColor;
+ HBITMAP hSpectrum;
+ BITMAP bitmap;
} INFO, *PINFO;
HINSTANCE hInst;
+extern char g_servername[];
void OnTabWndSelChange(PINFO pInfo)
{
@@ -49,6 +56,53 @@
BringWindowToTop(pInfo->hDisplayPage);
break;
}
+}
+
+
+static VOID
+GeneralOnInit(PINFO pInfo)
+{
+ SetWindowPos(pInfo->hGeneralPage,
+ NULL,
+ 15,
+ 122,
+ 0,
+ 0,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
+
+ pInfo->hLogon = LoadImage(hInst,
+ MAKEINTRESOURCE(IDI_LOGON),
+ IMAGE_ICON,
+ 32,
+ 32,
+ LR_DEFAULTCOLOR);
+ if (pInfo->hLogon)
+ {
+ SendDlgItemMessage(pInfo->hGeneralPage,
+ IDC_LOGONICON,
+ STM_SETICON,
+ (WPARAM)pInfo->hLogon,
+ 0);
+ }
+
+ pInfo->hConn = LoadImage(hInst,
+ MAKEINTRESOURCE(IDI_CONN),
+ IMAGE_ICON,
+ 32,
+ 32,
+ LR_DEFAULTCOLOR);
+ if (pInfo->hConn)
+ {
+ SendDlgItemMessage(pInfo->hGeneralPage,
+ IDC_CONNICON,
+ STM_SETICON,
+ (WPARAM)pInfo->hConn,
+ 0);
+ }
+
+ SetDlgItemText(pInfo->hGeneralPage,
+ IDC_SERVERCOMBO,
+ g_servername);
}
@@ -58,69 +112,85 @@
WPARAM wParam,
LPARAM lParam)
{
- static HICON hLogon, hConn;
- HWND hParent = GetParent(hDlg);
- PINFO pInfo = (PINFO)GetWindowLongPtr(hParent,
+ PINFO pInfo = (PINFO)GetWindowLongPtr(GetParent(hDlg),
GWLP_USERDATA);
switch (message)
{
case WM_INITDIALOG:
- {
- SetWindowPos(hDlg,
- NULL,
- 15,
- 122,
- 0,
- 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE |
SWP_NOZORDER);
-
- hLogon = LoadImage(hInst,
- MAKEINTRESOURCE(IDI_LOGON),
+ pInfo->hGeneralPage = hDlg;
+ GeneralOnInit(pInfo);
+ return TRUE;
+
+ case WM_CLOSE:
+ {
+ if (pInfo->hLogon)
+ DestroyIcon(pInfo->hLogon);
+
+ if (pInfo->hConn)
+ DestroyIcon(pInfo->hConn);
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
+
+static VOID
+DisplayOnInit(PINFO pInfo)
+{
+ SetWindowPos(pInfo->hDisplayPage,
+ NULL,
+ 15,
+ 122,
+ 0,
+ 0,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
+
+ pInfo->hRemote = LoadImage(hInst,
+ MAKEINTRESOURCE(IDI_REMOTE),
IMAGE_ICON,
32,
32,
LR_DEFAULTCOLOR);
- if (hLogon)
- {
- SendDlgItemMessage(hDlg,
- IDC_LOGONICON,
- STM_SETICON,
- (WPARAM)hLogon,
- 0);
- }
-
- hConn = LoadImage(hInst,
- MAKEINTRESOURCE(IDI_CONN),
+ if (pInfo->hRemote)
+ {
+ SendDlgItemMessage(pInfo->hDisplayPage,
+ IDC_REMICON,
+ STM_SETICON,
+ (WPARAM)pInfo->hRemote,
+ 0);
+ }
+
+ pInfo->hColor = LoadImage(hInst,
+ MAKEINTRESOURCE(IDI_COLORS),
IMAGE_ICON,
32,
32,
LR_DEFAULTCOLOR);
- if (hConn)
- {
- SendDlgItemMessage(hDlg,
- IDC_CONNICON,
- STM_SETICON,
- (WPARAM)hConn,
- 0);
- }
-
- return TRUE;
- }
-
- case WM_CLOSE:
- {
- if (hLogon)
- DestroyIcon(hLogon);
-
- if (hConn)
- DestroyIcon(hConn);
-
- break;
- }
- }
-
- return 0;
+ if (pInfo->hColor)
+ {
+ SendDlgItemMessage(pInfo->hDisplayPage,
+ IDC_COLORSICON,
+ STM_SETICON,
+ (WPARAM)pInfo->hColor,
+ 0);
+ }
+
+ pInfo->hSpectrum = LoadImage(hInst,
+ MAKEINTRESOURCE(IDB_SPECT),
+ IMAGE_BITMAP,
+ 0,
+ 0,
+ LR_DEFAULTCOLOR);
+ if (pInfo->hSpectrum)
+ {
+ GetObject(pInfo->hSpectrum,
+ sizeof(BITMAP),
+ &pInfo->bitmap);
+ }
}
@@ -130,67 +200,15 @@
WPARAM wParam,
LPARAM lParam)
{
- static HICON hRemote, hColor;
- static HBITMAP hSpectrum;
- static BITMAP bitmap;
PINFO pInfo = (PINFO)GetWindowLongPtr(GetParent(hDlg),
GWLP_USERDATA);
switch (message)
{
case WM_INITDIALOG:
- {
- SetWindowPos(hDlg,
- NULL,
- 15,
- 122,
- 0,
- 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE |
SWP_NOZORDER);
-
- hRemote = LoadImage(hInst,
- MAKEINTRESOURCE(IDI_REMOTE),
- IMAGE_ICON,
- 32,
- 32,
- LR_DEFAULTCOLOR);
- if (hRemote)
- {
- SendDlgItemMessage(hDlg,
- IDC_REMICON,
- STM_SETICON,
- (WPARAM)hRemote,
- 0);
- }
-
- hColor = LoadImage(hInst,
- MAKEINTRESOURCE(IDI_COLORS),
- IMAGE_ICON,
- 32,
- 32,
- LR_DEFAULTCOLOR);
- if (hColor)
- {
- SendDlgItemMessage(hDlg,
- IDC_COLORSICON,
- STM_SETICON,
- (WPARAM)hColor,
- 0);
- }
-
- hSpectrum = LoadImage(hInst,
- MAKEINTRESOURCE(IDB_SPECT),
- IMAGE_BITMAP,
- 0,
- 0,
- LR_DEFAULTCOLOR);
- if (hSpectrum)
- {
- GetObject(hSpectrum, sizeof(BITMAP), &bitmap);
- }
-
+ pInfo->hDisplayPage = hDlg;
+ DisplayOnInit(pInfo);
return TRUE;
- }
case WM_DRAWITEM:
{
@@ -202,7 +220,7 @@
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL)
{
- SelectObject(hdcMem, hSpectrum);
+ SelectObject(hdcMem, pInfo->hSpectrum);
StretchBlt(lpDrawItem->hDC,
lpDrawItem->rcItem.left,
lpDrawItem->rcItem.top,
@@ -211,8 +229,8 @@
hdcMem,
0,
0,
- bitmap.bmWidth,
- bitmap.bmHeight,
+ pInfo->bitmap.bmWidth,
+ pInfo->bitmap.bmHeight,
SRCCOPY);
DeleteDC(hdcMem);
}
@@ -222,14 +240,14 @@
case WM_CLOSE:
{
- if (hRemote)
- DestroyIcon(hRemote);
-
- if (hColor)
- DestroyIcon(hColor);
-
- if (hSpectrum)
- DeleteObject(hSpectrum);
+ if (pInfo->hRemote)
+ DestroyIcon(pInfo->hRemote);
+
+ if (pInfo->hColor)
+ DestroyIcon(pInfo->hColor);
+
+ if (pInfo->hSpectrum)
+ DeleteObject(pInfo->hSpectrum);
break;
}
@@ -242,7 +260,7 @@
static BOOL
-OnCreate(HWND hwnd)
+OnMainCreate(HWND hwnd)
{
PINFO pInfo;
TCITEM item;
@@ -271,11 +289,10 @@
pInfo->hTab = GetDlgItem(hwnd, IDC_TAB);
if (pInfo->hTab)
{
- pInfo->hGeneralPage = CreateDialog(hInst,
- MAKEINTRESOURCE(IDD_GENERAL),
- hwnd,
- (DLGPROC)GeneralDlgProc);
- if (pInfo->hGeneralPage)
+ if (CreateDialog(hInst,
+ MAKEINTRESOURCE(IDD_GENERAL),
+ hwnd,
+ (DLGPROC)GeneralDlgProc))
{
char str[256];
LoadString(hInst, IDS_TAB_GENERAL, str, 256);
@@ -286,11 +303,10 @@
(void)TabCtrl_InsertItem(pInfo->hTab, 0, &item);
}
- pInfo->hDisplayPage = CreateDialog(hInst,
- MAKEINTRESOURCE(IDD_DISPLAY),
- hwnd,
- (DLGPROC)DisplayDlgProc);
- if (pInfo->hDisplayPage)
+ if (CreateDialog(hInst,
+ MAKEINTRESOURCE(IDD_DISPLAY),
+ hwnd,
+ (DLGPROC)DisplayDlgProc))
{
char str[256];
LoadString(hInst, IDS_TAB_DISPLAY, str, 256);
@@ -330,7 +346,7 @@
switch(Message)
{
case WM_INITDIALOG:
- OnCreate(hDlg);
+ OnMainCreate(hDlg);
break;
case WM_COMMAND:
Modified: trunk/reactos/base/applications/mstsc/win32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/wi…
==============================================================================
--- trunk/reactos/base/applications/mstsc/win32.c (original)
+++ trunk/reactos/base/applications/mstsc/win32.c Sun Nov 4 16:49:47 2007
@@ -1476,17 +1476,19 @@
int ret = 1;
WSAStartup(MAKEWORD(2, 0), &d);
- if (OpenRDPConnectDialog(hInstance))
- {
- if (!mi_process_cl(lpCmdLine))
- {
- mi_show_params();
- WSACleanup();
- return 0;
- }
- ui_main();
- ret = 0;
- }
+
+ if (mi_process_cl(lpCmdLine))
+ {
+ if (OpenRDPConnectDialog(hInstance))
+ {
+ ui_main();
+ ret = 0;
+ }
+ }
+ else
+ mi_show_params();
+
+ WSACleanup();
return ret;
}