ListBox -> DragListBox

P

Peter Hunt

Hi,

I'm trying to change a listbox into a draglistbox so that the items
can be arranged by the user. I found lots of examples on the web,
but all of them are different and since I've just started on C++
I don't really know what way is suitable for my program.

Here's some code :

// This is when the listbos is being called :

set_filterdlg_Hscroll(hDlg,TRUE);

// Next, the set_filterdlg_Hscroll :

// Used by FilterDlgProc() below for setting horizontal
// scroll bar settings.Does this based on the largest filter string.
// If add_flag == TRUE, add all filter strings to listbox also.
void set_filterdlg_Hscroll(HWND hDlg, BOOL add_flg)
{
TEXTMETRIC ftm;
HDC fdc;
int xch,xcaps, largest_filter_str=0, value, index;
char temp_str[256];

fdc = GetDC(hDlg);
GetTextMetrics(fdc, &ftm);
xch = ftm.tmAveCharWidth + ftm.tmExternalLeading;
xcaps = (ftm.tmPitchAndFamily & 1 ? 3 : 2) * xch / 2;
ReleaseDC(hDlg,fdc);

for (index = 0; index < Profile.filters.size(); index++)
{
Build_Filter_String(temp_str, Profile.filters[index]);
if(add_flg)
{
SendDlgItemMessage(hDlg, IDC_FILTERS, LB_ADDSTRING, 0, (LPARAM) ((LPCSTR) temp_str));
}

value = strlen(temp_str); // find largest str for h-scroll
if(value > largest_filter_str) largest_filter_str = value;
}

if(largest_filter_str)
{
value = (largest_filter_str * xcaps);
SendDlgItemMessage(hDlg, IDC_FILTERS, LB_SETHORIZONTALEXTENT,
(WPARAM) value, (LPARAM) 0);
}
else // if no filter strings to work from, set dummy value
{
SendDlgItemMessage(hDlg, IDC_FILTERS, LB_SETHORIZONTALEXTENT,
(WPARAM) 20, (LPARAM) 0);
}
}


I hope this is the right code where the content of the listbox is being build.
Who can tell me how to modify this into drag and drop?

Thanks in advance!

Bye, Peter Hunt (Holland)
 
K

Kevin Goodsell

Peter said:
Thanks for the welcome posting. But are you referring to something
in particular? My English probably isn't as good as most of you here,
but I couldn't find anything irregular...


Here's a few relevant passages:

*************
First of all, please keep in mind that comp.lang.c++ is a group for
discussion of general issues of the C++ programming language, as defined
by the ANSI/ISO language standard. If you have a problem that is
specific to a particular system or compiler, you are much more likely to
get complete and accurate answers in a group that specializes in your
platform. A listing of some newsgroups is given at the end of this post.
**************
A list of some Newsgroups :

Operating Systems
-----------------
comp.os.ms-windows.programmer.win32 MS/Windows: Mice, DLLs, hardware
***************

The point being that your post had nothing to do with the C++ language,
and is completely off-topic here.

Here's some more reading for you:

http://www.slack.net/~shiva/offtopic.txt

-Kevin
 
P

Peter Hunt

The point being that your post had nothing to do with the C++ language,
and is completely off-topic here.

Well, as I told I'm new to programming... Since the code I pasted is
a part of a C++ program, I thought this might be the best place.

But I'll give it a try somewhere else. Thanks anyway.

Bye, Peter.
 
T

Thomas Matthews

Peter said:
Well, as I told I'm new to programming... Since the code I pasted is
a part of a C++ program, I thought this might be the best place.

But I'll give it a try somewhere else. Thanks anyway.




Bye, Peter.

Many C++ programs contain platform specific functionality.
Yours is one. The platform specific functionality is not
discussed in this newsgroup. That functionality is a
Windows Listbox control. Other platforms, such as vending
machines and microwave ovens, don't support Windows
features (have you seen a Listbox on a vending machine?).

We discuss issues with the _standard_ C++ language in
this newsgroup.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top