Bonjour,
J'utilise un hook bas niveau de type WH_MOUSE_LL, et j'ai un problème lorque je cherche a fermer ma fenêtre principale (la souris se bloque). Le petit programme qui suit met en évidence ce problème.
Une idée? Merci
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0501
#include<windows.h>
#include<tchar.h>
HINSTANCE hinst;
HWND hmain;
TCHAR szappname[] = _T("ACHANGER");
HHOOK hHook;
LRESULT CALLBACK AppWndProc(HWND hwnd, UINT mssg, WPARAM wParam, LPARAM
lParam)
{
switch(mssg)
{
case
WM_DESTROY:
PostQuitMessage(0);
return
0;
}
return
DefWindowProc(hwnd, mssg, wParam, lParam);
}
DWORD __stdcall InitInstance()
{
WNDCLASSEX wndcls;
memset(&wndcls, 0, sizeof(WNDCLASSEX));
wndcls.cbSize = sizeof(WNDCLASSEX);
wndcls.lpfnWndProc = AppWndProc;
wndcls.style = CS_HREDRAW | CS_VREDRAW;
wndcls.hInstance = hinst;
wndcls.lpszClassName =
szappname;
wndcls.hbrBackground = (HBRUSH)
GetStockObject(WHITE_BRUSH);
wndcls.hCursor = LoadCursor(0, IDC_ARROW);
if(!RegisterClassEx(&wndcls))
return 0;
hmain = CreateWindowEx(0,
szappname, szappname, WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hinst, 0);
return
(hmain != 0);
}
LRESULT CALLBACK MouseProc(int nCode,
WPARAM wParam, LPARAM lParam)
{
return
CallNextHookEx(hHook, nCode, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE
hInstance, HINSTANCE x, PSTR y, int z)
{
MSG msg;
hinst = hInstance;
hHook =
SetWindowsHookEx(WH_MOUSE_LL, MouseProc, hInstance, NULL);
if(!InitInstance())
return 0;
ShowWindow(hmain, SW_NORMAL);
while(GetMessage(&msg,
NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
_____________________________________
Un éditeur de ressources gratuit pour Windows