Click here to Skip to main content
16,014,589 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGetting the -REAL- printable area of a page Pin
Ernesto D.11-Sep-04 21:48
Ernesto D.11-Sep-04 21:48 
GeneralRe: Getting the -REAL- printable area of a page Pin
Blake Miller13-Sep-04 6:10
Blake Miller13-Sep-04 6:10 
Questionhow to find which port is active? Pin
anuchelvi11-Sep-04 20:55
anuchelvi11-Sep-04 20:55 
AnswerRe: how to find which port is active? Pin
Mad__13-Sep-04 4:49
Mad__13-Sep-04 4:49 
Generalsearching for Nicholl-Lee- Nicholl C or C++ code Pin
gledaoc11-Sep-04 18:26
gledaoc11-Sep-04 18:26 
GeneralRe: searching for Nicholl-Lee- Nicholl C or C++ code Pin
Ravi Bhavnani12-Sep-04 7:16
professionalRavi Bhavnani12-Sep-04 7:16 
Generaldeselecting list ctrl items Pin
Tyrus18211-Sep-04 14:05
Tyrus18211-Sep-04 14:05 
GeneralRe: deselecting list ctrl items Pin
Branislav11-Sep-04 22:32
Branislav11-Sep-04 22:32 
You'll need to handle LVN_ITEMCHANGING and return FALSE to allow the item to be (un)checked or (de)selected and return TRUE to disallow a change.

Here's some code that might help.

Add this to your CMyListCtrl class definition as a protected function:

// Returns TRUE if the item is checked, false if it is not or uState == 0
inline BOOL IsChecked(UINT uState) {return
(uState ? ((uState & LVIS_STATEIMAGEMASK) >> 12) - 1 : FALSE);}

Here's a sample function for handling LVN_ITEMCHANGING:

void CTestListView::OnItemchanging(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

// If old state is unchecked and new state is checked
// then item is being checked.
if ((! IsChecked(pNMListView->uOldState)) &&
(IsChecked(pNMListView->uNewState)))
MessageBox("Item is being checked");

// If old state is checked and new state is unchecked,
// item is being unchecked
else if ((IsChecked(pNMListView->uOldState)) &&
(! IsChecked(pNMListView->uNewState)))
MessageBox("Item is being unchecked");

// return FALSE (or 0) to allow change, TRUE to prevent
*pResult = 0;
}//OnItemchanging

Select: m_ListCtrl.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
Deselect: m_ListCtrl.SetItemState(iItem, 0, LVIS_SELECTED);

Focused: m_ListCtrl.SetItemState(iItem, LVIS_FOCUSED, LVIS_FOCUSED);
Unfocused: m_ListCtrl.SetItemState(iItem, 0, LVIS_FOCUSED);
GeneralRe: deselecting list ctrl items Pin
Michael Dunn12-Sep-04 8:49
sitebuilderMichael Dunn12-Sep-04 8:49 
GeneralCreate a flash movie from C++ Windows code Pin
AssemblySoft11-Sep-04 13:59
AssemblySoft11-Sep-04 13:59 
GeneralMouse hook Pin
0v3rloader11-Sep-04 13:26
0v3rloader11-Sep-04 13:26 
GeneralRe: Mouse hook Pin
AssemblySoft12-Sep-04 4:53
AssemblySoft12-Sep-04 4:53 
GeneralRe: Mouse hook Pin
0v3rloader12-Sep-04 5:46
0v3rloader12-Sep-04 5:46 
GeneralCRecordset question. Pin
crimsongrape11-Sep-04 12:46
crimsongrape11-Sep-04 12:46 
General_tscanf oddness Pin
Ravi Bhavnani11-Sep-04 11:39
professionalRavi Bhavnani11-Sep-04 11:39 
GeneralRe: _tscanf oddness Pin
Neville Franks11-Sep-04 12:13
Neville Franks11-Sep-04 12:13 
GeneralRe: _tscanf oddness Pin
Ravi Bhavnani11-Sep-04 12:56
professionalRavi Bhavnani11-Sep-04 12:56 
GeneralRe: _tscanf oddness Pin
Joel Holdsworth11-Sep-04 22:33
Joel Holdsworth11-Sep-04 22:33 
GeneralRe: _tscanf oddness Pin
Gary R. Wheeler12-Sep-04 2:50
Gary R. Wheeler12-Sep-04 2:50 
GeneralRe: _tscanf oddness Pin
Joel Holdsworth12-Sep-04 2:55
Joel Holdsworth12-Sep-04 2:55 
GeneralAlpha in GDI Pin
Joel Holdsworth11-Sep-04 9:32
Joel Holdsworth11-Sep-04 9:32 
GeneralRe: Alpha in GDI Pin
Iain Clarke, Warrior Programmer13-Sep-04 3:41
Iain Clarke, Warrior Programmer13-Sep-04 3:41 
GeneralRe: Alpha in GDI Pin
Joel Holdsworth13-Sep-04 7:39
Joel Holdsworth13-Sep-04 7:39 
GeneralReplicating an instance in a multi-threaded app Pin
0v3rloader11-Sep-04 8:56
0v3rloader11-Sep-04 8:56 
GeneralRe: Replicating an instance in a multi-threaded app Pin
Gary R. Wheeler12-Sep-04 2:58
Gary R. Wheeler12-Sep-04 2:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.