Created
September 29, 2019 17:02
-
-
Save freakboy3742/552fa5dec922b7150de91a4321689791 to your computer and use it in GitHub Desktop.
IMessageFilter on Python.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReference("System.Windows.Forms") | |
import System.Windows.Forms as WinForms | |
class MessageFilter(WinForms.IMessageFilter): | |
__namespace__ = 'System.Windows.Forms' | |
def PreFilterMessage(self, message): | |
print('filter', message) | |
return False | |
class HelloApp(WinForms.Form): | |
def __init__(self): | |
self.textbox = WinForms.TextBox() | |
self.textbox.Text = "Hello World" | |
self.Controls.Add(self.textbox) | |
def main(): | |
form = HelloApp() | |
app = WinForms.Application | |
f = MessageFilter() | |
app.AddMessageFilter(f) | |
app.Run(form) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For those that find this GIST - the problem was identified as pythonnet/pythonnet#965