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)
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)