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

Вниз

Считать текст с блокнота   Найти похожие ветки 

 
nirvan   (2007-06-05 16:31) [0]

У меня возникла проблема, как можно считать текст с текстового поля блокнота и вывести этот текст, которой находится в текстовой поле в listbox
Заранее благодарен!!


 
homm ©   (2007-06-05 16:35) [1]

Для начала тебе нужно найти окно Блокнота.
Конечно если меется ввиду программа Блокнот, а не TMemo, имеюшая похожую иконку в палитре компонентов.


 
nirvan   (2007-06-05 17:49) [2]

я нахожу сам блокнот с помощью
findWindow("Notepad", "нзваиние документа  ");
потом я делаю следующее
w:=GetWindow(w,GW_CHILD);
GetClassName(w, buff, SizeOf(buff));
getwindowtext(w, buff, sizeof(buff));
что мне не хватает что текст окзался в buff?


 
tesseract ©   (2007-06-05 18:04) [3]


> что мне не хватает что текст окзался в buff?


GetMem(buf) ?


 
nirvan   (2007-06-05 18:22) [4]

нет это не под ходит потому что buff: array [0..127] of char

я буду очень признателен если кто-нибудь даст уже готовый текст проги


 
begin...end ©   (2007-06-05 20:19) [5]

GetWindowText здесь не подойдёт. Используйте сообщение WM_GETTEXT.


 
nirvan   (2007-06-05 21:51) [6]

здесь возникает еще один вопрос,а как правильно  WM_GETTEXT описать в программе(т.е. какие параметры и как их указать и на что эти параметры должны указывать)


 
homm ©   (2007-06-05 22:09) [7]

f1 ?


 
begin...end ©   (2007-06-05 22:10) [8]

var
 Buffer: PChar;
 hEdit, Len: Cardinal;
begin
 hEdit := FindWindowEx(FindWindow("Notepad", "Безымянный - Блокнот"), 0, "EDIT", nil);
 if hEdit <> 0 then
 begin
   Len := SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0) + 1;
   GetMem(Buffer, Len);
   try
     if SendMessage(hEdit, WM_GETTEXT, Len, Integer(Buffer)) <> 0 then
       MyMemo.Text := Buffer
   finally
     FreeMem(Buffer)
   end
 end
end


 
homm ©   (2007-06-05 22:12) [9]

> [8] begin...end ©

Зря ты так, что он тебе сделал :)


 
nirvan   (2007-06-05 22:38) [10]

begin...end большое человеческое спасибо, благодарен тебе за помощь


 
nirvan   (2007-06-05 23:53) [11]

почему begin...end ты использовал не GetWindowText а использовал SendMessage(hEdit, WM_GETTEXT, Len, Integer(Buffer)) ?
почему GetWindowText не подходит?


 
clickmaker ©   (2007-06-06 09:31) [12]


> [11] nirvan   (05.06.07 23:53)

потому что хелп надо читать иногда

However, GetWindowText cannot retrieve the text of a control in another application.
...
If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. This behavior is by design. It allows applications to call GetWindowText without becoming unresponsive if the process that owns the target window is not responding. However, if the target window is not responding and it belongs to the calling application, GetWindowText will cause the calling application to become unresponsive.

To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.

(с) MSDN


 
nirvan   (2007-06-06 14:07) [13]

все спасибо за помощь
Тема закрыта



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

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

Наверх





Память: 0.47 MB
Время: 0.04 c
2-1196019346
outlaw
2007-11-25 22:35
2007.12.23
Диспетчер задач


15-1195595470
Германн
2007-11-21 00:51
2007.12.23
Ещё один вопрос о обновлении Windows


8-1171205709
Daiger
2007-02-11 17:55
2007.12.23
DelphiX проблема


2-1196404505
WestNik
2007-11-30 09:35
2007.12.23
Создание TabSheet динамически


2-1196154909
Quart
2007-11-27 12:15
2007.12.23
массив





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский