Автор
|
Тема: Editbox
|
Iliya |
опубликован 22-09-2001 14:52 MSK
У меня такой вопрос: у меня есть хэндл окна, я знаю ID editbox'а на этом окне, нужно получить текст из editbox'а. Вот код:char Buff1[0x100]; HWND hwnd; ...................................... hwnd=FindWindow(NULL,"Test"); if (hwnd!=NULL) { GetDlgItemText(hwnd, 1001, Buff1, sizeof(Buff1)); ....................... В буфер ничего не копируется! Объясните, пожалуйста, почему?
|
migel
|
опубликован 22-09-2001 16:41 MSK
Потому что это окно другого процесса.как взять строчку в этом случае есть в MSDN поищи в периодике |
Iliya
|
опубликован 22-09-2001 19:51 MSK
Перекопал MSDN - ничего не нашел. Кстати, ведь заголовок окна получить можно, хоть оно и "чужое"? Объясните, пожалуйста, как выдрать текст? |
zAg
|
опубликован 22-09-2001 20:01 MSK
Очень просто - GetWindowText. (я бывший zAg35) |
Iliya
|
опубликован 22-09-2001 20:15 MSK
2zAg:Ты не прав. Вот текст из MSDN: ...The GetWindowText function copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application. Так что из другого приложения - не выйдет! |
zAg
|
опубликован 22-09-2001 20:24 MSK
А может попробовать непосредственно отправить WM_GETTEXT .Смотри что написано в Remarks для GetWindowText : If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. Может получиться ? |
zAg
|
опубликован 22-09-2001 20:28 MSK
Да ,точно так ! Вот что написано ниже : To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
|
migel
|
опубликован 23-09-2001 17:28 MSK
В MSDN статья называется: "Synamic Runtime objects: Building..." "Microsoft system journal" July 1997. вот код: HWND hwndLV; // hwnd from you want get text DWORD dwProcessId; GetWindowThreadProcessId(hwndLV, &dwProcessId); HANDLE hProcess = OpenProcess( PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, dwProcessId); if (hProcess == NULL) { MessageBox(hwnd, __TEXT("Could not communicate with process"), g_szAppName, MB_OK | MB_ICONWARNING); return; } // Prepare a buffer to hold the text. // Allocate memory in the remote process's address space TCHAR* ptxt = (LV_ITEM*) VirtualAllocEx(hProcess, NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); ::SendMessage(hwndLV, WM_GETTEXT, 4096, (LPARAM)ptxt); TEXT tchText[1024]; ReadProcessMemory(hProcess, ptxt, tchText, 1024, NULL); // Free the memory in the remote process's address space VirtualFreeEx(hProcess, plvi, 0, MEM_RELEASE); // Cleanup and put our results on the clipboard CloseHandle(hProcess); ;;//tchText contain needed text |
migel
|
опубликован 24-09-2001 10:44 MSK
sorry must be TCHAR* ptxt = (TCHAR*) VirtualAllocEx(hProcess, NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); В амбразуре плохо код вбивать да еще и править :-) |
Iliya
|
опубликован 25-09-2001 11:23 MSK
Спасибо всем ответившим, все круто пашет! СПА-СИ-БО!!! |