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

CMonitorProfileManagement Class Reference

#include <devprop.h>

Inheritance diagram for CMonitorProfileManagement:

CDeviceProfileManagement CShellExtensionPage CPropertyPage List of all members.

Public Member Functions

 CMonitorProfileManagement (LPCTSTR lpstrName, LPCTSTR lpstrFriendlyName, HINSTANCE hiWhere)
 ~CMonitorProfileManagement ()
virtual BOOL OnInit ()
virtual BOOL OnCommand (WORD wNotifyCode, WORD wid, HWND hwndCtl)
virtual BOOL OnNotify (int idCtrl, LPNMHDR pnmh)
virtual BOOL OnHelp (LPHELPINFO pHelp)
virtual BOOL OnContextMenu (HWND hwnd)

Protected Member Functions

virtual void InitList ()
virtual void FillList (DWORD dwFlags=0)

Protected Attributes

unsigned m_uDefault
CString m_csDeviceFriendlyName

Constructor & Destructor Documentation

CMonitorProfileManagement::CMonitorProfileManagement LPCTSTR  lpstrName,
LPCTSTR  lpstrFriendlyName,
HINSTANCE  hiWhere
 

Definition at line 1379 of file devprop.cpp.

References CMonitorProfileManagement(), IsAdmin(), m_csDeviceFriendlyName, and MonitorUI.

Referenced by CMonitorProfileManagement().

01381 : 01382 CDeviceProfileManagement(lpstrName, hiWhere, MonitorUI, CLASS_MONITOR) { 01383 01384 01385 // if the user is not the administrator, 01386 // make this property sheet read only. 01387 01388 m_bReadOnly = !IsAdmin(); 01389 01390 // Keep friendly name in MonitorProfileManagement class. 01391 01392 m_csDeviceFriendlyName = lpstrFriendlyName; 01393 }

CMonitorProfileManagement::~CMonitorProfileManagement  )  [inline]
 

Definition at line 186 of file devprop.h.

00186 {}


Member Function Documentation

void CMonitorProfileManagement::FillList DWORD  dwFlags = 0  )  [protected, virtual]
 

Reimplemented from CDeviceProfileManagement.

Definition at line 1293 of file devprop.cpp.

References CUintArray::Count(), CProfileArray::Count(), DefaultButton, DefaultProfile, DEVLIST_NOSELECT, DEVLIST_ONINIT, dwFlags, EnableWindow(), FALSE, FillList(), GetDlgItem(), CString::Load(), m_uDefault, NoProfileString, RemoveButton, SendMessage(), and SetDlgItemText().

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

01293 { 01294 01295 // If we are initializing list box, we want to put focus on 01296 // "default" profile. here we won't below FillList set focus 01297 // to first one. 01298 01299 if (dwFlags & DEVLIST_ONINIT) { 01300 dwFlags |= DEVLIST_NOSELECT; 01301 } 01302 01303 CDeviceProfileManagement::FillList(dwFlags); 01304 01305 // There is either no default profile, an existing profile is the 01306 // default, or a newly selected one is. Some people just like the 01307 // selection operator. 01308 01309 // if there is only 1 profile in list box, we treat it as default profile. 01310 01311 if (SendMessage(m_hwndList,LB_GETCOUNT,0,0) == 1) { 01312 m_uDefault = (unsigned)SendMessage(m_hwndList, LB_GETITEMDATA, 0, 0); 01313 } 01314 01315 if (m_uDefault == -1) { 01316 01317 // There is no profile associated for this device. 01318 01319 CString csNoProfile; 01320 csNoProfile.Load(NoProfileString); 01321 SetDlgItemText(m_hwnd, DefaultProfile, csNoProfile); 01322 01323 } else { 01324 01325 // If the default has been deleted, set default as last in list. 01326 01327 if (m_uDefault >= (m_cpaProfile.Count() + m_cpaAdds.Count())) { 01328 01329 m_uDefault = (m_cpaProfile.Count() + m_cpaAdds.Count()) - 1; 01330 } 01331 01332 // Put default profile name in UI. 01333 01334 CProfile *pcpDefault = (m_uDefault < m_cpaProfile.Count()) ? \ 01335 m_cpaProfile[m_uDefault] : \ 01336 m_cpaAdds[m_uDefault - m_cpaProfile.Count()]; 01337 01338 SetDlgItemText(m_hwnd, DefaultProfile, pcpDefault -> GetName()); 01339 01340 // If we are initialing list box, put focus on default profile. 01341 01342 if (dwFlags & DEVLIST_ONINIT) { 01343 01344 LRESULT idSelect = SendMessage(m_hwndList, LB_FINDSTRINGEXACT, 01345 (WPARAM) -1, (LPARAM) (LPCTSTR) pcpDefault -> GetName()); 01346 01347 // if could not find, just select first item. 01348 01349 if (idSelect == LB_ERR) { 01350 idSelect = 0; 01351 } 01352 01353 // Select it. 01354 01355 SendMessage(m_hwndList, LB_SETCURSEL, idSelect, 0); 01356 } 01357 } 01358 01359 // 03-08-1997 [email protected] Memphis RAID 18420 01360 // Disable the Default button if there aren't any profiles 01361 01362 // We do it here, because this gets called any time the list changes. 01363 // only allow Default button to be enabled if 01364 // the dialog isn't read only. 01365 // the remove button should remain dissabled 01366 // under all conditions while the user is not 01367 // administrator. 01368 01369 if (m_bReadOnly) { 01370 EnableWindow(GetDlgItem(m_hwnd, RemoveButton), FALSE); 01371 } else { 01372 EnableWindow(GetDlgItem(m_hwnd, DefaultButton), 01373 m_cpaAdds.Count() + m_cpaProfile.Count() - m_cuaRemovals.Count()); 01374 } 01375 }

void CMonitorProfileManagement::InitList  )  [protected, virtual]
 

Reimplemented from CDeviceProfileManagement.

Definition at line 1284 of file devprop.cpp.

References CProfileArray::Count(), CDeviceProfileManagement::InitList(), and m_uDefault.

Referenced by OnNotify().

01284 { 01285 01286 CDeviceProfileManagement::InitList(); 01287 01288 m_uDefault = m_cpaProfile.Count() ? 0 : (unsigned) -1; 01289 }

BOOL CMonitorProfileManagement::OnCommand WORD  wNotifyCode,
WORD  wid,
HWND  hwndCtl
[virtual]
 

Reimplemented from CDeviceProfileManagement.

Definition at line 1431 of file devprop.cpp.

References AskRemoveDefault, BOOL, CProfileArray::Count(), DefaultButton, DEVLIST_CHANGED, FALSE, FillList(), m_uDefault, OnCommand(), RemoveButton, SendMessage(), and TRUE.

Referenced by OnCommand().

01432 { 01433 01434 switch (wNotifyCode) { 01435 01436 case LBN_DBLCLK: { 01437 01438 // Retrieve the ID of the new default profile 01439 // only accept dblclk changes if the dialog 01440 // is not read only - i.e. user is admin 01441 01442 if (!m_bReadOnly) { 01443 01444 int id = (int)SendMessage(m_hwndList, LB_GETCURSEL, 0, 0); 01445 m_uDefault = (unsigned)SendMessage(m_hwndList, LB_GETITEMDATA, id, 0); 01446 01447 // Change has been made, update the list 01448 01449 FillList(DEVLIST_CHANGED); 01450 } 01451 01452 return TRUE; 01453 } 01454 01455 case BN_CLICKED: 01456 01457 switch (wid) { 01458 01459 case RemoveButton: { 01460 01461 // Make sure we've tracked the default profile correctly 01462 // when a profile is removed. 01463 // All cases break, because we then want the base class to 01464 // process this message. 01465 01466 LRESULT id = SendMessage(m_hwndList, LB_GETCURSEL, 0, 0); 01467 01468 unsigned uTarget = (unsigned)SendMessage(m_hwndList, LB_GETITEMDATA, 01469 id, 0); 01470 01471 if (uTarget > m_uDefault || m_uDefault == (unsigned) -1) 01472 break; // Nothing here to worry about 01473 01474 if (m_uDefault == uTarget) { 01475 01476 if (CGlobals::ReportEx(AskRemoveDefault, m_hwnd, FALSE, 01477 MB_YESNO|MB_ICONEXCLAMATION,0) == IDYES) { 01478 01479 // The default has been deleted- the profile 01480 // at the top of monitor profile list will be 01481 // made the default profile, if we have 01482 01483 LRESULT itemCount = SendMessage(m_hwndList, LB_GETCOUNT, 0, 0); 01484 01485 if ((itemCount != LB_ERR) && (itemCount > 1)) { 01486 m_uDefault = (unsigned)SendMessage(m_hwndList, LB_GETITEMDATA, 0, 0); 01487 if (m_uDefault == uTarget) { 01488 m_uDefault = (unsigned)SendMessage(m_hwndList, LB_GETITEMDATA, 1, 0); 01489 } 01490 } else { 01491 m_uDefault = -1; 01492 } 01493 01494 break; 01495 } else { 01496 return TRUE; // operation cancelled. 01497 } 01498 } 01499 01500 if (uTarget < m_cpaProfile.Count()) 01501 break; // We're fine 01502 01503 // Must be an added profile below us in the list was 01504 // zapped- we need to decrement ourselves. 01505 01506 m_uDefault--; 01507 break; 01508 } 01509 01510 case DefaultButton: { 01511 01512 LRESULT id = SendMessage(m_hwndList, LB_GETCURSEL, 0, 0); 01513 01514 m_uDefault = (unsigned)SendMessage(m_hwndList, LB_GETITEMDATA, id, 0); 01515 01516 // Change has been made, update the list 01517 01518 FillList(DEVLIST_CHANGED); 01519 01520 return TRUE; 01521 } 01522 } 01523 01524 // Deliberate fall-through (use a break if you add a case here) 01525 } 01526 01527 // Use common command handling if not handled above 01528 return CDeviceProfileManagement::OnCommand(wNotifyCode, wid, hwndCtl); 01529 }

BOOL CMonitorProfileManagement::OnContextMenu HWND  hwnd  )  [virtual]
 

Reimplemented from CPropertyPage.

Definition at line 1636 of file devprop.cpp.

References BOOL, MonitorUIHelpIds, OnContextMenu(), TRUE, and WINDOWS_HELP_FILE.

Referenced by OnContextMenu().

01636 { 01637 01638 WinHelp(hwnd, WINDOWS_HELP_FILE, 01639 HELP_CONTEXTMENU, (ULONG_PTR) (LPSTR) MonitorUIHelpIds); 01640 01641 return (TRUE); 01642 }

BOOL CMonitorProfileManagement::OnHelp LPHELPINFO  pHelp  )  [virtual]
 

Reimplemented from CPropertyPage.

Definition at line 1626 of file devprop.cpp.

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

Referenced by OnHelp().

01626 { 01627 01628 if (pHelp->iContextType == HELPINFO_WINDOW) { 01629 WinHelp((HWND) pHelp->hItemHandle, WINDOWS_HELP_FILE, 01630 HELP_WM_HELP, (ULONG_PTR) (LPSTR) MonitorUIHelpIds); 01631 } 01632 01633 return (TRUE); 01634 }

BOOL CMonitorProfileManagement::OnInit  )  [virtual]
 

Reimplemented from CDeviceProfileManagement.

Definition at line 1397 of file devprop.cpp.

References AddButton, BOOL, DefaultButton, EnableWindow(), FALSE, GetDlgItem(), m_csDeviceFriendlyName, MonitorName, CDeviceProfileManagement::OnInit(), RemoveButton, SetDlgItemText(), SetFocus, and TRUE.

01397 { 01398 01399 // Do common initializations 01400 01401 CDeviceProfileManagement::OnInit(); 01402 01403 // Mark the device name in the space provided 01404 01405 SetDlgItemText(m_hwnd, MonitorName, m_csDeviceFriendlyName); 01406 01407 // Now, see if we have sufficient authority to administer the monitor 01408 01409 if(m_bReadOnly) { 01410 01411 // User is not Admin, Disable all of the controls 01412 01413 EnableWindow(GetDlgItem(m_hwnd, AddButton), FALSE); 01414 EnableWindow(GetDlgItem(m_hwnd, RemoveButton), FALSE); 01415 EnableWindow(GetDlgItem(m_hwnd, DefaultButton), FALSE); 01416 01417 // EnableWindow(m_hwndList, FALSE); 01418 01419 // Set the focus to the OK button 01420 01421 SetFocus(GetDlgItem(m_hwndSheet, IDOK)); 01422 return FALSE; // Because we moved the focus! 01423 } 01424 01425 return TRUE; 01426 }

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

Reimplemented from CDeviceProfileManagement.

Definition at line 1533 of file devprop.cpp.

References BOOL, CUintArray::Count(), CProfileArray::Count(), CPropertyPage::DisableApplyButton(), FALSE, FillList(), InitList(), m_uDefault, NoDefaultProfile, OnNotify(), CPropertyPage::SettingChanged(), SetWindowLongPtr(), and TRUE.

Referenced by OnNotify().

01533 { 01534 01535 switch (pnmh -> code) { 01536 01537 case PSN_APPLY: { 01538 01539 DisableApplyButton(); 01540 01541 // If nothing changed, nothing need to do. 01542 01543 if (!SettingChanged()) 01544 return TRUE; 01545 01546 // If the user hasn't selected a default, and we have 01547 // associated profiles, then we can't allow this. 01548 01549 // 03-08-1997 A-RobKj Fix for Memphis RAID 18416- if there's 01550 // only one profile left, then it must be the default. 01551 01552 if (m_uDefault == (unsigned) -1 && (m_cpaAdds.Count() + 01553 m_cpaProfile.Count() - m_cuaRemovals.Count()) > 1) { 01554 01555 CGlobals::Report(NoDefaultProfile, m_hwndSheet); 01556 SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); 01557 break; 01558 } 01559 01560 // !!! This behavior is hardly depend on EnumColorProfiles() API !!! 01561 01562 // OK, if the default profile has changed, we have to delete default 01563 // profile associations, and do the association for default profile 01564 // in "last". 01565 01566 // Let the base class handle the cases where the default hasn't 01567 // changed, or we started with no profiles and still have none. 01568 // 01569 // 03-08-1997 Sleazy code note. The case where no default is 01570 // selected but only one is assigned will now fall here. Since the 01571 // default happens to be the "last", and there only is one, letting 01572 // the base class handle it is not a problem. The list filling 01573 // code will take care of the rest for us. 01574 01575 if (m_uDefault == (unsigned) -1) break; 01576 01577 // Remove default first (if default is associated), then associate later. 01578 01579 if (m_uDefault < m_cpaProfile.Count()) 01580 m_cpaProfile[m_uDefault] -> Dissociate(m_csDevice); 01581 01582 // Now do the other removals (actually just dissociations) 01583 01584 for (unsigned u = 0; u < m_cuaRemovals.Count(); u++) { 01585 m_cpaProfile[m_cuaRemovals[u]] -> Dissociate(m_csDevice); 01586 } 01587 01588 // Add in the new ones 01589 01590 for (u = 0; u < m_cpaAdds.Count(); u++) { 01591 if (m_uDefault >= m_cpaProfile.Count()) 01592 if (u == (m_uDefault - m_cpaProfile.Count())) 01593 continue; // this is default, will be done later 01594 01595 // OK, add it back in... 01596 m_cpaAdds[u] -> Associate(m_csDevice); 01597 } 01598 01599 // Finally, associate default profile. 01600 01601 if (m_uDefault < m_cpaProfile.Count()) 01602 m_cpaProfile[m_uDefault] -> Associate(m_csDevice); 01603 else 01604 m_cpaAdds[m_uDefault - m_cpaProfile.Count()] -> Associate(m_csDevice); 01605 01606 // Update the various working structures... 01607 01608 InitList(); 01609 FillList(); 01610 01611 SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_NOERROR); 01612 01613 // Now, we have updated settings. 01614 01615 SettingChanged(FALSE); 01616 } 01617 } 01618 01619 // Let the base class handle everything else 01620 01621 return CDeviceProfileManagement::OnNotify(idCtrl, pnmh); 01622 }


Member Data Documentation

CString CMonitorProfileManagement::m_csDeviceFriendlyName [protected]
 

Definition at line 178 of file devprop.h.

Referenced by CMonitorProfileManagement(), and OnInit().

unsigned CMonitorProfileManagement::m_uDefault [protected]
 

Definition at line 177 of file devprop.h.

Referenced by FillList(), InitList(), OnCommand(), and OnNotify().


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