tags:

views:

26

answers:

1

I'm new to win32 API programming and I try to understand source code of treeview from codeproject.

But I really don't understand this :

BOOL TreeView::DoNotify(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    // blah blah
    HTREEVIEW Selected = (HTREEITEM)SendDlgItemMessage(hWnd,ID_TREE,TVM_GETNEXTITEM,TVGN_CARET,(LPARAM)Selected);
    // halb halb
}

It doesn't work ( Selected is used without initializing) until I declare Selected as global variable.

Thanks for reading this and I need your help .

+2  A: 

TVM_GETNEXTITEM with TVGN_CARET does not use the LParam (So you can just pass NULL). You can verify this by looking at the macro for the same action:

#define TreeView_GetSelection(hwnd) TreeView_GetNextItem(hwnd, NULL,  TVGN_CARET)
Anders