I couldn't understand how WNDPROC(in WNDCLASS) works. How can i make a callback function similar to that? Please advice.
I couldn't understand how WNDPROC(in WNDCLASS) works. How can i make a callback function similar to that? Please advice.
You'll have to re-phrase that question to get a decent response
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;
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
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.....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 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
Meaning a function that recieves 4 32bit params. It returns an LRESULT and as a callback, allows the system to call it....Code:LRESULT CALLBACK my_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
That's all that's needed.......the rest you can define yourself
I think that means "how do you use function pointers"...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
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.