-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDialogPage.cpp
More file actions
164 lines (140 loc) · 3.5 KB
/
DialogPage.cpp
File metadata and controls
164 lines (140 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "stdafx.h"
#include "Axis3.h"
#include "Axis3Dlg.h"
#include "DialogPage.h"
IMPLEMENT_DYNAMIC(CDialogPage, CDialogEx)
CDialogPage::CDialogPage(UINT ID, HICON h_Icon ,CWnd* pParent /*=NULL*/)
: CDialogEx(ID, pParent)
{
initialized = FALSE;
m_hIcon = h_Icon;
}
CDialogPage::~CDialogPage()
{
}
void CDialogPage::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDialogPage, CDialogEx)
ON_WM_RBUTTONDOWN()
ON_WM_CTLCOLOR()
ON_WM_GETMINMAXINFO()
ON_COMMAND(IDOK, OnOk)
ON_COMMAND(IDCLOSE, OnClose)
END_MESSAGE_MAP()
void CDialogPage::PreSubclassWindow()
{
ModifyStyleEx(WS_EX_DLGMODALFRAME, 0);
ModifyStyle(WS_CHILD, WS_POPUP);
CDialogEx::PreSubclassWindow();
}
BOOL CDialogPage::OnInitDialog()
{
CDialogEx::OnInitDialog();
//Set CtrlID of Tab Pages
iCtrlID = Main->iDlgCtrlID;
SetDlgCtrlID(Main->iDlgCtrlID);
Main->iDlgCtrlID++;
//Set Icon and Position of Tab
SetIcon(m_hIcon, FALSE);
CenterWindow();
GetWindowRect(&MinSize);
ScreenToClient(&MinSize);
GetClientRect(&MinDock);
ScreenToClient(&MinDock);
//Dock the Page to the Main Dialog
OnCancel();
return TRUE;
}
void CDialogPage::OnRButtonDown(UINT /*nFlags*/, CPoint point)
{
//Dock/Undock Menu
ClientToScreen(&point);
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
DWORD dwCurStyle = ::GetWindowLong(GetSafeHwnd(), GWL_STYLE);
if (dwCurStyle & WS_CHILD)
::AppendMenu(hMenu, MF_STRING, 1, CMsg(_T("Undock Tab")));
else
::AppendMenu(hMenu, MF_STRING, 2, CMsg(_T("Dock Tab")));
int sel = ::TrackPopupMenuEx(hMenu,
TPM_CENTERALIGN | TPM_RETURNCMD,
point.x,
point.y,
m_hWnd,
NULL);
switch (sel)
{
case 1:
{
//Undock Tab from Main Dialog
//Change Style/Parent/Caption to Dialog form WS_EX_APPWINDOW
ModifyStyle(WS_CHILD, WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_THICKFRAME);
::SetWindowText(GetSafeHwnd(), Main->m_TabCtrl.GetTabText(Main->m_TabCtrl.GetSel()));
::SetParent(GetSafeHwnd(), NULL);
//Position Window
CenterWindowEx(m_hWnd);
//Remove Tab from Main Dialog
Main->m_TabCtrl.Delete(Main->m_TabCtrl.GetSel());
Main->m_TabCtrl.Update();
break;
}
case 2:
{
//Dock Tab to Main Dialog
OnCancel();
break;
}
}
::DestroyMenu(hMenu);
}
}
void CDialogPage::OnCancel()
{
//Dock Tab to Main Dialog
//Hide Window
::ShowWindow(GetSafeHwnd(),SW_HIDE);
//Reset Style/Parent/ID/Caption to Tab form
ModifyStyle(WS_THICKFRAME | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, WS_CHILD);
::ShowWindow(GetSafeHwnd(), SW_RESTORE);
::SetParent(GetSafeHwnd(), Main->m_TabCtrl.GetSafeHwnd());
SetDlgCtrlID(iCtrlID);
CString csCaption;
GetWindowText(csCaption);
//Add Tab to Main Dialog
Main->m_TabCtrl.SetSel(Main->m_TabCtrl.AddEx(GetSafeHwnd(),csCaption,-1));
Main->m_TabCtrl.Update();
return;
}
HBRUSH CDialogPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
//Set Color of Tab's Background
CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
::SetBkMode(pDC->m_hDC,TRANSPARENT);
switch (nCtlColor)
{
case CTLCOLOR_EDIT:
case CTLCOLOR_LISTBOX:
return Main->hbWhite;
default:
return Main->hbBlue;
}
}
void CDialogPage::OnOk()
{
}
void CDialogPage::OnClose()
{
CDialogEx::OnOK();
}
void CDialogPage::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if(initialized)
{
lpMMI->ptMinTrackSize.x = MinSize.Width();
lpMMI->ptMinTrackSize.y = MinSize.Height();
}
CDialogEx::OnGetMinMaxInfo(lpMMI);
}