6.4 Windows Common Controls

Microsoft Visual C++/Microsoft Foundation Classes


6.4. Windows Common Controls (a.k.a. Windows 95 controls)

6.4.1. Can I use these controls under NT or Win32s?

Windows NT 3.50 does not support the common controls, and will not in the future. You must use Windows NT version 3.51 to gain the common controls.

[email protected], mfc-l, 7/6/95

Version 1.30 of Win32s supports the Common controls.

6.4.2. Where's a demo of these wickedly cool controls?

Check out the MFC sample, fire, it features most of the controls in action: MSVC20\samples\mfc\fire. Under 4.0, there's another one called cmnctrls.

[email protected], 7/27/95

6.4.3. How do you handle NM_DBLCLK for a CListCtl?

BEGIN_MESSAGE_MAP(CListView, CView)
    ON_NOTIFY( NM_DBLCLK,ID_LISTCTRL,OnDblClick )
END_MESSAGE_MAP()
void CListView::OnDblClick(NMHDR* /*k*/, LRESULT* /*j*/)
{
    int nItem, nFlags;
    char szTest[80];
    nFlags = LVNI_SELECTED;
    nItem = m_ListCtrl->GetNextItem(-1, nFlags );
    if ( nItem != -1 )
    {
        sprintf( szTest, "Selected Item %d", nItem);
        AfxMessageBox(szTest);
    }
}

[email protected], mfc-l, 7/21/95

6.4.4. Does CTreeCtrl support multiple selection?

No. Sorry! (I see this one all the time!)

[email protected]

If it's accessible to you, Microsoft Systems Journal, July 1994, has an extensive look at TreeViews, including a sample program that includes drag & drop. If you're developing for Windows 95, you don't need a shareware implementation, MFC has a class for it.

[email protected]

6.4.5. When I expand a node in my CTreeCtrl, there's no visual feedback, what to do?

Create the control with TVS_SHOWSELALWAYS style.

[email protected]

6.4.6. (The FAQ of the devil!) How do I implement multiple selection, tooltips, editable nodes and multiple columns in my tree control?

Unfortunately, since the tree control lives in a binary DLL, it is not very extensible and you are stuck without these features. There have been articles on how to try and "hack" these features, but they do not work reliably.

We have a drop-in tree control replacement that implements all of these features and more in Objective Toolkit. Demos are at http://www.stingray.com.

NEW!! 6.4.7.  How do I tell a CListCtrl object to select the whole line and not just the left column,  when you click on an item?

The easiest way of getting full row select is if you use the updated common controls DLL (versions >= 4.70) supplied with IE.  With that you can use the LVM_SETEXTENDEDLISTVIEWSTYLE message to set the LVS_EX_FULLROWSELECT style.

mfc-l, 6/21/98

NEW!!  6.4.8.  How do you turn off the sliding animation that happens when a TreeCtrl is expanded or collapsed?

I have used LockWindowUpdate() and UnlockWindowUpdate() in the past to achieve what you are asking using a CListCtrl. The functions are in CWnd and since CTreeCtrl is derived from CWnd this should work the same.

Ted Dasler [ [email protected] ], mfc-l, 6/19/98

NEW!! 6.4.9.  When implementing drag/drop operations, how do you get the different cursors: copy, shortcut, circle with the slash, etc. ?

I believe you want to override the OnDragEnter() and OnDragOver() methods. Returning DROPEFFECT_NONE will give you the circle with a slash. DROPEFFECT_LINK will give you the arrow. DROPEFFECT_COPY will give you the plus sign. 

Cary Walker [[email protected]], VCPP mailing list, 6/29/98