mhammond / pywin32

Python for Windows (pywin32) Extensions
4.92k stars 785 forks source link

Removed Windows message hook #936

Open ghost opened 19 years ago

ghost commented 19 years ago

This is an EXPERIMENTAL patch. It could break existing applications.

One major change is that the default message handler is no longer called always as the HookMessage help page tells you. This is required sometimes (when handling WM_GETMINMAXINFO for example). In those cases use something like this: res = self.WindowProc(message, wParam, lParam). Another change is that now the value returned by your Python handler will be passed back to Windows. So please return an integer (usually 0) as required by the specific message you handle. Not returning an integer still works, through.

Detailed changes:

Added pResult parameter to Python_check_message in which it puts the handler return value. Made old CPythonWndFramework::WindowProc a special case of a new one which now dispatches messages to the Python handlers and deletes associations on WM_NCDESTROY. Disabled message hooking in HookWindowsMessages and message processing in Win32uiPreTranslateMessage. PyCWnd::DoKillAssoc now checks if the window was already detached before calling UnsubclassWindow. For an unknown reason this is necessary after the changes above. Added PyCWnd.WindowProc method which calls the underlying MFC one. Fixed Python_OnCmdMsg to not call the command handler if pHandlerInfo != NULL.

Reported by: adalx

Original Ticket: "pywin32/patches/62":https://sourceforge.net/p/pywin32/patches/62

ghost commented 19 years ago

against build 203

Original comment by: adalx