Has anyone got a device going with Tcl/Tk? I've spent many days trying to get it working properly and have come to the conclusion that because Windows Tcl/Tk is also waiting on GetMessage, it's probably impossible to write an event loop that works correctly.
I have tried using the tcl event source system but it's not smooth.
I can make this work on a busy loop but I think our customers would probably complain
I'd be pleased to post my code if anyone thinks they could help.
One solution is to modify the event code in Tcl/Tk but this is a pain since we have to support three platforms.
Is it possible to read from a device without using GetMessage? Tcl can wait on sockets and file handles just fine.
thanks for any help!
Andy
Using with Tcl/Tk
Moderator: Moderators
Tcl/TK will support multiple threading but it would make the implementation of this very messy. Tcl/TK waits on GetMessage so you need to wedge in there (using the standard Tcl/Tk notification and event sources is useless in this case).
We have solved the problem like this - I hope this is useful to someone. (this is for Windows Tcl/Tk only)
This will be in our software soon. If you would like to test it before release please contact me - see www.inivis.com for more details on AC3D (3D modelling software)
Andy
We have solved the problem like this - I hope this is useful to someone. (this is for Windows Tcl/Tk only)
Code: Select all
WNDPROC oldWndProc; // old WindowProc function
// the new hook function that's wedged into the window event handler
LRESULT CALLBACK HookWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
check_for_space_mouse_event(msg, wp, lp); // see if it's a space mouse event
LRESULT lr = CallWindowProc(oldWndProc, hwnd, msg, wp, lp); // call the old event handler
return(lr);
}
if (space_mouse_init())
{
Tk_Window tkwin = Tk_NameToWindow(interp, ".", Tk_MainWindow(interp));
Window win = Tk_WindowId(tkwin);
HWND hwnd = Tk_GetHWND(win);
// set the hook proc and record the old
oldWndProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (DWORD)HookWndProc);
}
This will be in our software soon. If you would like to test it before release please contact me - see www.inivis.com for more details on AC3D (3D modelling software)
Andy