Je te mets un exemple intercepte messages souris pour tooltips sur dialogbox, tu adapteras.
Et en sortie: UnhookWindowsHookEx(g_hhk);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
MSG *lpmsg;
lpmsg = (MSG *) lParam;
if(nCode < 0 || !(IsChild(g_hwndDlg, lpmsg->hwnd)))
return (CallNextHookEx(g_hhk, nCode, wParam, lParam));
switch (lpmsg->message) {
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
if(g_hwndTT != NULL) {
MSG msg;
msg.lParam = lpmsg->lParam; msg.wParam = lpmsg->wParam;
msg.message = lpmsg->message; msg.hwnd = lpmsg->hwnd;
SendMessage(g_hwndTT, TTM_RELAYEVENT, 0, (LPARAM) (LPMSG) &msg);
}
break;
default: break;
}
return (CallNextHookEx(g_hhk, nCode, wParam, lParam));
}
BOOL CALLBACK EnumChildProc(HWND hwndCtrl, LPARAM lParam)
{
TOOLINFO ti;
char szClass[64];
GetClassName(hwndCtrl, szClass, sizeof(szClass));
if(lstrcmpi(szClass, "STATIC")) { // Skip static controls.
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND; ti.hwnd = g_hwndDlg;
ti.uId = (UINT) hwndCtrl; ti.hinst = 0;
ti.lpszText = LPSTR_TEXTCALLBACK;
SendMessage(g_hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
}
return TRUE;
}
ICI est appele par WM_INITDIALOG
BOOL DoCreateDialogTooltip()
{
g_hwndTT = CreateWindowEx(0, TOOLTIPS_CLASS, (LPSTR) NULL,
TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, g_hwndDlg, (HMENU) NULL, m_hinst, NULL);
if(g_hwndTT == NULL) return FALSE;
if(!EnumChildWindows(g_hwndDlg, (WNDENUMPROC) EnumChildProc, 0)) return FALSE;
g_hhk = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, (HINSTANCE) NULL, GetCurrentThreadId());
if(g_hhk == (HHOOK) NULL) return FALSE;
return TRUE;
}
BruNews, ciao...
-------------------------------
Réponse au message :
-------------------------------
>
>

Curator68

> Ce serai possible d'avoir des précisions sur SetWindowsHookEx().
> thx
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Une dialogbox a un comportement particulier. Pour intercepter events clavier, soit tu sous classes les controles de dialogbox, soit tu installes un SetWindowsHookEx() dans WM_INITDIALOG et bien l'enlever quand boite se detruit.
> > BruNews, ciao...
> >
> >
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > >

Curator68

> > >
> > > J'ai besoin d'aide en ce qui concerne les évènements clavier WM_KEYUP, WM_KEYDOWN et WM_CHAR.
> > > j'arrive pas à intercepter ces évènements dans une boîte de dialogue modale.
> > >
> > > merci d'avance.
> >
>