00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#include "ICMUI.H"
00018
00019
#include "Resource.H"
00020
00021
00022
00023
00024
00025 void CProfilePropertySheet::ConstructAssociations() {
00026
00027
m_cuaAssociate.
Empty();
00028
00029
for (
unsigned u = 0; u <
m_cpTarget.
AssociationCount(); u++) {
00030
for (
unsigned uDelete = 0;
00031 uDelete <
m_cuaDelete.
Count();
00032 uDelete++)
00033
00034
if (
m_cuaDelete[uDelete] ==
m_cpTarget.
Association(u))
00035
break;
00036
00037
if (uDelete ==
m_cuaDelete.
Count())
00038
m_cuaAssociate.
Add(
m_cpTarget.
Association(u));
00039 }
00040
00041
00042
00043
for (u = 0; u <
m_cuaAdd.
Count(); u++)
00044
m_cuaAssociate.
Add(
m_cuaAdd[u]);
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 CProfilePropertySheet::CProfilePropertySheet(HINSTANCE hiWhere,
00056
CProfile& cpTarget) :
00057
CDialog(hiWhere,
00058 cpTarget.IsInstalled() ? UninstallInterface : InstallInterface),
00059 m_cpTarget(cpTarget) {
00060
00061
if (!cpTarget.
IsValid()) {
00062
for (
int i = 0; i <
sizeof m_pcdPage /
sizeof m_pcdPage[0]; i++)
00063
m_pcdPage[i] =
NULL;
00064
00065 CGlobals::Report(
InvalidProfileString, m_hwndParent);
00066
return;
00067 }
00068
00069
m_bDelete =
FALSE;
00070
ConstructAssociations();
00071
00072
DoModal();
00073 }
00074
00075
00076
00077 CProfilePropertySheet::~CProfilePropertySheet() {
00078
for (
int i = 0; i <
sizeof m_pcdPage /
sizeof (
m_pcdPage[0]); i++)
00079
if (
m_pcdPage[i])
00080
delete m_pcdPage[i];
00081 }
00082
00083
00084
00085 void CProfilePropertySheet::Associate(
unsigned uAdd) {
00086
00087
00088
00089
for (
unsigned u = 0; u <
m_cuaDelete.
Count(); u++)
00090
if (uAdd ==
m_cuaDelete[u])
00091
break;
00092
00093
if (u < m_cuaDelete.Count())
00094 m_cuaDelete.Remove(u);
00095
else {
00096
for (u = 0; u <
m_cuaAssociate.
Count(); u++)
00097
if (
m_cuaAssociate[u] == uAdd)
00098
break;
00099
if (u ==
m_cuaAssociate.
Count())
00100
m_cuaAdd.
Add(uAdd);
00101 }
00102
00103
ConstructAssociations();
00104 }
00105
00106
00107
00108 void CProfilePropertySheet::Dissociate(
unsigned uRemove) {
00109
00110
00111
00112
for (
unsigned u = 0; u <
m_cuaAdd.
Count(); u++)
00113
if (uRemove ==
m_cuaAdd[u])
00114
break;
00115
00116
if (u < m_cuaAdd.Count())
00117 m_cuaAdd.Remove(u);
00118
else
00119
m_cuaDelete.
Add(uRemove);
00120
00121
ConstructAssociations();
00122 }
00123
00124
00125
00126 BOOL CProfilePropertySheet::OnInit() {
00127
00128
CString csWork;
00129 TC_ITEM tciThis = {TCIF_TEXT, 0, 0,
NULL, 0, -1, 0};
00130
00131
00132
00133
00134 RECT rcWork;
00135
00136
GetWindowRect(
GetDlgItem(m_hwnd, TabControl), &
m_rcTab);
00137
GetWindowRect(m_hwnd, &rcWork);
00138
OffsetRect(&
m_rcTab, -rcWork.left, -rcWork.top);
00139
SendDlgItemMessage(m_hwnd, TabControl, TCM_ADJUSTRECT,
FALSE,
00140 (LPARAM) &
m_rcTab);
00141
00142
00143
00144
00145
m_pcdPage[0] =
new CInstallPage(
this);
00146
m_pcdPage[1] =
new CAdvancedPage(
this);
00147
m_pcdPage[0] ->
Create();
00148
m_pcdPage[0] -> Adjust(m_rcTab);
00149
00150
00151
00152 csWork.
Load(
m_cpTarget.
IsInstalled() ?
00153
ShortUninstallString :
ShortInstallString);
00154
00155 tciThis.pszText = const_cast<LPTSTR>((LPCTSTR) csWork);
00156
00157
SendDlgItemMessage(m_hwnd, TabControl, TCM_INSERTITEM, 0,
00158 (LPARAM) &tciThis);
00159
00160 csWork.
Load(
AdvancedString);
00161
00162 tciThis.pszText = const_cast<LPTSTR>((LPCTSTR) csWork);
00163
00164
SendDlgItemMessage(m_hwnd, TabControl, TCM_INSERTITEM, 1,
00165 (LPARAM) &tciThis);
00166
00167
00168
00169 HICON hi = LoadIcon(m_hiWhere,
00170 MAKEINTRESOURCE(
m_cpTarget.
IsInstalled() ?
00171
DefaultIcon :
UninstalledIcon));
00172
00173
SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM) hi);
00174
00175
return TRUE;
00176 }
00177
00178
00179
00180 BOOL CProfilePropertySheet::OnNotify(
int idCtrl, LPNMHDR pnmh) {
00181
00182
int iPage = !!
SendMessage(pnmh -> hwndFrom, TCM_GETCURSEL, 0, 0);
00183
00184
switch (pnmh -> code) {
00185
case TCN_SELCHANGING:
00186
00187
m_pcdPage[iPage] ->
Destroy();
00188
return FALSE;
00189
00190
case TCN_SELCHANGE:
00191
00192
00193
00194
m_pcdPage[iPage] ->
Create();
00195
m_pcdPage[iPage] -> Adjust(
m_rcTab);
00196
00197
return TRUE;
00198 }
00199
00200
return TRUE;
00201 }
00202
00203
00204
00205 BOOL CProfilePropertySheet::OnCommand(WORD wNotifyCode, WORD wid,
00206 HWND hwndControl) {
00207
switch (wid) {
00208
00209
case IDOK:
00210
00211
if (wNotifyCode == BN_CLICKED && !
m_cpTarget.
IsInstalled())
00212
m_cpTarget.
Install();
00213
00214
while (
m_cuaDelete.
Count()) {
00215
m_cpTarget.
Dissociate(
m_cpTarget.Device(
m_cuaDelete[0]));
00216
m_cuaDelete.
Remove(0);
00217 }
00218
00219
while (
m_cuaAdd.
Count()) {
00220
m_cpTarget.
Associate(
m_cpTarget.Device(
m_cuaAdd[0]));
00221
m_cuaAdd.
Remove(0);
00222 }
00223
break;
00224
00225
case UninstallButton:
00226
00227
if (wNotifyCode == BN_CLICKED)
00228
m_cpTarget.
Uninstall(
m_bDelete);
00229
break;
00230 }
00231
00232
return CDialog::OnCommand(wNotifyCode, wid, hwndControl);
00233 }