CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Can't get window title with HCBT_ACTIVATE

  1. #1
    Join Date
    Jun 2006
    Posts
    148

    [RESOLVED] Can't get window title with HCBT_ACTIVATE

    Hi all,

    i am working on a project of Activity Monitoring and for that i have applied system wide hook using the dll.

    I want to get the window title at the time it gets activated and for that i have applied WH_CBT hook. In the callback procedure i am trying to get the window title with HCBT_ACTIVATE message, but its working for local thread.

    Following is the code to set the hook

    Code:
    hookWindow = SetWindowsHookEx(WH_CBT, (HOOKPROC)InternalWindowHookCallback,g_appInstance,0);
    and following is the code of call back function

    Code:
    static LRESULT CALLBACK InternalWindowHookCallback(int code, WPARAM wparam, LPARAM lparam)
    {
    	if (code < 0)
    	{
    		return CallNextHookEx(hookWindow, code, wparam, lparam);
    	}
    	if(code==HCBT_ACTIVATE)
    	{
    		if (UserWindowHookCallback != NULL && !windowFilter.IsFiltered((int)wparam))
    		{
    			TCHAR szTitle[512];
    			HWND hwnd = (HWND)wparam;
    			GetWindowText(hwnd ,szTitle,512);
    			UserWindowHookCallback(code, wparam, lparam,szTitle);
    		}
    	}
    	return CallNextHookEx(hookWindow, code, wparam, lparam);
    }
    Its working only for the local thread and not globally.

    Thanx for any kind of help.

    Regards,
    Shail2k4
    Last edited by shail2k4; August 26th, 2008 at 07:25 AM.

  2. #2
    Join Date
    May 2008
    Posts
    8

    Re: [RESOLVED] Can't get window title with HCBT_ACTIVATE

    hi Shail2k4, any chance you can update us on how you got WH_CBT to work globally and not just with the local window? I'm running into the same problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)