In the following code we have a CBT hook proc.
Nothing to it. Upon launching a window of interest with the mouse HCBT_ACTIVATE is caught and WindowString is obtained then checked for "The window I want".
We'll call them, Window 1, Window2, and TheWindowIWant.
If I put a breakpoint at the call to CheckWindowString(), I can see 3 windows being created
with the 3rd of the three being the one I am after.
If I remove that breakpoint and let the code rip, only the first two windows are "caught"
Windows 1 and Window 2.
I could not believe it so I put a break and continue breakpoint that printed out the WindowText then continued execution to prove it. It indeed showed that HCBT_ACTIVATE was indeed apparently "missing" the activation of the desired window even though, there it is on the desktop, all nice and activated.
Unless execution is stopped by the breakpoint that window is never seen by HCBT_ACTIVATE and consiquently never acted upon as I wish.
Out of desparation tried Sleep(1000) where the breakpoint was - That didn't work.
HELP! :-)
:Ron
LRESULT CBCRMaster::MyCBTProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(nCode == HCBT_ACTIVATE)
{
CBTACTIVATESTRUCT *cwp = (CBTACTIVATESTRUCT*) lParam;
char WindowString[255];
GetWindowText((HWND)wParam,WindowString,255)
CheckWindowString();
}