동적으로 다른 창에서 텍스트를 가져 오려고합니다. (해당 텍스트 필드에 텍스트를 입력 한 다음 프로그램을 시작하면 필자가 작성한 내용을 봐야합니다.) getWindowText , 그것은 정적 초기화 된 텍스트 상자를 제공합니다. 그게 문제입니다. 비슷한, 스파이 ++ 않습니다. 가 여기에 내가 무슨 짓을 코드 예제 :동적으로 텍스트를 텍스트에서 가져 오기
#include <Windows.h>
#include <vector>
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
HWND hWnd;
MSG msg;
vector<HWND> a;
hWnd = FindWindow(NULL, "SomeList");
vector<string> phrases;
char p[100];
if(!hWnd)
{
cout << "Window hasn't been found " << endl;
_getch();
exit(1);
}
hWnd = GetWindow(hWnd, GW_CHILD);
while (hWnd !=0)
{
hWnd = GetWindow(hWnd, GW_HWNDNEXT);
GetClassName(hWnd, p, 10);
string k(p);
if(k == "Edit")
a.push_back(hWnd);
GetWindowText(hWnd,p,100);
cout << p << endl;
}
phrases.resize(a.size());
for(auto i = a.begin();i != a.end();i++)
{
int index = 0;
GetWindowText(*i,p, 10);
string n(p);
if(n.size() != 0)
{
phrases[index] = n;
index++;
}
}
_getch();
return 0;
}
실제 문제가 무엇입니까? –
프로그램을 시작할 때 텍스트 상자에 작성한 텍스트를 읽지 않고 정적으로 초기화 된 텍스트를 읽습니다. SetWindowText에 의해 초기화되지 않은 텍스트 필드에서 텍스트를 읽어야하지만, 윈도우에 쓴 텍스트를 사용해야합니다. – Psychoman
창 컨트롤의 첫 번째 자식을 목표로하고 있습니까? 그렇다면 바로 건너 뜁니다. –