ChristianS_ | OK, ça fonctionne avec le message TTM_GETTEXT, mais il semblerait qu'il faille passer une zone memoire non protégée par mon thead, pour que le tooltip puisse ecrire les infos dedans.
J'ai adapté un code VB trouvé sur un forum...
C'est bien la premiere fois que j'utilise les VirtualAllocEx et autre OpenProcess... en tout cas ça marche...
Code :
- // hwnd = hwnd du tooltip
- HWND parent=GetParent(hwnd);
- CString title;
- char texte[300];
- SIZE_T tailleEcritLu=0;
- TOOLINFO info;
- memset(&info, 0, sizeof(TOOLINFO));
- info.cbSize=sizeof(TOOLINFO);
-
- DWORD pid=0;
- DWORD id=GetWindowThreadProcessId(hwnd,&pid);
- HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, FALSE, pid);
- LPVOID sharedINFO = VirtualAllocEx(hProcess,NULL,sizeof(TOOLINFO), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
- LPVOID sharedTEXT = VirtualAllocEx(hProcess,NULL,sizeof(texte), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
- WriteProcessMemory(hProcess, sharedINFO, &info, sizeof(TOOLINFO), &tailleEcritLu);
- SendMessage(hwnd, TTM_GETCURRENTTOOL, 0, (LPARAM)sharedINFO);
- ReadProcessMemory(hProcess, sharedINFO, &info, sizeof(TOOLINFO), &tailleEcritLu);
- info.lpszText=(LPSTR)sharedTEXT;
- WriteProcessMemory(hProcess, sharedINFO, &info, sizeof(TOOLINFO), &tailleEcritLu);
- SendMessage(hwnd, TTM_GETTEXT, 0, (LPARAM)sharedINFO);
- ReadProcessMemory(hProcess, sharedINFO, &info, sizeof(TOOLINFO), &tailleEcritLu);
- ReadProcessMemory(hProcess, info.lpszText, texte, sizeof(texte), &tailleEcritLu);
- title=texte;
- VirtualFreeEx(hProcess, sharedTEXT, sizeof(texte), MEM_RELEASE);
- VirtualFreeEx(hProcess, sharedINFO, sizeof(TOOLINFO), MEM_RELEASE);
- CloseHandle(hProcess);
- MessageBox(NULL,title,"titre",0);
|
Message édité par ChristianS_ le 23-11-2005 à 21:06:09
|