Application crashing in window procedure :(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xoinki
    New Member
    • Apr 2007
    • 110

    Application crashing in window procedure :(

    hi all,
    I have a very general question.. My program is crashing in a window procedure...
    the sample code is as follows..

    [code=cpp]
    return CallWindowProc( pccustgrid->m_wporiglistwn dproc, hwnd, message, wparam, lparam);
    [/code]

    this is a window procedure for a listbox.. sometimes it is crashing while editing the listbox.. actually this listbox is a part of customized grid.. if a user presses tab then he can navigate thru the grid.. and edit.

    my question..
    wat may be the reasons an application can crash in a window procedure?

    Thnx for any replies,
    xoinki
    Last edited by JosAH; Aug 10 '07, 07:11 AM. Reason: corrected the code tags: <code> ---> [code]
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The window procedure is just a switch on the message received from DispatchMessage (). Each case is handwritten application code. Just use your debugger and you should be able to see exactly where the crash is occurring.

    Comment

    • Darryl
      New Member
      • May 2007
      • 86

      #3
      CallWindowProc expects a C function (__stdcall) and not a member function.

      If pccustgrid->m_wporiglistwn dproc is actually a static function (which i am guessing it's not) you need to use pccustgrid::m_w poriglistwndpro c assuming pccustgrid is the name of the class and not an instance

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Originally posted by Darryl
        CallWindowProc expects a C function (__stdcall) and not a member function.
        A member function should be OK as long as it is __stdcall (aka WINAPI). Member functions have addresses and can be used as regular functions provided a this pointer is OK for the first argument.

        Comment

        • Darryl
          New Member
          • May 2007
          • 86

          #5
          Originally posted by weaknessforcats
          A member function should be OK as long as it is __stdcall (aka WINAPI). Member functions have addresses and can be used as regular functions provided a this pointer is OK for the first argument.
          No a member functon is Not OK to pass to CallWindowProc.

          Now there are ways to craft a C function to accept and use a this pointer, but in this instance, The first parameter of CallWindowProc already has a set signature and therefore cannot take a member function.

          To the OP: Here is a link that should help you understand how to accomplish what you are trying to do

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            Originally posted by Darryl
            No a member functon is Not OK to pass to CallWindowProc.

            Now there are ways to craft a C function to accept and use a this pointer, but in this instance, CallWindowProc already has a set signature and therefore cannot take a member function.
            You would have thought I would have checked the docs before saying anything. But no. That's twice today. I need more coffee.

            Comment

            Working...