Bonjour à tous,
J'ai écris un petit programme en C++ qui change la position d'une seule MsgBox en utilisant la fonction : SetWindowsHookEx().
Ce j'aimerais faire ici, c'est que dès que j’exécute mon programme, il y est au moins 10 MessageBox qui s'affichent à des endroits aléatoires sur l'écran de mon ordinateur.Code:
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 #include <windows.h> #include <TlHelp32.h> #include <Shlwapi.h> #include <Psapi.h> LRESULT CALLBACK msgBoxHook(int nCode, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK msgBoxHook(int, WPARAM, LPARAM); DWORD WINAPI messageBoxThread(LPVOID); if (nCode == HCBT_CREATEWND) { CREATESTRUCT *pcs = ((CBT_CREATEWND *)lParam)->lpcs; if ((pcs->style & WS_DLGFRAME) || (pcs->style & WS_POPUP)) { HWND hwnd = (HWND)wParam; int x = rand() % (GetSystemMetrics(SM_CXSCREEN) - pcs->cx); int y = rand() % (GetSystemMetrics(SM_CYSCREEN) - pcs->cy); pcs->x = x; pcs->y = y; } } return CallNextHookEx(0, nCode, wParam, lParam); } int main() { HHOOK hook = SetWindowsHookEx(WH_CBT, msgBoxHook, 0, GetCurrentThreadId()); MessageBoxW(NULL, L"Msgbox | Test", L"MessageBox", MB_SYSTEMMODAL | MB_OK | MB_ICONIFORMATION); UnhookWindowsHookEx(hook); }
Merci de vos réponses!