From cb3cc17e874f46e8f351e90447fa760773833105 Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Thu, 18 Oct 2018 23:27:43 +0300
Subject: fixes #1621 (resizable Import wizard)

---
 plugins/Import/res/resource.rc  | 40 +++++++++++++++++++++++++-----------
 plugins/Import/src/miranda.cpp  | 31 ++++++++++++++++++++++++++++
 plugins/Import/src/progress.cpp | 13 ++++++++++++
 plugins/Import/src/resource.h   |  6 ++++--
 plugins/Import/src/stdafx.h     |  5 +++++
 plugins/Import/src/wizard.cpp   | 45 +++++++++++++++++++++++++++++++++++++++--
 6 files changed, 124 insertions(+), 16 deletions(-)

(limited to 'plugins/Import')

diff --git a/plugins/Import/res/resource.rc b/plugins/Import/res/resource.rc
index 4f6af7ef49..ead48a41b2 100644
--- a/plugins/Import/res/resource.rc
+++ b/plugins/Import/res/resource.rc
@@ -36,32 +36,32 @@ IDD_WIZARDINTRO DIALOGEX 0, 0, 220, 114
 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
 FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
-    LTEXT           "This wizard will help you import contacts and message history from another Miranda profile or from an external program.",IDC_STATIC,33,12,182,32
+    LTEXT           "This wizard will help you import contacts and message history from another Miranda profile or from an external program.",IDC_STATICTEXT1,33,12,182,32
     ICON            IDI_IMPORT,IDC_STATIC,5,12,20,20
-    LTEXT           "Click ""Next"" to choose the information you wish to import, or click ""Cancel"" to exit the wizard and continue using Miranda.",IDC_STATIC,33,49,182,25
-    LTEXT           "It is recommended that you create a backup of your current Miranda profile before importing.",IDC_STATIC,33,81,182,21
+    LTEXT           "Click ""Next"" to choose the information you wish to import, or click ""Cancel"" to exit the wizard and continue using Miranda.",IDC_STATICTEXT2,33,49,182,25
+    LTEXT           "It is recommended that you create a backup of your current Miranda profile before importing.",IDC_STATICTEXT3,33,81,182,21
 END
 
 IDD_FINISHED DIALOGEX 0, 0, 220, 114
 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
 FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
-    LTEXT           "If you wish to import more information, click ""Next"" to return to the start of the wizard, otherwise click ""Finish"" to start using Miranda.",IDC_STATIC,5,20,210,16
-    LTEXT           "You will probably never need to use this wizard again, so you can save memory by not loading it every time you start Miranda. This will mean that the import menu item will no longer be available.",IDC_STATIC,5,41,210,24
+    LTEXT           "If you wish to import more information, click ""Next"" to return to the start of the wizard, otherwise click ""Finish"" to start using Miranda.",IDC_STATICTEXT1,5,20,210,16
+    LTEXT           "You will probably never need to use this wizard again, so you can save memory by not loading it every time you start Miranda. This will mean that the import menu item will no longer be available.",IDC_STATICTEXT2,5,41,210,24
     CONTROL         "Do not load the import plugin at startup again",IDC_DONTLOADPLUGIN,
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,97,210,10
     LTEXT           "Import completed",IDC_STATIC,5,7,210,8
-    LTEXT           "If at a future date you wish to use the wizard again, you can make it load again by going to the Plugins section of the Options dialog box.",IDC_STATIC,5,69,210,24
+    LTEXT           "If at a future date you wish to use the wizard again, you can make it load again by going to the Plugins section of the Options dialog box.",IDC_STATICTEXT3,5,69,210,24
 END
 
 IDD_MIRANDADB DIALOGEX 0, 0, 220, 114
 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
 FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
-    LTEXT           "Miranda has found Miranda profiles with the following names. Please select the one you wish to import, or click ""Other Profile"" if your profile is not listed, or if the list is empty.",IDC_STATIC,5,10,210,24
+    LTEXT           "Miranda has found Miranda profiles with the following names. Please select the one you wish to import, or click ""Other Profile"" if your profile is not listed, or if the list is empty.",IDC_STATICTEXT1,5,10,210,24
     LISTBOX         IDC_LIST,5,36,210,36,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
     PUSHBUTTON      "&Other Profile...",IDC_OTHER,145,74,70,14
-    RTEXT           "&Filename:",IDC_STATIC,5,93,34,8
+    RTEXT           "&Filename:",IDC_STATICTEXT2,5,93,34,8
     EDITTEXT        IDC_FILENAME,41,91,174,12,ES_AUTOHSCROLL
 END
 
@@ -71,18 +71,18 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
     LTEXT           "Now importing...",IDC_STATIC,5,11,62,8
     CONTROL         "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,5,24,210,10
-    LISTBOX         IDC_STATUS,5,38,210,61,NOT LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
+    LISTBOX         IDC_STATUS,5,38,210,71,NOT LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
 END
 
 IDD_WIZARD DIALOGEX 0, 0, 220, 143
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 CAPTION "Import Information Wizard"
 FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
     DEFPUSHBUTTON   "&Next >",IDOK,120,124,45,13
     PUSHBUTTON      "Cancel",IDCANCEL,170,124,45,13
     PUSHBUTTON      "< &Back",IDC_BACK,75,124,45,13
-    CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-7,115,234,1
+    CONTROL         "",IDC_SPLITTER,"Static",SS_ETCHEDHORZ,-7,120,234,1
 END
 
 IDD_OPTIONS DIALOGEX 0, 0, 220, 120
@@ -96,7 +96,7 @@ BEGIN
                     "Button",BS_AUTORADIOBUTTON | BS_LEFT | BS_TOP | WS_TABSTOP,8,38,206,10
     CONTROL         "Only import contacts",IDC_RADIO_CONTACTS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,68,206,10
     CONTROL         "Custom import",IDC_RADIO_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,7,98,206,10
-    LTEXT           "Makes precise copy of the original profile, including all settings, contacts and history.",IDC_STATIC,27,18,187,16
+    LTEXT           "Makes precise copy of the original profile, including all settings, contacts and history.",IDC_STATICTEXT1,27,18,187,16
     LTEXT           "Imports only contacts and history, and a few settings. Ideal for synchronizing.",IDC_STATIC_ALL,26,48,187,16
     LTEXT           "Imports contacts only, doesn't import any message history.",IDC_STATIC_CONTACTS,26,78,187,16
     LTEXT           "Custom schema: you can choose what to import.",IDC_STATIC_CUSTOM,26,108,187,8,WS_DISABLED
@@ -298,6 +298,22 @@ END
 
 #endif    // APSTUDIO_INVOKED
 
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_WIZARD AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
+IDD_PROGRESS AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
 #endif    // Neutral resources
 /////////////////////////////////////////////////////////////////////////////
 
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp
index 0abfac62c4..7d4c1e4e34 100644
--- a/plugins/Import/src/miranda.cpp
+++ b/plugins/Import/src/miranda.cpp
@@ -63,6 +63,24 @@ bool CMirandaPageDlg::OnInitDialog()
 	return true;
 }
 
+int CMirandaPageDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+	switch (urc->wId) {
+	case IDC_STATICTEXT1:
+		return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+
+	case IDC_STATICTEXT2:
+		return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+
+	case IDC_FILENAME:
+		return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+
+	case IDC_LIST:
+		return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+	}
+	return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+}
+
 void CMirandaPageDlg::OnDestroy()
 {
 	for (int i = SendDlgItemMessage(m_hwnd, IDC_LIST, LB_GETCOUNT, 0, 0) - 1; i >= 0; i--)
@@ -178,6 +196,19 @@ bool CMirandaOptionsPageDlg::OnInitDialog()
 	return true;
 }
 
+int CMirandaOptionsPageDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+	switch (urc->wId) {
+	case IDC_STATIC_ALL:
+	case IDC_STATIC_CONTACTS:
+	case IDC_STATIC_CUSTOM:
+	case IDC_STATICTEXT1:
+		return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+	}
+
+	return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+}
+
 void CMirandaOptionsPageDlg::onClick_Back(CCtrlButton*)
 {
 	PostMessage(m_hwndParent, WIZM_GOTOPAGE, 0, (LPARAM)new CMirandaPageDlg());
diff --git a/plugins/Import/src/progress.cpp b/plugins/Import/src/progress.cpp
index 434f072bd6..eace042403 100644
--- a/plugins/Import/src/progress.cpp
+++ b/plugins/Import/src/progress.cpp
@@ -38,6 +38,19 @@ CProgressPageDlg::CProgressPageDlg() :
 	m_timer.OnEvent = Callback(this, &CProgressPageDlg::OnTimer);
 }
 
+int CProgressPageDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+	switch (urc->wId) {
+	case IDC_PROGRESS:
+		return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+
+	case IDC_STATUS:
+		return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+	}
+
+	return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+}
+
 bool CProgressPageDlg::OnInitDialog()
 {
 	pDlg = this;
diff --git a/plugins/Import/src/resource.h b/plugins/Import/src/resource.h
index f75f1d2a15..bc81fde5fe 100644
--- a/plugins/Import/src/resource.h
+++ b/plugins/Import/src/resource.h
@@ -23,6 +23,10 @@
 #define IDC_FILENAME                    1007
 #define IDC_PROGRESS                    1008
 #define IDC_STATUS                      1009
+#define IDC_SPLITTER							 1010
+#define IDC_STATICTEXT1						 1011
+#define IDC_STATICTEXT2						 1012
+#define IDC_STATICTEXT3						 1013
 #define IDC_RADIO_ALL                   1016
 #define IDC_RADIO_CONTACTS              1017
 #define IDC_RADIO_CUSTOM                1018
@@ -31,7 +35,6 @@
 #define IDC_STATIC_CUSTOM               1021
 #define IDC_RADIO_COMPLETE              1022
 #define IDC_DATETIMEPICKER              1023
-#define IDC_STATIC_ALL2                 1023
 #define IDC_IN_FT                       1024
 #define IDC_CONTACTS                    1025
 #define IDC_SYSTEM                      1026
@@ -48,7 +51,6 @@
 #define IDC_ALL                         1037
 #define IDC_MSG                         1038
 #define IDC_URL                         1039
-#define IDC_FILE                        1040
 #define IDC_FT                          1040
 #define IDC_OPEN_FILE                   1042
 #define IDC_CHECK_DUPS                  1043
diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h
index c30d02c3b0..19259ba0c0 100644
--- a/plugins/Import/src/stdafx.h
+++ b/plugins/Import/src/stdafx.h
@@ -97,6 +97,7 @@ class CIntroPageDlg : public CWizardPageDlg
 {
 public:
 	CIntroPageDlg();
+	int Resizer(UTILRESIZECONTROL *urc) override;
 
 	bool OnInitDialog() override;
 	void OnNext() override;
@@ -109,6 +110,7 @@ class CProgressPageDlg : public CWizardPageDlg
 
 public:
 	CProgressPageDlg();
+	int Resizer(UTILRESIZECONTROL *urc) override;
 
 	bool OnInitDialog() override;
 	void OnDestroy() override;
@@ -130,6 +132,7 @@ class CMirandaPageDlg : public CWizardPageDlg
 
 public:
 	CMirandaPageDlg();
+	int Resizer(UTILRESIZECONTROL *urc) override;
 
 	bool OnInitDialog() override;
 	void OnDestroy() override;
@@ -147,6 +150,7 @@ class CMirandaOptionsPageDlg : public CWizardPageDlg
 
 public:
 	CMirandaOptionsPageDlg();
+	int Resizer(UTILRESIZECONTROL *urc) override;
 
 	bool OnInitDialog() override;
 	void OnNext() override;
@@ -179,6 +183,7 @@ class CFinishedPageDlg : public CWizardPageDlg
 {
 public:
 	CFinishedPageDlg();
+	int Resizer(UTILRESIZECONTROL *urc) override;
 
 	bool OnInitDialog() override;
 	void OnNext() override;
diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp
index ed1fd7432a..7852f89371 100644
--- a/plugins/Import/src/wizard.cpp
+++ b/plugins/Import/src/wizard.cpp
@@ -35,6 +35,14 @@ bool CIntroPageDlg::OnInitDialog()
 	return true;
 }
 
+int CIntroPageDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+	if (urc->wId == -1)
+		return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+
+	return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+}
+
 void CIntroPageDlg::OnNext()
 {
 	PostMessage(m_hwndParent, WIZM_GOTOPAGE, 0, (LPARAM)new CMirandaPageDlg());
@@ -55,6 +63,11 @@ bool CFinishedPageDlg::OnInitDialog()
 	return true;
 }
 
+int CFinishedPageDlg::Resizer(UTILRESIZECONTROL*)
+{
+	return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+}
+
 void CFinishedPageDlg::OnNext()
 {
 	PostMessage(m_hwndParent, WIZM_GOTOPAGE, 0, (LPARAM)new CMirandaPageDlg());
@@ -76,6 +89,7 @@ CWizardPageDlg::CWizardPageDlg(int iDlgId) :
 	btnCancel(this, IDCANCEL)
 {
 	m_autoClose = 0; // disable built-in IDOK & IDCANCEL handlers;
+	m_forceResizable = true;
 
 	btnOk.OnClick = Callback(this, &CWizardPageDlg::onClick_Ok);
 	btnCancel.OnClick = Callback(this, &CWizardPageDlg::onClick_Cancel);
@@ -92,6 +106,7 @@ class CWizardDlg : public CDlgBase
 {
 	CWizardPageDlg *m_pFirstPage;
 	HWND hwndPage = nullptr;
+	int m_splitterX = 0, m_splitterY = 0;
 
 public:
 	CWizardDlg(CWizardPageDlg *pPage) :
@@ -103,6 +118,8 @@ public:
 
 	bool OnInitDialog() override
 	{
+		Utils_RestoreWindowPosition(m_hwnd, 0, IMPORT_MODULE, "wiz");
+
 		Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_IMPORT));
 		g_hwndWizard = m_hwnd;
 
@@ -111,8 +128,26 @@ public:
 		return true;
 	}
 
+	int Resizer(UTILRESIZECONTROL *urc) override
+	{
+		switch (urc->wId) {
+		case IDC_SPLITTER:
+			m_splitterX = urc->dlgNewSize.cx;
+			m_splitterY = urc->dlgNewSize.cy - (urc->dlgOriginalSize.cy - urc->rcItem.top);
+			return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+
+		case IDOK:
+		case IDCANCEL:
+		case IDC_BACK:
+			return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+		}
+
+		return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+	}
+
 	bool OnClose() override
 	{
+		Utils_SaveWindowPosition(m_hwnd, 0, IMPORT_MODULE, "wiz");
 		if (hwndPage)
 			DestroyWindow(hwndPage);
 		return true;
@@ -143,7 +178,7 @@ public:
 				pPage->Show();
 				hwndPage = pPage->GetHwnd();
 			}
-			SetWindowPos(hwndPage, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+			SetWindowPos(hwndPage, nullptr, 0, 0, m_splitterX, m_splitterY, SWP_NOZORDER);
 			if (bFirstLaunch)
 				ShowWindow(m_hwnd, SW_SHOW);
 			break;
@@ -189,7 +224,13 @@ public:
 			break;
 		}
 
-		return CDlgBase::DlgProc(uMsg, wParam, lParam);
+		INT_PTR res = CDlgBase::DlgProc(uMsg, wParam, lParam);
+		if (uMsg == WM_SIZE && hwndPage) {
+			SetWindowPos(hwndPage, 0, 0, 0, m_splitterX, m_splitterY, SWP_NOZORDER | SWP_NOACTIVATE);
+			SendMessage(hwndPage, WM_SIZE, wParam, lParam);
+		}
+
+		return res;
 	}
 };
 
-- 
cgit v1.2.3