Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CProfileAssociationPage Class Reference

#include <profassoc.h>

Inheritance diagram for CProfileAssociationPage:

CShellExtensionPage CPropertyPage List of all members.

Public Member Functions

 CProfileAssociationPage (HINSTANCE hiWhere, LPCTSTR lpstrTarget)
 ~CProfileAssociationPage ()
VOID ConstructAssociations ()
VOID UpdateDeviceListBox ()
virtual BOOL OnInit ()
virtual BOOL OnCommand (WORD wNotifyCode, WORD wid, HWND hwndControl)
virtual BOOL OnNotify (int idCtrl, LPNMHDR pnmh)
virtual BOOL OnDestroy ()
virtual BOOL OnHelp (LPHELPINFO pHelp)
virtual BOOL OnContextMenu (HWND hwnd)
HINSTANCE Instance ()
CProfileProfile ()
void Associate (unsigned uAdd)
void Dissociate (unsigned uRemove)
unsigned Association (unsigned u)
unsigned AssociationCount () const
BOOL AssociationChanged ()
VOID DeviceListChanged ()
LPCTSTR DisplayName (unsigned u)

Private Attributes

CString m_csProfile
CProfilem_pcpTarget
CUintArray m_cuaAdd
CUintArray m_cuaDelete
CUintArray m_cuaAssociate
BOOL m_bAssociationChanged

Constructor & Destructor Documentation

CProfileAssociationPage::CProfileAssociationPage HINSTANCE  hiWhere,
LPCTSTR  lpstrTarget
 

Definition at line 36 of file profassoc.cpp.

References AssociateDevicePage, AssociatePropertyString, CProfileAssociationPage(), m_csProfile, m_pcpTarget, and NULL.

Referenced by CProfileAssociationPage().

00037 { 00038 m_pcpTarget = NULL; 00039 m_csProfile = lpstrTarget; 00040 m_psp.dwSize = sizeof m_psp; 00041 m_psp.dwFlags |= PSP_USETITLE; 00042 m_psp.hInstance = hiWhere; 00043 m_psp.pszTemplate = MAKEINTRESOURCE(AssociateDevicePage); 00044 m_psp.pszTitle = MAKEINTRESOURCE(AssociatePropertyString); 00045 }

CProfileAssociationPage::~CProfileAssociationPage  ) 
 

Definition at line 49 of file profassoc.cpp.

References m_pcpTarget.

00049 { 00050 if (m_pcpTarget) { 00051 delete m_pcpTarget; 00052 } 00053 }


Member Function Documentation

void CProfileAssociationPage::Associate unsigned  uAdd  ) 
 

Definition at line 132 of file profassoc.cpp.

References CUintArray::Add(), Associate(), CUintArray::Count(), DeviceListChanged(), m_cuaAdd, m_cuaAssociate, and m_cuaDelete.

Referenced by Associate(), and CAddDeviceDialog::OnCommand().

00132 { 00133 00134 // First, see if it's on the delete list. If it is, remove it from there 00135 // Otherwise, add us to the add list, if it's a new association. 00136 00137 for (unsigned u = 0; u < m_cuaDelete.Count(); u++) 00138 if (uAdd == m_cuaDelete[u]) 00139 break; 00140 00141 if (u < m_cuaDelete.Count()) 00142 m_cuaDelete.Remove(u); 00143 else { 00144 for (u = 0; u < m_cuaAssociate.Count(); u++) 00145 if (m_cuaAssociate[u] == uAdd) 00146 break; 00147 if (u == m_cuaAssociate.Count()) 00148 m_cuaAdd.Add(uAdd); 00149 } 00150 00151 DeviceListChanged(); 00152 }

unsigned CProfileAssociationPage::Association unsigned  u  )  [inline]
 

Definition at line 55 of file profassoc.h.

References Association(), and m_cuaAssociate.

Referenced by Association(), CAddDeviceDialog::OnInit(), and UpdateDeviceListBox().

00055 { 00056 return m_cuaAssociate[u]; 00057 }

BOOL CProfileAssociationPage::AssociationChanged  )  [inline]
 

Definition at line 61 of file profassoc.h.

References BOOL, and m_bAssociationChanged.

00061 { 00062 return m_bAssociationChanged; 00063 }

unsigned CProfileAssociationPage::AssociationCount  )  const [inline]
 

Definition at line 58 of file profassoc.h.

References CUintArray::Count(), and m_cuaAssociate.

Referenced by CAddDeviceDialog::OnInit(), and UpdateDeviceListBox().

00058 { 00059 return m_cuaAssociate.Count(); 00060 }

VOID CProfileAssociationPage::ConstructAssociations  ) 
 

Definition at line 107 of file profassoc.cpp.

References CUintArray::Add(), CProfile::Association(), CProfile::AssociationCount(), CUintArray::Count(), CUintArray::Empty(), m_cuaAdd, m_cuaAssociate, m_cuaDelete, m_pcpTarget, and VOID().

Referenced by DeviceListChanged(), OnInit(), and OnNotify().

00107 { 00108 00109 m_cuaAssociate.Empty(); // Clean it up! 00110 00111 for (unsigned u = 0; u < m_pcpTarget->AssociationCount(); u++) { 00112 00113 for (unsigned uDelete = 0; 00114 uDelete < m_cuaDelete.Count(); 00115 uDelete++) { 00116 if (m_cuaDelete[uDelete] == m_pcpTarget->Association(u)) 00117 break; 00118 } 00119 00120 if (uDelete == m_cuaDelete.Count()) // Not yet deleted 00121 m_cuaAssociate.Add(m_pcpTarget->Association(u)); 00122 } 00123 00124 // Now, add any added associations 00125 00126 for (u = 0; u < m_cuaAdd.Count(); u++) 00127 m_cuaAssociate.Add(m_cuaAdd[u]); 00128 }

VOID CProfileAssociationPage::DeviceListChanged  )  [inline]
 

Definition at line 65 of file profassoc.h.

References ConstructAssociations(), and VOID().

Referenced by Associate(), and Dissociate().

00065 { 00066 ConstructAssociations(); 00067 }

LPCTSTR CProfileAssociationPage::DisplayName unsigned  u  )  [inline]
 

Definition at line 69 of file profassoc.h.

References CProfile::DisplayName(), DisplayName(), m_cuaAssociate, and m_pcpTarget.

Referenced by DisplayName(), and UpdateDeviceListBox().

00069 { 00070 return m_pcpTarget->DisplayName(m_cuaAssociate[u]); 00071 }

void CProfileAssociationPage::Dissociate unsigned  uRemove  ) 
 

Definition at line 156 of file profassoc.cpp.

References CUintArray::Add(), CUintArray::Count(), DeviceListChanged(), Dissociate(), m_cuaAdd, and m_cuaDelete.

Referenced by Dissociate(), and OnCommand().

00156 { 00157 00158 // First, see if it's on the add list. If it is, remove it from there 00159 // Otherwise, add us to the delete list. 00160 00161 for (unsigned u = 0; u < m_cuaAdd.Count(); u++) 00162 if (uRemove == m_cuaAdd[u]) 00163 break; 00164 00165 if (u < m_cuaAdd.Count()) 00166 m_cuaAdd.Remove(u); 00167 else 00168 m_cuaDelete.Add(uRemove); 00169 00170 DeviceListChanged(); 00171 }

HINSTANCE CProfileAssociationPage::Instance  )  [inline]
 

Definition at line 49 of file profassoc.h.

00049 { return m_psp.hInstance; }

BOOL CProfileAssociationPage::OnCommand WORD  wNotifyCode,
WORD  wid,
HWND  hwndControl
[virtual]
 

Reimplemented from CPropertyPage.

Definition at line 220 of file profassoc.cpp.

References AddButton, CAddDeviceDialog::bCanceled(), BOOL, DeviceListControl, Dissociate(), CPropertyPage::EnableApplyButton(), EnableWindow(), GetDlgItem(), OnCommand(), RemoveButton, SendDlgItemMessage(), CPropertyPage::SettingChanged(), TRUE, and UpdateDeviceListBox().

Referenced by OnCommand().

00220 { 00221 00222 switch (wid) { 00223 00224 case AddButton : 00225 if (wNotifyCode == BN_CLICKED) { 00226 CAddDeviceDialog cadd(this, m_hwnd); 00227 if (!cadd.bCanceled()) { 00228 UpdateDeviceListBox(); 00229 EnableApplyButton(); 00230 SettingChanged(TRUE); 00231 } 00232 return TRUE; 00233 } 00234 break; 00235 00236 case RemoveButton : 00237 if (wNotifyCode == BN_CLICKED) { 00238 LRESULT i = SendDlgItemMessage(m_hwnd, DeviceListControl, 00239 LB_GETCURSEL, 0, 0); 00240 00241 if (i == -1) 00242 return TRUE; 00243 00244 unsigned uItem = (unsigned)SendDlgItemMessage(m_hwnd, DeviceListControl, 00245 LB_GETITEMDATA, i, 0); 00246 Dissociate(uItem); 00247 UpdateDeviceListBox(); 00248 EnableApplyButton(); 00249 SettingChanged(TRUE); 00250 return TRUE; 00251 } 00252 break; 00253 00254 case DeviceListControl : 00255 if (wNotifyCode == LBN_SELCHANGE) { 00256 EnableWindow(GetDlgItem(m_hwnd, RemoveButton), 00257 -1 != SendDlgItemMessage(m_hwnd, DeviceListControl, LB_GETCURSEL, 0, 0)); 00258 return TRUE; 00259 } 00260 break; 00261 } 00262 00263 return TRUE; 00264 }

BOOL CProfileAssociationPage::OnContextMenu HWND  hwnd  )  [virtual]
 

Reimplemented from CPropertyPage.

Definition at line 358 of file profassoc.cpp.

References BOOL, DWORD, GetDlgCtrlID(), OnContextMenu(), ProfileAssociationUIHelpIds, TRUE, and WINDOWS_HELP_FILE.

Referenced by OnContextMenu().

00358 { 00359 00360 DWORD iCtrlID = GetDlgCtrlID(hwnd); 00361 00362 WinHelp(hwnd, WINDOWS_HELP_FILE, 00363 HELP_CONTEXTMENU, (ULONG_PTR) (LPSTR) ProfileAssociationUIHelpIds); 00364 00365 return (TRUE); 00366 }

BOOL CProfileAssociationPage::OnDestroy  )  [virtual]
 

Reimplemented from CPropertyPage.

Definition at line 266 of file profassoc.cpp.

References BOOL, FALSE, m_pcpTarget, and NULL.

00266 { 00267 00268 if (m_pcpTarget) { 00269 delete m_pcpTarget; 00270 m_pcpTarget = (CProfile *) NULL; 00271 } 00272 00273 return FALSE; // still need to handle this message by def. proc. 00274 }

BOOL CProfileAssociationPage::OnHelp LPHELPINFO  pHelp  )  [virtual]
 

Reimplemented from CPropertyPage.

Definition at line 348 of file profassoc.cpp.

References BOOL, OnHelp(), ProfileAssociationUIHelpIds, TRUE, and WINDOWS_HELP_FILE.

Referenced by OnHelp().

00348 { 00349 00350 if (pHelp->iContextType == HELPINFO_WINDOW) { 00351 WinHelp((HWND) pHelp->hItemHandle, WINDOWS_HELP_FILE, 00352 HELP_WM_HELP, (ULONG_PTR) (LPSTR) ProfileAssociationUIHelpIds); 00353 } 00354 00355 return (TRUE); 00356 }

BOOL CProfileAssociationPage::OnInit  )  [virtual]
 

Reimplemented from CPropertyPage.

Definition at line 57 of file profassoc.cpp.

References AddButton, BOOL, ConstructAssociations(), DefaultIcon, CPropertyPage::DisableApplyButton(), CUintArray::Empty(), FALSE, GetDlgItem(), CProfile::GetName(), CProfile::IsInstalled(), m_csProfile, m_cuaAdd, m_cuaDelete, m_pcpTarget, ProfileFilename, SendDlgItemMessage(), SetDlgItemText(), SetFocus, CPropertyPage::SettingChanged(), StatusIcon, TRUE, UninstalledIcon, and UpdateDeviceListBox().

00057 { 00058 00059 m_pcpTarget = new CProfile(m_csProfile); 00060 00061 if (m_pcpTarget) { 00062 00063 // Set profile filename 00064 00065 SetDlgItemText(m_hwnd, ProfileFilename, m_pcpTarget->GetName()); 00066 00067 // Update ICON to show installed/non-installed status. 00068 00069 HICON hIcon = LoadIcon(CGlobals::Instance(), 00070 MAKEINTRESOURCE(m_pcpTarget->IsInstalled() ? DefaultIcon : UninstalledIcon)); 00071 00072 if (hIcon) { 00073 SendDlgItemMessage(m_hwnd, StatusIcon, STM_SETICON, (WPARAM) hIcon, 0); 00074 } 00075 00076 // Clean up add/delete list. 00077 00078 m_cuaAdd.Empty(); 00079 m_cuaDelete.Empty(); 00080 00081 // Build tentitive association list. 00082 00083 ConstructAssociations(); 00084 00085 // And then, fill up device listbox 00086 00087 UpdateDeviceListBox(); 00088 00089 // And set focus on AddButton. 00090 00091 SetFocus(GetDlgItem(m_hwnd,AddButton)); 00092 00093 DisableApplyButton(); 00094 SettingChanged(FALSE); 00095 00096 return TRUE; 00097 00098 } else { 00099 return FALSE; 00100 } 00101 }

BOOL CProfileAssociationPage::OnNotify int  idCtrl,
LPNMHDR  pnmh
[virtual]
 

Reimplemented from CPropertyPage.

Definition at line 278 of file profassoc.cpp.

References CProfile::Associate(), BOOL, ConstructAssociations(), CUintArray::Count(), DefaultIcon, CProfile::DeviceName(), CPropertyPage::DisableApplyButton(), CProfile::Dissociate(), FALSE, CProfile::IsInstalled(), m_csProfile, m_cuaAdd, m_cuaDelete, m_pcpTarget, OnNotify(), CUintArray::Remove(), SendDlgItemMessage(), CPropertyPage::SettingChanged(), StatusIcon, TRUE, UninstalledIcon, and UpdateDeviceListBox().

Referenced by OnNotify().

00278 { 00279 00280 switch (pnmh -> code) { 00281 00282 case PSN_APPLY: { 00283 00284 if (SettingChanged()) { 00285 00286 // Disable apply button, because current request are 00287 // going to be "Applied". 00288 00289 DisableApplyButton(); 00290 00291 // We are going to update changed. 00292 00293 SettingChanged(FALSE); 00294 00295 // Remove any associations we're removing 00296 00297 while (m_cuaDelete.Count()) { 00298 m_pcpTarget->Dissociate(m_pcpTarget->DeviceName(m_cuaDelete[0])); 00299 m_cuaDelete.Remove(0); 00300 } 00301 00302 // Add any associations we're adding 00303 00304 while (m_cuaAdd.Count()) { 00305 m_pcpTarget->Associate(m_pcpTarget->DeviceName(m_cuaAdd[0])); 00306 m_cuaAdd.Remove(0); 00307 } 00308 00309 // Re-create CProfile object. 00310 // 00311 // !!! Need to be done some performance work here. 00312 00313 delete m_pcpTarget; 00314 m_pcpTarget = new CProfile(m_csProfile); 00315 00316 if (!m_pcpTarget) 00317 { 00318 // BUGBUG proper error should happen. 00319 00320 return FALSE; 00321 } 00322 00323 // Re-Build tentitive association list. 00324 00325 ConstructAssociations(); 00326 00327 UpdateDeviceListBox(); 00328 00329 // check the install status to refect icon. 00330 00331 HICON hIcon = LoadIcon(CGlobals::Instance(), 00332 MAKEINTRESOURCE(m_pcpTarget->IsInstalled() ? DefaultIcon : UninstalledIcon)); 00333 00334 if (hIcon) { 00335 SendDlgItemMessage(m_hwnd, StatusIcon, STM_SETICON, (WPARAM) hIcon, 0); 00336 } 00337 } 00338 00339 break; 00340 } 00341 } 00342 00343 return TRUE; 00344 }

CProfile* CProfileAssociationPage::Profile  )  [inline]
 

Definition at line 51 of file profassoc.h.

References m_pcpTarget.

Referenced by CAddDeviceDialog::OnInit().

00051 { return m_pcpTarget; }

VOID CProfileAssociationPage::UpdateDeviceListBox  ) 
 

Definition at line 173 of file profassoc.cpp.

References AddButton, Association(), AssociationCount(), DeviceListControl, DisplayName(), EnableWindow(), GetDlgItem(), GetFocus(), RemoveButton, SendDlgItemMessage(), SendMessage(), SetFocus, TRUE, and VOID().

Referenced by OnCommand(), OnInit(), and OnNotify().

00173 { 00174 00175 // Add the associations to the list 00176 00177 SendDlgItemMessage(m_hwnd, DeviceListControl, LB_RESETCONTENT, 0, 0); 00178 00179 for (unsigned u = 0; u < AssociationCount(); u++ ) { 00180 LRESULT iItem = SendDlgItemMessage(m_hwnd, DeviceListControl, LB_ADDSTRING, 00181 0, (LPARAM) DisplayName(u)); 00182 SendDlgItemMessage(m_hwnd, DeviceListControl, LB_SETITEMDATA, iItem, 00183 (LPARAM) Association(u)); 00184 } 00185 00186 // If there are no associations, disable the Remove Devices button 00187 00188 HWND hwndRemove = GetDlgItem(m_hwnd,RemoveButton); 00189 00190 // If there are no more devices, or all are associated, disable the Add 00191 // Devices button. 00192 // 00193 // !!! To get more performance !!! 00194 // 00195 // EnableWindow(GetDlgItem(m_hwnd, AddButton), 00196 // m_pcpTarget->DeviceCount() && m_pcpTarget->DeviceCount() > AssociationCount()); 00197 // 00198 // !!! AddButton NEVER DISABLED !!! 00199 // 00200 00201 // If focus is on Remove, move it to Add button. 00202 00203 if (GetFocus() == hwndRemove) { 00204 00205 HWND hwndAdd = GetDlgItem(m_hwnd, AddButton); 00206 00207 SetFocus(hwndAdd); 00208 SendMessage(hwndRemove, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0)); 00209 SendMessage(hwndAdd, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0)); 00210 } 00211 00212 EnableWindow(hwndRemove, !!(AssociationCount())); 00213 00214 // If there is any device, set focus to 1st entry. 00215 00216 if (SendDlgItemMessage(m_hwnd, DeviceListControl, LB_GETCOUNT, 0, 0)) 00217 SendDlgItemMessage(m_hwnd, DeviceListControl, LB_SETCURSEL, 0, 0); 00218 }


Member Data Documentation

BOOL CProfileAssociationPage::m_bAssociationChanged [private]
 

Definition at line 31 of file profassoc.h.

Referenced by AssociationChanged().

CString CProfileAssociationPage::m_csProfile [private]
 

Definition at line 22 of file profassoc.h.

Referenced by CProfileAssociationPage(), OnInit(), and OnNotify().

CUintArray CProfileAssociationPage::m_cuaAdd [private]
 

Definition at line 26 of file profassoc.h.

Referenced by Associate(), ConstructAssociations(), Dissociate(), OnInit(), and OnNotify().

CUintArray CProfileAssociationPage::m_cuaAssociate [private]
 

Definition at line 29 of file profassoc.h.

Referenced by Associate(), Association(), AssociationCount(), ConstructAssociations(), and DisplayName().

CUintArray CProfileAssociationPage::m_cuaDelete [private]
 

Definition at line 27 of file profassoc.h.

Referenced by Associate(), ConstructAssociations(), Dissociate(), OnInit(), and OnNotify().

CProfile* CProfileAssociationPage::m_pcpTarget [private]
 

Definition at line 24 of file profassoc.h.

Referenced by ConstructAssociations(), CProfileAssociationPage(), DisplayName(), OnDestroy(), OnInit(), OnNotify(), Profile(), and ~CProfileAssociationPage().


The documentation for this class was generated from the following files:
Generated on Sat May 15 19:46:27 2004 for test by doxygen 1.3.7