Can a wxWindow dispatch all events (mouse, keyboard) ?
In other words can all events be "wxEvent::Skip"ped
without having to catch all events and skipping in each handler?
If you don't bind a handler for an event then it will be as if you did
and the handler only called event.Skip(). Does this answer your
question?
Yes it does, Thanks for your answer, but I have a more specific one:
Can mouse and keyboard events (recieved by a wx.Window inside a wx.Frame)
be dispatched to a non-wxPython window ?
For example a vendor supplied window that has it's own event handler and
that is embedded into a wxPython window through it's handle.
Yes, sorta. You'll have to translate the events back to Windows
messages and send them to the window yourself.
I have two questions then :
1-How can I send a Windows Message to my vendor supplied window.
2-How do wxPython events translate to Windows messages.
All of the above preferably in my favorite language of course!
Any more specific recommendation or hint would be greatly appreciated !
Question 1:
How can I send a Windows Message to my vendor supplied window?
You can send any message to any window with the PyWin32 extension. You
import the win32gui module which is a wrapper around all sorts of
useful win32 API functions. one of them is Post message. If you know
the HWND numeric value, the message number, and the wParam and lParam
you are all set.
Here is a little program I wrote to fire off windows messages from the
commandline. It shows how it works. All completely in Python!
if __name__ == "__main__":
if len(sys.argv) != 5:
print "USAGE: postMessage.py WINDOW MESSAGE WPARAM LPARAM"
args = [int(i,0) for i in sys.argv[1:5]]
PostMessage(args[0],args[1],args[2],args[3])
Question 2:
How do wxPython events translate to Windows messages.
I don't know a general solution for this. Somewhere in the wxWidgets
source there must be ampping from Windows messages to wxWidgets
events, but I've never looked at that, and I don't think you can get
that mapping programmatically. Is there a limited set of events you
are trying to repost? We could probably figure out the right Windows
message for each event you need.
Yes it does, Thanks for your answer, but I have a more specific one:
Can mouse and keyboard events (recieved by a wx.Window inside a wx.Frame)
be dispatched to a non-wxPython window ?
For example a vendor supplied window that has it's own event handler and
that is embedded into a wxPython window through it's handle.
Yes, sorta. You'll have to translate the events back to Windows
messages and send them to the window yourself.
I have two questions then :
1-How can I send a Windows Message to my vendor supplied window.
Use the win32api or win32gui module and call SendMessage.
2-How do wxPython events translate to Windows messages.
That's the tricky part, there is nothing built-in for doing it. You'll need take the wx event and deduce from its type and other attributes what Windows message and lparam and wparam were actually sent to begin with. You'll probably want to read some of the wxWidgets sources to see how things were translated to begin with, and also get real familiar with MSDN.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!