Q: Drag and Drop LB using MFC
Mario Contestabile -- Mario_Contestabile.UOS__MTL@UOSMTL2.universal.com Wednesday, September 04, 1996 Environment: MSVC 4.1 Windows 95, Windows NT 3.51 Problem: How to achieve drag and drop in a single sel listbox using MFC? That is, dragging item 1 between items 3 and 4 for example. mcontest@universal.com
Roger Onslow -- Roger_Onslow@compsys.com.au Thursday, September 05, 1996 [Mini-digest: 3 responses] >Problem: How to achieve drag and drop in a single sel listbox >using MFC? That is, dragging item 1 between items 3 and 4 for example. try this class (which is in VC4.1) CDragListBox In addition to providing the functionality of a Windows list box, the CDragListBox class allows the user to move list box items, such as filenames, within the list box. List boxes with this capability allow users to order the items in a list in whatever manner is most useful to them. By default, the list box will move the item to the new location in the list. However, CDragListBox objects can be customized to copy items instead of moving them. The list box control associated with the CDragListBox class must not have the LBS_SORT or the LBS_MULTIPLESELECT style. For a description of list box styles, see List-Box Styles. To use a drag list box in an existing dialog box of your application, add a list box control to your dialog template using the dialog editor and then assign a member variable (of Category Control and Variable Type CDragListBox) corresponding to the list box control in your dialog template. For more information on assigning controls to member variables, see Shortcut for Defining Member Variables for Dialog Controls in Chapter 14 of the Visual C++ User's Guide. #includemcontest@universal.com -----From: kitk@mudshark.sunquest.com (Kit Kauffmann) Several people have been looking for a drag and drop listbox capability. John Grant (yes, THE John Grant) was kind enough to provide a C listbox subclass implementation, and I've encapsulated it into an MFC-compatible class, which you may obtain via ftp at: mudshark.sunquest.com pub/kitk/dragdrop.zip It has absolutely no documentation (I'm getting lazier every day). All you do to use it is create an object of type CDragDropListBox in your dialog class, and use the Subclass method to connect it to the resource-based listbox, as in: CDragDropListBox m_ListBox; // declared in dialog class YourDialog::OnInitDialog() { ... m_ListBox.Subclass( ID_LISTBOX, this ); ... } BTW, the latest version has both LB exchange (drag'n'drop between 2 LB's) and LB re-arrangement as you are looking for. Note that using LBS_SORT with this would probably not yield the expected results :-) Do you need a silencer if you are going to shoot a mime? -----From: Mast-CBT You can see the example CMNCTRLS.MDP in "\msdev\samples\mfc\general\cmnctrls" of your MSVC++ 4.1 NB : this example is contained in MSVC++ 4.0. I think there is in MSVC++ 4.1 too Bye Mast-CBT
| Вернуться в корень Архива |