Thread: my wndProc is out of scope

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    Sorry just read this after my last post.

    what you actually want to do is call the function directly as you had done. After that you need to call DefWindowProc to get the default action for messages you don't handle.
    I read it in a book that i should not call the window function directly (e.g. return mf->wndProc(hwnd,message,wParam,lParam); ) because

    This is because a message may require additional processing as it is sent to a window procedure. It also accounts for the fact that only on some platforms, or under some conditions, there may be additional processing required to call a window procedure. In win32, this may involve Unicode translations.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Quote Originally Posted by Raison
    I read it in a book that i should not call the window function directly (e.g. return mf->wndProc(hwnd,message,wParam,lParam); ) because
    The book was talking about the WNDPROC which is static in your case. You aren't calling the static WNDPROC directly when you call the virtual one.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    Sorry about this but i dont understand. That means in my case, i cannot call the static wndProc directly in the static wndProc function itself? I'm lost.

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    what the book was likely suggesting is...


    lets say you want to tell a window that you want it to repaint. You think that you can call the window function with a WM_PAINT message but you can't because it wont work.

    or maybe you want to do some processing that happens when the thing is sized, so you call it with a WM_SIZE message.

    These are the things you shouldn't do. Don't call it directly.

    As for inside of the static or global WndProc function itself, you can certainly call other functions. Your virtual wndProc is not a WNDPROC at all, but a method on the class. Therefore you can most definitely call it explicitly.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    ok thanks for helping me out so far. I still have alot of doubts:

    You mean like if i want to resize the window using its wndProc. I should not call it explicitly, but instead i should use CallWindowProc?
    But i tot i should use SendMessage in this case. Then when should i use CallWindowProc?

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Quote Originally Posted by Raison
    ok thanks for helping me out so far. I still have alot of doubts:

    You mean like if i want to resize the window using its wndProc. I should not call it explicitly, but instead i should use CallWindowProc?
    But i tot i should use SendMessage in this case. Then when should i use CallWindowProc?
    you won't be able to do it that way anyway, but its just an example. Just don't call it directly. don't worry too much about why. Windows just wants to be the only one to call it.

    The real matter here is that your virtual wndProc is not a WNDPROC so you can call it. Change the name if you want it to be less confusing
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    you won't be able to do it that way anyway, but its just an example. Just don't call it directly. don't worry too much about why. Windows just wants to be the only one to call it.
    so when do i actually need to use CallWindowProc and SendMessage. Now i even begin to wonder what difference they have.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM
  5. Putting WndProc into a class?
    By Eber Kain in forum Windows Programming
    Replies: 3
    Last Post: 12-13-2001, 06:46 PM