![]() |
|
|
![]()
|
|
| StrikeTheCore |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 11 Регистрация: 25.5.2006 Репутация: нет Всего: нет |
Hello,
These forums were recommended to me due to a lack of Borland C++ forums in English, so I was hoping I could get an answer here. I have created a TListBox and need to select multiple items for a project. Both MultiSelect and ExtendedSelect are set to true, yet when the program runs only one item can be selected at a time. When dragging mutliple items are selected but on MouseButtonUp all are lost. If you have any insight into why this is happening please let me know. Thanks, Brian |
|||
|
||||
| chwind |
|
|||
|
Шустрый ![]() Профиль Группа: Участник Сообщений: 70 Регистрация: 15.2.2006 Репутация: 1 Всего: 1 |
What events assigned to ListBox. Show your code please
|
|||
|
||||
| StrikeTheCore |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 11 Регистрация: 25.5.2006 Репутация: нет Всего: нет |
I am using OnMouseDown, OnMouseUp, and OnMouseMove. To clarify, what I want is to be able to select multiple items and be able to drag them all in a block to a different position in the list. My code is as follows:
void __fastcall TForm1::MsgTypesMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { AnsiString str; int i = 0; if(dragItem == -1) return; if(Button == mbLeft) { if(dragItem >= MsgTypes->Items->Count) dragItem = MsgTypes->Items->Count-1; MsgTypes->Items->Move(startDragItem, dragItem); for(int count=(startDragItem<dragItem?startDragItem:dragItem); count<=(startDragItem>dragItem?startDragItem:dragItem);count++) { i = 0; str = MsgTypes->Items->Strings[count]; MsgTypes->Items->Strings[count] = AnsiString().sprintf("%03d",msgEnumValues[count])+str.Delete(1,3); str.Delete(1,1); for (i = 0; i < 256; i++) if (mappings[i].AnsiCompare(str)) break; mappings[count] = str; mappings[i] = NULL; } dragItem = -1; startDragItem = -1; } } void __fastcall TForm1::MsgTypesMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TPoint point; point.x = X; point.y = Y; if(Button == mbLeft) { dragItem = MsgTypes->ItemAtPos(point, true); if(dragItem == -1 || dragItem < 2) { dragItem = -1; return; } startDragItem = dragItem; } } void __fastcall TForm1::MsgTypesMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { TPoint point; if(dragItem == -1) return; point.x = X; point.y = Y; if(Shift.Contains(ssLeft)){ dragItem = MsgTypes->ItemAtPos(point, false); if(dragItem > MsgTypes->Items->Count) return; if(dragItem < 2) dragItem = 2; } } The dragItem and startDragItem are both global ints. Also I want to prevent moving the first 2 items, and that is the reason for the addition if statements. Any help with why this is not working is greatly appreciated. Добавлено @ 16:34 I should also say that the actual problem I am having is that when MultiSelect is set to true you can drag the mouse to select multiple items but when the mouse button is released all selections are lost and the first selected item moves to the last selected item (which is correct behavior without multiselect). What I need to do is allow for the user to select a large block, then be able to drag that entire block to a different position. |
|||
|
||||
| chwind |
|
||||
|
Шустрый ![]() Профиль Группа: Участник Сообщений: 70 Регистрация: 15.2.2006 Репутация: 1 Всего: 1 |
It is a working code. I have checked up
cpp file
h file
Only you should finish a code to forbid to move the first 2 elements Has forgotten to tell, elements move the right mouse button. Это сообщение отредактировал(а) chwind - 27.5.2006, 17:20 |
||||
|
|||||
| StrikeTheCore |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 11 Регистрация: 25.5.2006 Репутация: нет Всего: нет |
That worked great and did exactly what I needed.
Thanks a lot. -Brian |
|||
|
||||
![]()
|
| Правила форума "С++ Builder" | |
|
|
Запрещается! 1. Публиковать ссылки на вскрытые компоненты 2. Обсуждать взлом компонентов и делиться вскрытыми компонентами
Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Rrader. |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | C++ Builder | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |