Hooks problem

Discussion in 'C Programming' started by kid joe, Nov 21, 2008.

  1. kid joe

    kid joe Guest

    Hi,

    I'm trying hooks for the first time and having a bit
    of a nightmare.

    I basically want to trap when other windows are resized,
    moved etc. When i set a WH_CBT hook it runs ok, but never
    seems to execute.

    When i set WH_CALLWNDPROC my machine goes mad and
    i have to reboot, im using VC++6 on win2k bbut had similar experience on
    win95.

    The code im using is below. It looks OK to me, but obviously it isnt!

    Any help would be appreciated.

    Cheers

    Joe



    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
    HWND hWnd;

    hInst = hInstance; // Store instance handle in our global variable

    hWnd = CreateWindow(szWindowClass, szTitle, WS_POPUP|WS_SYSMENU,
    0, -200, ww, hh, NULL, NULL, hInstance, NULL);

    if (!hWnd)
    {
    return FALSE;
    }
    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);

    hhk = SetWindowsHookEx(WH_CBT,CallWndProc,hInstance,0);
    // hhk = SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,hInstance,0);
    theWnd = hWnd;

    return TRUE;

    }

    LRESULT CALLBACK CallWndProc(
    int nCode, // hook code
    WPARAM wParam, // depends on hook code
    LPARAM lParam // depends on hook code
    )
    {
    if(nCode>=0)
    {
    grabit=2;
    }

    return CallNextHookEx(hhk, nCode, wParam, lParam );

    }


    --
    .--------------------.
    | |
    | Good Evening.... | .--.--.
    | | .; .;|;. ;.
    `-------------. ,---' .;_;' `;_;.
    \| ; ;' `; ;
    \ ;;'.--.___.--.`;;
    ;-( o )=( o )-;
    ( `--' | `--' )
    \| . . |/
    ........... . .:::::. . .______
    / . '---` . '\
    .' `. .' \
    | ____,.- . | `.....' | _______ |
    | ,-' \ /|\'' \.-- |
    | / \.'\ /,'. \. - |
    | /| ` `\ / \ |
    | ,/ _ '/ '\ |
    ,-' ,-. |o '
    / '| | | | \
    / ,/| |o | \ `
    | .' | |.' |. \ \
    ________/ .'____|________________________||__`. `__________
    ( \ ) / )
    '-. '-. ( .-` .-`
    '-. .-'--.__. .-.__.--`-. .-`
    '-..' \--' : ~`:=,`- `..-`
    \ .. \\ |`-'|`-, /
    \\\\\\\) | |`-'/.'/
    \)\)\\ `-' `-'
    `
     
    kid joe, Nov 21, 2008
    #1
    1. Advertising

  2. kid joe

    Ben Pfaff Guest

    kid joe <> writes:

    > I basically want to trap when other windows are resized,
    > moved etc. When i set a WH_CBT hook it runs ok, but never
    > seems to execute.
    >
    > When i set WH_CALLWNDPROC my machine goes mad and
    > i have to reboot, im using VC++6 on win2k bbut had similar experience on
    > win95.


    This is Windows-specific, so you will probably get better
    responses if you ask about it in a Windows programming newsgroup.
    --
    "C has its problems, but a language designed from scratch would have some too,
    and we know C's problems."
    --Bjarne Stroustrup
     
    Ben Pfaff, Nov 21, 2008
    #2
    1. Advertising

  3. On 2008-11-21, Ben Pfaff <> wrote:
    >
    > This is Windows-specific, so you will probably get better
    > responses if you ask about it in a Windows programming newsgroup.


    It also looks suspiciously like C++ to me as well.

    --
    Andrew Smallshaw
     
    Andrew Smallshaw, Nov 24, 2008
    #3
  4. kid joe

    Bartc Guest

    "Andrew Smallshaw" <> wrote in message
    news:...
    > On 2008-11-21, Ben Pfaff <> wrote:
    >>
    >> This is Windows-specific, so you will probably get better
    >> responses if you ask about it in a Windows programming newsgroup.

    >
    > It also looks suspiciously like C++ to me as well.


    Probably not; I could understand the code.

    --
    Bartc
     
    Bartc, Nov 24, 2008
    #4
  5. On 2008-11-24, Bartc <> wrote:
    >
    > "Andrew Smallshaw" <> wrote in message
    > news:...
    >>
    >> It also looks suspiciously like C++ to me as well.

    >
    > Probably not; I could understand the code.


    It is possible that this is a C99 program, but if so there are an
    awful lot of typedefs and a misleading reference to classes. I
    suspect it may actually be C+. This is a curious language common
    amongst Windows programmers that uses all the syntactic crud of
    C++ while having the structure of a straight C program. This
    negates any of the benefits of using C++ is the first place.

    --
    Andrew Smallshaw
     
    Andrew Smallshaw, Nov 24, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. U. George
    Replies:
    0
    Views:
    369
    U. George
    Apr 2, 2006
  2. Andrew FPGA
    Replies:
    7
    Views:
    1,157
    stephenmm
    Nov 1, 2008
  3. OtisUsenet
    Replies:
    0
    Views:
    492
    OtisUsenet
    Apr 28, 2006
  4. Gonçalo Rodrigues

    Help on import hooks

    Gonçalo Rodrigues, Nov 16, 2003, in forum: Python
    Replies:
    0
    Views:
    358
    Gonçalo Rodrigues
    Nov 16, 2003
  5. Simon Dahlbacka

    import hooks

    Simon Dahlbacka, Aug 12, 2004, in forum: Python
    Replies:
    0
    Views:
    363
    Simon Dahlbacka
    Aug 12, 2004
Loading...

Share This Page