> > > > #define WIN32_LEAN_AND_MEAN > > > > > > > > #include <windows.h> > > > > > > > > HWND hApp = NULL; > > > > > > > > LRESULT CALLBACK CBTProc(INT nCode, WPARAM wParam, LPARAM lParam) { > > > > if (nCode == HCBT_CREATEWND) { > > > > if (hApp != NULL) PostMessage(hApp, WM_USER+1, 0, 0); > > > > return 1; > > > > } > > > > return 0; > > > > } > > > > > > > > VOID WINAPI SetAppWnd(HWND hWnd) { > > > > hApp = hWnd; > > > > } > > > > > > > > BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { > > > > return TRUE; > > > > } > > > >
> > > > typedef VOID WINAPI (*SETAPPWND)(HWND); > > > > > > > > SETAPPWND SetAppWnd = (SETAPPWND) GetProcAddress(hLib, "SetAppWnd@4"); // hLib étant l'instance de la dll chargée précedemment avec LoadLibrary > > > > > > > > SetAppWnd(wndMain); // wndMain étant le HWND de ma fenetre principale > > > >
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#define WIN32_LEAN_AND_MEAN #include <windows.h> HWND wnd = NULL; UINT msg = WM_USER; LRESULT CALLBACK CBTProc(INT nCode, WPARAM wParam, LPARAM lParam) { if (nCode == HCBT_CREATEWND) { PostMessage(wnd, msg, 0, 0); return 1; } return 0; } VOID WINAPI SetWndApp(HWND hWnd, UINT uMsg) { wnd = hWnd; msg = uMsg; } BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { return TRUE; }
case WM_CREATE: SetWndApp(hWnd, WM_USER+1); return 0; case (WM_USER+1): TrayIcon.hIcon = xKill; lstrcpy(TrayIcon.szTip, "Enragé"); Shell_NotifyIcon(NIM_MODIFY, &TrayIcon); return 0;
#define WIN32_LEAN_AND_MEAN #include <windows.h> static HHOOK hHook = NULL; LRESULT CALLBACK CBTProc(INT nCode, WPARAM wParam, LPARAM lParam) { if (nCode == HCBT_CREATEWND) { return 1; } return CallNextHookEx(hHook, nCode, wParam, lParam); } VOID WINAPI AddHook(VOID) { if (hHook NULL) hHook SetWindowsHookEx(WH_CBT, CBTProc, GetCurrentProcess(), 0); } VOID WINAPI RemHook(VOID) { if (hHook != NULL) UnhookWindowsHookEx(hHook); } BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { return TRUE; }