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

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. You’ve Deployed SharePoint…Now What?This one-day free online conference delivers the technical knowledge needed to kick MOSS up a notch. In one information-packed day, independent SharePoint experts will present practical, real-world information and provide take-away, ready-to-use solutions 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! Protecting Sharepoint with Double-Take for Windows 5.0Providing SharePoint recoverability is a two step process. Learn those steps now. Vendor protection solutions for SharePoint are incomplete at worst and unreliable at best. So what’s an Administrator to do? Read More… Maximize Your SharePoint Investment This web seminar discusses how true bi-directional replication of SharePoint content from one server to another enables branch offices to maintain access to current SharePoint content.