Thread: Wndproc

  1. #1
    Unregistered
    Guest

    Question Wndproc

    I couldn't understand how WNDPROC(in WNDCLASS) works. How can i make a callback function similar to that? Please advice.

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    267
    You'll have to re-phrase that question to get a decent response

  3. #3
    Raven Arkadon
    Guest
    LRESULT CALLBACK my_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
    switch(msg) {


    }

    return ;
    }



    WNDCLASS wndclass;
    memset(&wndclass, 0, sizeof(WNDCLASS));
    ...
    wndclass.lpfnwndproc = my_wndproc;

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    244

    Angry

    ARGH! i accidently posted the unfinished reply... AND I COULD'NT EDIT IT... >_<

    ok, again:

    //this is your wnd proc
    //whenever your window receives a message, this function will be called (as long as you call DispatchMessage( ... )
    LRESULT CALLBACK my_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
    switch(msg) {
    //handle the message
    }
    }

    return 0; //hm... should we return 0 if we processed the message or if we didn't? --- i am not sure now but you can rtfm
    }



    WNDCLASS wndclass;
    memset(&wndclass, 0, sizeof(WNDCLASS));
    ...
    wndclass.lpfnWndproc = my_wndproc; //every window created with this windowclass will have my_wndproc as it's window procedure.

    so thats how to declare a callback function
    signature under construction

  5. #5
    Unregistered
    Guest
    Thanks, Raven Arkadon.
    I know how to program using the WNDCLASS. I wanna know what's behind the WNDCLASS and WndProc. How can i make a call back function which has the same 'magic' as WndProc?

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Unregistered
    Thanks, Raven Arkadon.
    I know how to program using the WNDCLASS. I wanna know what's behind the WNDCLASS and WndProc. How can i make a call back function which has the same 'magic' as WndProc?
    The WNDCLASS is just a structure of information sent to RegisterClass to allow you to create windows using those styles.....

    The WndProc is a simple call back that can be defined however you want as long as it's declared. You include a pointer to this function in your WNDCLASS

    Code:
    LRESULT CALLBACK my_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
    Meaning a function that recieves 4 32bit params. It returns an LRESULT and as a callback, allows the system to call it....

    That's all that's needed.......the rest you can define yourself

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I wanna know what's behind the WNDCLASS and WndProc. How can i make a call back function which has the same 'magic' as WndProc
    I think that means "how do you use function pointers"...

    Try this site:
    http://www.function-pointer.org/
    Last edited by Hunter2; 08-12-2002 at 07:28 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WndProc Hook - Help
    By Mastadex in forum Windows Programming
    Replies: 0
    Last Post: 05-15-2006, 03:13 PM
  2. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 07:23 AM
  3. deriving a class with a wndproc
    By bennyandthejets in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2003, 07:31 PM
  4. WNDPROC type
    By Garfield in forum Windows Programming
    Replies: 5
    Last Post: 01-17-2002, 10:32 PM
  5. Putting WndProc into a class?
    By Eber Kain in forum Windows Programming
    Replies: 3
    Last Post: 12-13-2001, 06:46 PM