Bonjour,

Je cherche à accèderr aux textes des ToolTips à partir des handles de fenêtres. J'aimerais bien au final coder l'ensemble en VBA, mais je ne doute pas avoir davantage de changes sur un forum de C++.

Je me perds un peu concernant les messages (WM_NOTIFY,..), les structures (NMHDR, NMTOOLTIPSCREATED qui semble contenir un pointeur vers le handle de la fenêtre ToolTip,...) et les notifications (NM_TOOLTIPSCREATED,..) qui pourraient être utilies.

Ci-dessous le bout de code que j'ai composé au gré de mes recherches sur internet (n'étant pas un expert en C++ ) où j'ai créé un p'tit formulaire sous Excel en VBA avec un bouton ayant un ToolTip en guise de cobaye :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <windows.h>
#include <tchar.h>
#include <commctrl.h>
#include <iostream>
#include <string>
 
int main()
{
 
	HWND hwndParent;
	HWND hwnd;
 
	//UserForm créé sous Excel en VBA avec un simple CommandButton contenant un ControlTipText
	hwndParent = FindWindow(L"ThunderDFrame", L"UserForm1"); 
 
	hwnd = FindWindowEx(hwndParent, NULL, NULL, NULL);
 
	std::wcout << "hwnd = " << hwnd << " and hwndParent = " << hwndParent << std::endl;
 
	TCHAR className[255] = _T(""); 
 
	GetClassName(hwnd, className, 255);
 
	std::wcout << "claaName = " << className << std::endl; // -> "F3 Server 33180000"
 
	std::wcout << "GetDlgCtrlID(hwnd) = " << GetDlgCtrlID(hwnd) << std::endl; // -> 0 (il me semble que ça correspond à une erreur, sans pour autant être sûr)
 
	std::wcout << "GetWindowLong(hWnd, GWL_ID) = " << GetWindowLong(hwnd, GWL_ID) << std::endl; // -> 0 aussi
 
	/*-------------------------------------------------*/
 
	NMHDR nmh;
	nmh.code = NM_TOOLTIPSCREATED; //Arithmetic overflow...
	nmh.idFrom = GetDlgCtrlID(hwnd); //UNIT_PTR
	nmh.hwndFrom =hwndParent;
 
	std::wcout << "SendMessage = " << SendMessage(hwndParent, WM_NOTIFY, nmh.idFrom, (LPARAM)& nmh) << std::endl;
 
	//...
 
	/*-------------------------------------------------*/
 
  	system("pause");
 
	return 0;
}
Pouvez-vous m'aider à ce sujet ?

Merci par avance !