Welcome to Office & SharePoint Pro Sign in | Join | Help
in Search

SUBSCRIBE to Windows IT Pro Magazine & SAVE 30%      FREE Email Newsletters Vista UPDATE, Windows IT Pro UPDATE & More

How to capture windows messages in vc++.net

Last post 03-17-2007, 7:54 AM by pink. 0 replies.
Sort Posts: Previous Next
  •  03-17-2007, 7:54 AM 28258

    How to capture windows messages in vc++.net

    The problem is:
    Windows Message is not returned by WindowProc CALLBACK .Im trying to capture the WM_COMMAND message which is defined in winuser.h.But WindowProc is not returning this message.
     
    Actually i need to capture an Applications new,save,open &close events.All these can be captured only if WindowProc enters into WM_COMMAND case.once this is captured i can trace the wparam value and capture
    the above mentioned application events.

    Note:This problem comes only in .NET VC++ 2003(im currently working in).
    I dont hav any problem capturing the WM_COMMAND message in Native VC++ 6.0!!

    Plz tell me y its not coming in .NET VC++ 2003?
    Please give me a solution for this problem as soon as possible .Its very urgent.
    This is how my code goes:

    LRESULT CALLBACK WindowProc( HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
     LRESULT retval; 
     
     char buf[128];
     sprintf(buf,"%d",uMsg);
    // MessageBox(NULL,buf,"uMsg",0);

     switch(uMsg)
     {
      case WM_COMMAND:
        
       sprintf(buf,"%d : %d",wParam,lParam);
       //MessageBox(NULL,buf,"Art assess",0);
      break;
                    }
     retval = CallWindowProc((WNDPROC)pOldProc, hwnd, uMsg, wParam, lParam);
     return retval; //Default window message...
    }
     

    code snippet where i call this WindowProc:

    void MenuInitialize()
    {
     char buf[200];
     HWND wind;
     wind=GetForegroundWindow();
     SetActiveWindow( wind);
     g->illustratorHWND = GetNextWindow(wind, GW_HWNDNEXT);
     
     SetActiveWindow( g->illustratorHWND);
     pOldProc = SetWindowLong(g->illustratorHWND, GWL_WNDPROC, (long) WindowProc);

     
    }

    Hope u could understand my problem.
    Help me soon.
View as RSS news feed in XML
SPONSORED LINKS FEATURED LINKS

Maximize Your SharePoint Investment: Get Your Data MovingJoin us as we take a look at the complex business of securing, accessing and managing vast amounts of information in a global network and various ways to get your data moving. Order Your Fundamentals CD Today!Get up to speed quickly and learn how to uncover rich information management and deployment capabilities with this free SharePoint CD. Free Technology Resource Directory ListingPost your free listing in this comprehensive directory for IT and developer professionals, powered by Windows IT Pro. But hurry! Deadline ends Oct. 9. SharePoint Conections event returns to Las Vegas Nov 10 - 13Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. It is co-located with Microsoft ASP.NET, SQL Server and Windows Connections with over 250 in-depth sessions. Ease Your Scripting Pains with the Flexibility of PowerShell!Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!