Ruby DL callback function for a windowProc

A

awertyui

I am trying to create a window class with ruby dl so I can create my
own window but I'm stuck on the wndproc. here is what I have so far
but it doesn't work.
I can get it to work if I use one of the standard window classes like
Button but if I do that then I dont have control over the wndproc which
seems to be getting the messages I am trying to recieve.

There is more to the code I just cut out the parts with the problem.
module Win32
extend DL::Importable
dlload 'user32.dll' , 'kernel32.dll'
WNDCLASSEX = struct [
"UINT cbSize",
"UINT style",
"void* lpfnWndProc",
"int cbClsExtra",
"int cbWndExtra",
"UINT hInstance1",
"UINT hIcon",
"UINT hCursor",
"UINT hbrBackground",
"LPCSTR lpszMenuName",
"LPCSTR lpszClassName",
"UINT hIconSm"

]

def my_proc(hwnd,uMsg,wParam,lParam)
puts "TEST"
end

MY_PROC = callback 'UINT my_proc(HWND,UINT,WPARAM,LPARAM)'
end


#this is the line that the program stops on.
wndclass.lpfnWndProc = Win32::MY_PROC

this is the error
type mismatch
(eval):16:in `[]='
 
T

Takaaki Tateishi

#this is the line that the program stops on.
wndclass.lpfnWndProc = Win32::MY_PROC

Create an PtrData object using to_ptr() and assign it to lpfnWndProc as follows.
wndclass.lpfnWndProc = Win32::MY_PROC.to_ptr()

Regards,
 
T

Takaaki Tateishi

#this is the line that the program stops on.
wndclass.lpfnWndProc = Win32::MY_PROC

Create an PtrData object using to_ptr() and assign it to lpfnWndProc as follows.
wndclass.lpfnWndProc = Win32::MY_PROC.to_ptr()

Regards,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top