OK, I don't profess to fully understand this subject yet, but I have to agree with the sentiment that it would be nice to have OnMessage expanded to allow it to be neatly encapsulated in a class.
I know Lexikos has his reservations about the need for such a thing, but for messages such as scrolling (0x114/115) it would be really nice as the HWND passed as the 4th param for OnMessage is not always the HWND of the window you wish to route the scroll message to, and class encapsulation is a nice way to handle this.
For example, when trapping rolls of the mouse wheel, you do not get the HWND of a window. The logical thing to do is find the HWND of the item under the cursor, but this is not always the window to be scrolled - eg if you scroll a window with a child control - as you scroll, the child control may pass under the mouse cursor and so you would get the HWND for the control.
So if you could encapsulate all gui items (controls, guis) into classes, you could easily have the class for non-scrollable gui countrols (eg edit boxes, checkboxes) pass the onscroll message to it's parent.
I have coded this using alternative methods (Classes register themselves with a "Message Handler") but it just makes stuff more complicated.
Would it not be possible to add an optional 4th parameter to OnMessage, like so?
Code: Select all
class c {
__New(){
[...]
; Suggested syntax:
; The extra "this" param specifies what the "hidden this" param passed to OnScroll will be
; And also which object to call the OnScroll method of.
OnMessage(0x114,"OnScroll",, this)
OnMessage(0x115,"OnScroll",, this)
}
}