/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ #include "stdafx.h" #include "MyCheckListBox.h" #include "MyApp.h" #include "MyLog.h" #include "Generic.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // MyCheckListBox // Constructor. MyCheckListBox::MyCheckListBox() { } // Destructor. /* virtual */ MyCheckListBox::~MyCheckListBox() { } BEGIN_MESSAGE_MAP(MyCheckListBox, CCheckListBox) //{{AFX_MSG_MAP(MyCheckListBox) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // MyCheckListBox message handlers // This is called by MFC after the window's HWND has been bound to the // MyListCtrl object, but before the subclassing occurs. Note that this class // never gets WM_CREATE, because that comes before the subclassing occurs. void MyCheckListBox::PreSubclassWindow() { VALIDATE; HRESULT hr(S_OK); DWORD dwStyle(::GetWindowLong(GetSafeHwnd(), GWL_STYLE)); _ASSERTE(dwStyle & LBS_OWNERDRAWFIXED && "Style for the checklistbox must be 'Owner Draw Fixed'!"); _ASSERTE(dwStyle & LBS_HASSTRINGS && "Style for the checklistbox must be 'Has Strings'!"); dwStyle |= LBS_OWNERDRAWFIXED | LBS_HASSTRINGS; EC_B(0 != ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle)); CCheckListBox::PreSubclassWindow(); } // Append the test to the control, and set its checkbox. void MyCheckListBox::AppendAndSet(const CString& s, bool bCheck) { VALIDATE; _ASSERTE(! s.IsEmpty()); HRESULT hr(S_OK); int nItem(AddString(s)); EC_B(LB_ERR != nItem && LB_ERRSPACE != nItem); SetCheck(nItem, bCheck); }