|
Модераторы: Snowy, bartram, MetalFan, bems, Poseidon, Riply |
|
fishca |
|
|||
Unregistered |
var
lpszText : string; В программе создаю текстовое поле FileNameText := CreateWindowsEx(...); Потом пытаюсь написать SendMessage(FileNameText,20,LPARAM(lpszText)); т.е. пытаюсь получить текст текстового поля, врезультате Access Violation, что не так подскажите пожалуйста! |
|||
|
||||
FdX |
|
|||
Unregistered |
Если мне не изменяет память, начиная с Дельфи 2.0 string очень похож
на LPSZ, но там ещще хранится гдето длина строки. Пиши так: var Text:Array[0..MaxLengthOfYourText] of Char; lpszText:String; дальше пишешь примерно так: SendMessage(FileNameText,20,LPARAM(@Text)); lpzsText:=StrPas(@Text); @Text представляет из себя PChar я это не проверял, но должно работать |
|||
|
||||
Fantasist |
|
|||
Лентяй Профиль Группа: Участник Клуба Сообщений: 1517 Регистрация: 24.3.2002 Репутация: нет Всего: 41 |
Что-то у вас в SendMessage параметров мало.
Ну это не главное. String в Delphi это Ansi строка, а ее начало находиться в первом символе этой строки. SetLength(s,20); SendMessage(Handle,WM_GETTEXT,20,Longint(@s[1])); -------------------- Волны гасят ветер... |
|||
|
||||
rhf |
|
|||
Шустрый Профиль Группа: Участник Сообщений: 51 Регистрация: 13.8.2002 Репутация: нет Всего: нет |
а лучше все делать точно, сначала проверить длину текста
setLength(lpszText,sendMessage(h,WM_GETTEXTLENGTH,0,0)+1); или setLength(lpszText,getWindowTextLength(handle)+1); а затем получить текст sendMessage(h,WM_GETTEXT,wParam(length(lpszText)),lParam(@lpszText[1])); или sendMessage(h,WM_GETTEXT,wParam(length(lpszText)),lParam(pChar(lpszText)); |
|||
|
||||
skinny |
|
|||
Unregistered |
Спасибо пацаны
мне вы очень помогли |
|||
|
||||
Guest |
|
|||
Unregistered |
Хм. Если я не ошибаюсь, то у функции SendMessage 4 параметра, здесь ( "SendMessage(FileNameText,20,LPARAM(lpszText));"
) я вижу только 3 The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately. LRESULT SendMessage( HWND hWnd, // handle of destination window UINT Msg, // message to send WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); Parameters hWnd Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. Msg Specifies the message to be sent. wParam Specifies additional message-specific information. lParam Specifies additional message-specific information. Return Values The return value specifies the result of the message processing and depends on the message sent. Remarks Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function to obtain a unique message for inter-application communication. If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, Windows switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. Как говорится "все это и многое другое" Вы найдете в файле "win32.hlp", там описано все, что связано с Win32 API! |
|||
|
||||
Правила форума "Delphi: WinAPI и системное программирование" | |
|
Запрещено: 1. Публиковать ссылки на вскрытые компоненты 2. Обсуждать взлом компонентов и делиться вскрытыми компонентами
Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, bartram, MetalFan, bems, Poseidon, Rrader, Riply. |
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
0 Пользователей: | |
« Предыдущая тема | Delphi: WinAPI и системное программирование | Следующая тема » |
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |