每次在c ++中创建可见(带图形界面的东西)窗口时,我都希望收到警报。我想过这样的事情:
HWINEVENTHOOK hWinEventHook0 = SetWinEventHook(
EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE,
NULL, WinEventProcCallback, 0, 0,
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
和
VOID CALLBACK WinEventProcCallback(HWINEVENTHOOK hWinEventHook,
DWORD dwEvent, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime)
if (idObject == OBJID_WINDOW && dwEvent == EVENT_OBJECT_CREATE)
{
if (IsWindowVisible(hwnd))
{
// ...
}
}
但它不起作用。因为我观察到通过删除'IsWindowVisible'代码设法捕获所有窗口创建我认为可能在创建时尚未设置可见标记,但我不知道如何继续。