Click here to Skip to main content
15,905,322 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLVN_BEGINDRAG Pin
baerten27-Jun-07 2:44
baerten27-Jun-07 2:44 
AnswerRe: LVN_BEGINDRAG Pin
KarstenK27-Jun-07 2:50
mveKarstenK27-Jun-07 2:50 
GeneralRe: LVN_BEGINDRAG Pin
baerten27-Jun-07 3:49
baerten27-Jun-07 3:49 
GeneralRe: LVN_BEGINDRAG Pin
KarstenK27-Jun-07 4:26
mveKarstenK27-Jun-07 4:26 
GeneralRe: LVN_BEGINDRAG Pin
baerten27-Jun-07 4:40
baerten27-Jun-07 4:40 
QuestionCTreeCtrl and trapping on message after checkbox is marked Pin
JDCSI9927-Jun-07 1:49
JDCSI9927-Jun-07 1:49 
AnswerRe: CTreeCtrl and trapping on message after checkbox is marked Pin
Iain Clarke, Warrior Programmer27-Jun-07 3:12
Iain Clarke, Warrior Programmer27-Jun-07 3:12 
AnswerRe: CTreeCtrl and trapping on message after checkbox is marked Pin
Iain Clarke, Warrior Programmer27-Jun-07 3:38
Iain Clarke, Warrior Programmer27-Jun-07 3:38 
OK, you officially owe me a pint.

There isn't a clear message, but as its a common control, you get owner draw notifications when things have changed. Including the check box...

The below code will raise some repeated messages, eg when you scroll. So in your handling code, I'd check if the change is really a change, or just a redraw.

Iain.

ON_NOTIFY(NM_CUSTOMDRAW, IDC_TREE1, OnTreeCustomDraw)

void CMyDlg::OnTreeCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;
	NMTVCUSTOMDRAW *nmtv = (NMTVCUSTOMDRAW *)pNMHDR;

	// TODO: Add your control notification handler code here

	switch (nmtv->nmcd.dwDrawStage)
	{
	case CDDS_PREPAINT:
		*pResult = CDRF_NOTIFYITEMDRAW;
		return;

	case CDDS_POSTPAINT:
		break;

	case CDDS_ITEMPREPAINT:
		TRACE1("uItemState=%x\n", nmtv->nmcd.uItemState);
		{
			BOOL bState = TreeView_GetCheckState (::GetDlgItem (GetSafeHwnd (), IDC_TREE1), (HTREEITEM) nmtv->nmcd.dwItemSpec);
			TRACE1("   Check state = %i\n", bState);
                        // Now do whatever you like!
		}
		break;

	case CDDS_ITEMPOSTPAINT:
	case CDDS_ITEMPREERASE:
	case CDDS_ITEMPOSTERASE:
		break;
	default:
		TRACE1("Unexpected draw state =%i", nmtv->nmcd.dwDrawStage);
		break;
	}

	
}

// Copied from MSDN
BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem)
{
    TVITEM tvItem;

    // Prepare to receive the desired information.
    tvItem.mask = TVIF_HANDLE | TVIF_STATE;
    tvItem.hItem = hItem;
    tvItem.stateMask = TVIS_STATEIMAGEMASK;

    // Request the information.
    TreeView_GetItem(hwndTreeView, &tvItem);

    // Return zero if it's not checked, or nonzero otherwise.
    return ((BOOL)(tvItem.state >> 12) -1);
}



GeneralRe: CTreeCtrl and trapping on message after checkbox is marked Pin
JDCSI9927-Jun-07 4:38
JDCSI9927-Jun-07 4:38 
QuestionHelp needed to solve images problem Pin
James_Programmer27-Jun-07 1:42
James_Programmer27-Jun-07 1:42 
AnswerRe: Help needed to solve images problem Pin
KarstenK27-Jun-07 1:59
mveKarstenK27-Jun-07 1:59 
GeneralRe: Help needed to solve images problem Pin
James_Programmer27-Jun-07 2:14
James_Programmer27-Jun-07 2:14 
GeneralRe: Help needed to solve images problem Pin
KarstenK27-Jun-07 2:45
mveKarstenK27-Jun-07 2:45 
GeneralRe: Help needed to solve images problem Pin
James_Programmer27-Jun-07 20:24
James_Programmer27-Jun-07 20:24 
GeneralRe: Help needed to solve images problem Pin
KarstenK27-Jun-07 21:09
mveKarstenK27-Jun-07 21:09 
QuestionRe: Help needed to solve images problem Pin
Rajkumar R27-Jun-07 2:33
Rajkumar R27-Jun-07 2:33 
Questionhow can i unselecect files in a list view Pin
vasu_sri27-Jun-07 1:39
vasu_sri27-Jun-07 1:39 
AnswerRe: how can i unselecect files in a list view Pin
Nibu babu thomas27-Jun-07 1:48
Nibu babu thomas27-Jun-07 1:48 
QuestionHow to Get System Hard Disk Serial Number in MFC Pin
swamy Narasimha27-Jun-07 1:37
swamy Narasimha27-Jun-07 1:37 
AnswerRe: How to Get System Hard Disk Serial Number in MFC Pin
prasad_som27-Jun-07 2:30
prasad_som27-Jun-07 2:30 
AnswerRe: How to Get System Hard Disk Serial Number in MFC Pin
Hamid_RT27-Jun-07 8:30
Hamid_RT27-Jun-07 8:30 
QuestionHow to handle Exceptions in Constructor? Pin
narayanagvs27-Jun-07 1:31
narayanagvs27-Jun-07 1:31 
AnswerRe: How to handle Exceptions in Constructor? Pin
toxcct27-Jun-07 1:44
toxcct27-Jun-07 1:44 
QuestionOn Close Exception Pin
Programm3r27-Jun-07 0:46
Programm3r27-Jun-07 0:46 
AnswerRe: On Close Exception Pin
CPallini27-Jun-07 0:48
mveCPallini27-Jun-07 0:48 

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.