I'm trying to set a wndProc to a block of ruby code because the
wndProc is getting the messages I have to respond to. I have already
created the window and have the message loop going the only problem is
I would like to be able to pass a block of code instead of passing it a
module function.
This code works.
module MyWin32
extend DL::Importable
dlload 'user32.dll' , 'kernel32.dll'
..
..
..
def my_proc(hwnd,uMsg,wParam,lParam)
puts "My proc CALLED MSG = " + uMsg.to_s
defWindowProc(hwnd,uMsg,wParam,lParam)
end
MY_PROC = callback 'UINT my_proc(HWND,UINT,WPARAM,LPARAM)'
end
@wndclass.lpfnWndProc = MyWin32::MY_PROC.to_ptr
This last line is inside the window class and it works but I would
rather be able to pass it a block of code which can call functions
inside the class instead of the function from the module.
I tried this
doIT = lambda {|hWnd,uInt,wParam,lParam|
class_proc(hWnd,uInt,wParam,lParam)
}
@theCallback = DL.callback('IIIII',doIT)
@wndclass.lpfnWndProc = @theCallback
but this doesn't work. I tried adding .to_ptr to the end but
everything I do gives me errors.
This is one of the errors I keep getting
(eval):16:in `[]=': type mismatch (DL::DLTypeError)
from (eval):16:in `lpfnWndProc='
If anyone knows a better way to send Windows messages between ruby and
c programs let me know.