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;
} |
Partager