Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2003.01.13;
Скачать: [xml.tar.bz2];

Вниз

Как получить элемент ListBox a???   Найти похожие ветки 

 
Cosmic   (2002-11-24 21:58) [0]

Как получить текст (в смысле значение) выделенного элемента ListBox"a при его выделении? ListBox создан при пом. CreateWindow. В обработке сообщения пишу так:


var
FoldersListBuffer: array [1..255] of Char;
Folders: integer; // handle listbox"a
...
wm_command :
begin
if (lParam = Folders) then
begin
Selection := SendMessage(Folders,LB_GETCURSEL,0,0);
SendMessage(Folders,LB_GETTEXT,Selection,Integer(@FoldersListBuffer));
MessageBoxA(0,PChar(@FoldersListBuffer),"www",0);
end;
...


Выдает два пустых MessageBox"a. Что я делаю неправильно?


 
MBo   (2002-11-24 22:18) [1]

procedure TForm1.LB1Click(Sender: TObject);
var
Buffer: array [0..255] of Char;
Selection:Integer;
begin
Selection := SendMessage(LB1.Handle,LB_GETCURSEL,0,0);
SendMessage(LB1.Handle,LB_GETTEXT,Selection,Integer(@Buffer));
MessageBox(0,Buffer,"www",0);
end;


 
apay   (2002-11-25 00:12) [2]

(из хелпа!)
An LB_GETTEXTLEN message can be sent before the LB_GETTEXT message to retrieve the length, in characters, of the string.
Return Values
The return value is the length of the string, in characters, excluding the terminating null character. If index does not specify a valid index, the return value is LB_ERR.
Remarks
If you create the list box with an owner-drawn style but without the LBS_HASSTRINGS style, the buffer pointed to by the lpszBuffer parameter will receive the 32-bit value associated with the item (the item data).

если пишешь на WinAPI, внимательней с созданием окошек.

2 MBo © (24.11.02 22:18)
если юзать VCL, зачем вся эта бадья?



 
MBo   (2002-11-25 00:18) [3]

>apay
>если юзать VCL, зачем вся эта бадья?
Он неправильно выводил Buffer в MessageBox, поэтому я тестовый пример сделал



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2003.01.13;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.008 c
1-37001
Armageddon
2002-12-27 17:55
2003.01.13
Создание динамического массива


1-37120
Kventin
2003-01-04 13:42
2003.01.13
Проблема с StringReplace


3-36926
Дот
2002-12-17 16:42
2003.01.13
Table corrupt other than header


4-37428
Marko_polo
2002-11-24 07:38
2003.01.13
Нужна Помощь!!!


4-37438
serd_hhc
2002-10-27 09:42
2003.01.13
Как узнать адресс строки в чужом приложении?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский