To establish an event handler, you use the setHandler() routine. This links together
three things: A control, an Event Type, and a Routine that you write.
Example:
setHandler(okButton, w32HClick, routine_id("myClickHandler"))
The event handler routine that you write is always passed three parameters:
integer self This is the id of the control that triggered the event.
integer event This is the Win32lib code for the event type that was
triggered.
sequence parms This is zero of more parameters that are specific to
the type of event being triggered.
A given event handler can be shared by many controls. In this case, you can use the self and event parameters to determine your actions.
procedure myClickHandler(integer self, integer event, sequence parms) if self = okBtn then . . . else . . . end if end procedure setHandler({okBtn,cancelBtn}, w32HClick, routine_id("myClickHandler"))
This is an optional routine that if defined, must be a global routine
in your Win32Lib application. It is used by the include file w32start.ew
It is called by Win32Lib when the library needs some details from the application.
see setCallback for more details.
Example:
procedure AppCallback(integer self, integer event, sequence parms) if event = w32HGetHandler then -- parms[1] is the standard routine handler name -- in the form_ -- eg. Click_PushBtn -- parms[2] is the event code to be handled -- eg. w32HClick -- parms[3] is the control's name if match("About", parms[3]) then returnValue(routine_id(parms[1])) else -- Non standard naming returnValue(routine_id("menu_item_selected" )) end if end if end procedure
See Also: closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
You can set a handler to trap the close of the main window if you have any last minute activites to do, such as closing databases, etc...
Example:
procedure Click_CloseBtn(integer self, integer event, sequence parms) if message_box("Is it okay to stop now?", "Close", MB_YESNO) = IDYES closeApp() end if end procedure setHandler(CloseBtn, w32HClick, routine_id("Click_CloseBtn"))
See Also: AppCallback, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
id is usually zero, meaning that events for all controls are processed, however you can limit this to a particular control by supplying it id.
Typically this is used inside user written event handlers when they know that they might take a long time to complete. For example, if by clicking a button the application must scan through all the files on a disk, it would be appropriate to include a doEvents() call inside the inner loop so that other windows events can be processed during the file search. If this isn't done, no control or window belonging to the application will respond until the disk scan is conpleted. For example, there might be another button that the user can click to abort the disk scan. Without doEvents() this would only respond after the disk scan is completed!
See Also: AppCallback, closeApp, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
id is the ID of the control that the event applies to.
htype is the type of event being handled.
Example
object hl -- Make sure my handler is installed before any others. hl = getHandler(myWindow, w32HPaint) -- Chain mine to the front. setHandler(myWindow, w32HPaint, -1 & routine_id("mypainter") & hl)
See Also: AppCallback, closeApp, doEvents, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
This is used by advanced users. It can be used to determine the triggering event for the current event handler. For example, you can use this to find out if a w32HClick event was triggered by a keypress or a mousepress. Or if a paint event was triggered by a scroll action or not.
What this returns depends on the option value.
This returns an empty list if there are no windows messages being processed.
Example:
sequence msg msg = getLastMsg( "" )
See Also: AppCallback, closeApp, doEvents, getHandler, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
Example:
object rv -- Set a return value if not already set. rv = getReturnValue() if not sequence(rv) then returnValue(-1) end if
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
the handler, zero otherwise.
Example:
object rv -- Simulate a button press on the Close Button. rv = invokeHandler(btnClose, w32HClick, {}) if not sequence(rv) then closeWindow(mainWin) end if
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
This is an optional routine that you can define in your application. If you
do, it is called by the include file w32start.ew just prior to passing
control to Windows.
It is passed the output of the command_line() routine.
If it returns a zero, then the application will start up. Anything else
will cause the application to abort.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
By default, the library supports the onXXX syntax but this will change with version 0.70. From then, the default will be not to support this interface and then you will have to explictly turn it on via this function.
Support for the onXXX syntax will be removed from the library from version 1.0 onwards.
Note: Using onXXX support is much slower than using the setHandler() syntax.
If you choose to turn onXXX support off, you must use setHandler() and all your onXXX[] routine_ids will be ignored.
Also note that any call to setHandler will turn off onXXX support. So if you need to mix both syntaxes, you must call onXXX(1) after your last setHandler() call.
Example:
integer lOld -- Turn off onXXX support. lOld = onXXX (w32False)
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
id is one or more control IDs.
htype is one or more event types.
routine is one or more routine_ids previously set for the control-event combinations
in the previous parameters.
You use this routine to get rid of a handler that had been established earlier.
Example:
removeHandler( {Btn1, Btn2}, w32HClick, routine_id("CommonHandler"))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
Example
resetReturnValue()
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
This allows you to override the value an event handler returns to Win32. By default, when an event is processed, it goes through these steps:
Setting returnValue causes processing to stop at the step that the value was set in, and return that value to Windows.
Example:
-- prevent Button1 from seeing any space bar keys procedure Button1_KeyDown( integer self, integer event, sequence parms) integer keycode integer shift keycode = parms[1] shift = parms[2] if keycode = VK_SPACE then -- set return value returnValue( w32True ) end if end procedure setHandler( Button1, w32HKeyDown, routine_id("Button1_KeyDown"))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
routineID is either -1 or a valid routine id.
This sets the application's callback routine id and returns the old
value.
The application may call the callback routine for a number of reasons
during the running of a program. It is mainly used to get information
needed by Win32Lib that it has not received so far.
The callback routine must be a procedure that takes three parameters:-
integer self
integer event
sequence data
The contents of the parameters passed to the callback routine depend on
the value of the event parameter.
When event = w32HGetHandler is called when Win32lib needs an event handler
to be associated for a specific control's event. This comes about when using
the "events=..." parameter in the newUIObj routine./n
The data contains three values...
[1] A string in the form <eventname>_<controlname>, eg. "Click_OkayBtn"
[2] An integer with the symbolic event code, eg. w32HClick
[3] A string containing the control's name.
And the self parameter contains the control-id for the control needing
the handler routine.
Example
integer oldrtn oldrtn = setCallback(routine_id("AppCallback"))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
The Windows Default Processing routine is called whenever a message is received for a control
that Win32lib does not explicitly handle. Win32lib will pass a number of parameters to
this routine.
Example:
function MyDefaultProc(integer id, integer pSource, atom hWnd, atom iMsg, atom wParam, atom lParam) atom lResultif (id = 0) or (pSource = kMainMsg) then lResult = w32Func( xDefWindowProc, { hWnd, iMsg, wParam, lParam } ) else lResult = w32Func( xCallWindowProc, { mySubProc, hWnd, iMsg, wParam, lParam } ) end if
return lResult end function VOID = setDefaultProcessing(routine_id("MyDefaultProc"))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
There may be situations in which the Windows Message handler loop, built into Win32lib, is not adequate for your needs. If so, you can call this function to supply an alternative message handler.
NewId is the routine_id of your routine that will be called by Win32lib to process Windows Messages.
UserData can be anything. It is passed back to your routine by Win32lib on each call. Win32lib does not alter it at anytime.
Win32lib calls the message handler from within the MainWin() routine to begin processing
messages received from Windows. It also calls it when you use openDialog(). The replacement
message handler will receive the UserData value every time it is called by Win32lib.
Example:
integer OldHandler procedure myMsgHandler(sequence Parms) . . . your code goes here . . . end procedure OldHandler = setEventLoop( routine_id("myMsgHandler"), {})
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
id is the ID of the control that the event applies to.
htype is the type of event to trap.
routine is the routine_id of the user written code that will handle
the event.
Note that id can be a sequence of ids. You would do this if they all
shared the same handler code.
Note that htype can be a sequence of event codes. You would do this
if the same handler code is to be invoked for different events.
Note that routine can be a sequence of routine_id() values. You
would do this to set a chain of routines that are triggered for each
event listed in htype.
This routine actually adds the handler's routine_id to the end of a list
of such routines for this ID and Event combination. This way, you can
chain together independantly written routines to fire for the same
id and same events.
A special note. To remove the current chain, set routine to -1. To clear the existing chain before setting a new one, you can also pass routine as {-1, routine_id("myhandler")}
How the Event Handler subsystem works
The Win32lib library receives various events notifications from Windows.
If an event handler has been set up for the specific control-event
combination, the library invokes the user written routine before
continuing. Each event handler is a procedure that is passed three
parameters by the library.
1) integer ID. The control id that the event applies to.
2) integer Event. The event code that invoked this routine. This
enables a single routine to handler multiple event types.
3) sequence Params. This is a list of zero or more parameters
associated with the specific event. For example, a w32HKeyDown event will
have the keycode and shift mask in these parameters.
Example
-- Set a single routine to be triggered by one type of event. setHandler(myWindow, w32HPaint, routine_id("repaintWindow"))-- Set the same handler for two different buttons. setHandler( {btn1, btn2}, w32HClick, routine_id("click_buttons"))
-- Set the same handler for two different events. setHandler( btn1, {w32HClick, w32HKeyPress}, routine_id("click_buttons"))
-- Set a chain of handlers. setHandler( btn1, w32HClick, routine_id("click_buttons")) if DebugSwitch = w32True then -- add a second routine to be called. setHandler( btn1, w32HClick, routine_id("Debugger")) end if
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
newvalue is either w32True or w32False
The initial setting is w32False, meaning that w32HIdle is not invoked
when the application is idling. To start having this handler invoked,
you need to setIdle(w32True).
example
integer x x = setIdle(w32True)
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
There are three parameters used to detect a mouse click event. These are
By using this function, you can set any, all, or none of these parameters. To not set a parameter, you must use an empty sequence in its place.
example:
-- Set the time to 1.5 seconds, and the Y tolerance to 5 pixels. -- Leave the X tolerance as it is. curval1 = setMouseClick( 1.5, {}, 5) -- Double the X tolerance, leaving the others alone. curval2 = setMouseClick( {}, curval1[2] * 2, {})
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
pMsg is the Notification Message code for which you are setting the
handler.
pRtnId is the routine_id() of your function that handles the message.
Your routine is passed four parameters:
sequence alldata integer oldval integer SORT_BY SORT_BY=0 alldata = getDataItems()function CS_byElement(sequence s1,sequence s2) return compare(s1[SORT_BY],s2[SORT_BY]) end function
constant ByElement=routine_id("CS_byElement")
function mylvclick(integer id, atom hWnd, atom wParam, atom lParam) integer lColumn, lOwner
id = getId( w32fetch( lParam, NMHDR_hwndFrom )) if id != 0 then lColumn = w32fetch( lParam, NMLISTVIEW_iSubItem ) + 1 SORT_BY=lColumn alldata=custom_sort(ByElement,alldata) VOID = sendMessage(id,WM_SETREDRAW,0,0) loadLVInfo(id, alldata) VOID = sendMessage(id,WM_SETREDRAW,1,0) end if
return kMainMsg end function oldval = setNotifyHandler( LVN_COLUMNCLICK, routine_id("mylvclick"))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
Use this to set up a handler to directly deal with a
Windows message prior to win32lib processing it.
This is really only used by experienced Windows coders as it
must deal with all the low-level detail itself.
id can be either a single control Id or a list of them.
pMsg can be either a single Windows message code or a list of them.
The pRtnId is a routine_id of some code of yours which must
be a function that receives these parameters ...
Note that if pRtnId is -1 then this removes a previously set message handler.
Example:
function myhandler(integer pSource, atom hWnd, atom iMsg, atom wParam, atom lParam) if wParam = VK_ENTER then if iMsg = WM_KEYDOWN then ... else -- WM_KEYUP ... end if end if return {0} end function setWinMsgHandler( myFld, {WM_KEYDOWN, WM_KEYUP}, routine_id(myhandler))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
This opens the main window, setting focus on the first 'focusable' control and then handles over control to Windows.
The CallbackRtn parameter is either a single routine_id or a list of three routine_ids.
If it is a single routine_id is can be either w32NoCallBack or the routine id
of a callback routine inside your application. See setCallback for more
details.
If CallbackRtns is a list of three routine_ids, it takes the format of ...
Example:
startApp({routine_id("AppCallback"), routine_id("LocalCallback"), routine_id("AppMain")})
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
return INTEGER: A win32lib control id. ZERO if it fails.
Id is a sequence {ControlType, ParentID}
hWnd is the Windows Handle to the control.
Example
-- Use an edit fld that was created outside of win32lib as if it was -- a normal win32lib control. newid = subClassControl( {EditText, myWindow}, winhandle)-- Use an external bitmap as if it was a pixmap. bmh = loadBitmapFromFile("..\\demoresources\\java.bmp") myPixMap = subClassControl({Pixmap, 0}, bmh) setPenColor(myPixMap, Cyan) drawRectangle(myPixMap, 1, 0, 0, 40, 40)
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
This is typically triggered by WinMain, or openWindow. It differs from w32HOpen in that it is triggered after a window is opened but before control is returned to your application.
Typically, code that is run at this point does a setFocus or other initialization..
This event is only triggered for a Window.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { atom winmsg, atom wParam, atom lParam, atom lWinReturn }
After the message is processed by the Windows, Win32lib, and any event handlers, this is triggered.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {integer keyCode, integer shift}
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
The contents of parms varies with the type of control. Note that they are only available when using the setHandler() interface.
For the List and Combo family of controls the parms are ...
{ Event qualifier (integer), Index of affected item (integer) }
Note that the event qualifier is always 'w32CHG_Sel' at this stage.
For ListView the parms are ...
For MonthCalendar the parms are ...
if the event is invoked by a date change cuased by pressing one of the
prev/next buttons or by paging up/down etc, then the parms are an empty
sequence.
If the event is invoked by an explicit date or date range being clicked then
the parms returns two dates.
Note, for Combo box controls, this is triggered when either the edit box area has been changed by the user, or when the list item selection is about to change. If the user is editing the edit box area then getText will return the current value of the edit box, but if this event was triggered due to the user selecting a new item, getText will return the previously selected item and you must use getItem(id, 0) to retrieve the new selection value.
To determine the new value of the control, use the appropriate function - getText, isChecked, getIndex etc.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { }
This event is triggered when a PushButton, CheckBox or TabItem is clicked, or by a MenuItem selection.
It is not the same as a Mousedown event. For a click to happen, the left mouse down and up events must be in the same control, be no more than 2 pixels from each other, and the up event must be within a double-click period of the down event.
The use of accelerator keys, generates a mouse click event.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
This typically occurs via closeWindow, although the user can select the close control on the window as well.
Closing a window does not actually destroy it (unless it is the main window; the window is merely hidden. Refer to closeWindow for more details.
If the onClose routine calls returnValue() with a non-zero parameter, win32lib aborts the Close operation, as if it hadn't been invoked. In this way it is possible to do a conditional close.
This event is only triggered for a Window.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms is { eventqual, index }
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
This is triggered when destroy() has been called and before the control is actually destroyed. It is designed for the application to perform any cleaning up that might be required.
If the event handler return -1, then the control is not destroyed. This enables the application to prevent a control from being destroyed.
Note, when the main window is closed, the destroy routine is called automatically as well.
procedure onDestroy_MsgWnd(integer self, integer event, sequence parms) -- Don't allow it to go until the messages have been -- acknowledged by the operator. if vMsgAcknowledged = w32False then returnValue(-1) end if end procedure setHandler(MsgWnd, w32HDestroy, routine_id("onDestroy_MsgWnd"))
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { integer id, sequence data }
This is triggered by the user dragging and dropping a file or a ListView
or TreeView item onto a control or window.
If id is zero, then windows is dropping one or more files onto the
control or window. In this case, the handler is called multiple times:
In the first call, data contains one integer. This is the number of
files about to be passed to your handler routine.
Then your handler routine is called once per file being passed.
The final call to the handler is when data is an empty sequence. This
signifies that no more files will be passed.
For example, the following code adds the name of the files to TheList.
integer vFileCount procedure dropped( integer self, integer event, sequence parms ) if parms[1] = 0 then if length(parms[2]) = 1 then -- Opening call, the file count. setEnable(actionButton, w32False) eraseItems(TheList) vFileCount = parms[2]elsif length(parms[2]) = 0 then -- Final call. setEnable(actionButton, w32True)
else -- add the file name to the list addItem( TheList, parms[2] ) end if end if end procedure setHandler(TheList, w32HDragAndDrop, routine_id("dropped"))
If id is not zero, then it is the Win32Lib id of the control from which items have been dragged. The second parameter is a sequence of the item id's.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
This can be used to dynamically load the values into a combobox.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { atom winmsg, atom wParam, atom lParam }
Before the events are processed by any of the trap routines or default Windows routines, the w32HEvent is triggered.
If you want to skip the default Windows processing of the winmsg, pass a value to the returnValue() routine.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
Focus means that keyboard events are directed to that control. Static controls (such as LText) cannot get focus.
When a Win32Lib window gets focus, it will give focus back to the last control in the window that had focus. If there are no controls in the window that can recieve focus, the focus will remain with the window.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {integer Counter, atom MsgAddr}
Your application will only start getting these events once you have called setIdle(w32True).
The Counter starts at 1 for each time the handler is invoked after the Windows Message Queue becomes empty again. That is, this handler will be invoked repeatedly, while there are no messages to be processed. You can tell when you application becomes idle when the Counter value is 1. Values higher than 1 indicate that the application is still idle. When the application becomes active again, the handler is called with a Counter value of -1 and the MsgAddr contains the message that 'woke up' the application.
When the value of Counter is greater than -1, the MsgAddr is the address of the Msg structure that contains the last Windows message before becoming idle. When the Counter is -1, this contains the message that is about to be processed.
If your handler routine calls returnValue, passing any value, this will immediately wake up your application and cause it to process the information contained in the structure pointer to by MsgAddr. This means that you are expected to place into this structure, valid data to simulate a Windows event.
Note: This event is not supported by the onXXX[] interface.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {integer keyCode, integer shift}
The keyCode is "raw" value of the key. The primary purpose of onKeyDown is to trap "special" keys not reported by onKeyPress.
The shift parameter has bits set indicating the if the shift, control, and alt keys are pressed. The masks for each key are:
For example, to see if the Shift+Backspace key was pressed, you could write:
-- shift+backspace? if and_bits( shift, ControlMask ) and keyCode = VK_BACK then -- shift+backspace held end if
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { integer keyCode, integer shift}
The keyCode is ANSII value of the key. Only "visible" keys are reported with this function. To trap "special" keys (such as the cursor keys), use onKeyDown.
For example:
-- is it the letter 'a'? if keyCode = 'a' then -- it's the letter a end if
The shift parameter has bits set indicating the if the shift, control, and alt keys are pressed. The masks for each key are:
For example, to see if the control key is held down, you could write:
-- control key held down? if and_bits( shift, ControlMask ) then -- control key is held down end if
If you want to to Windows to ignore the key, set the return value to -1.
if find(keyCode,"0123456789") then returnValue(-1) -- ignore digits. end if
If you want to to Windows to use a different key, set the return value to the new key.
-- collect characters into the password, but don't show them. PassWord &= keyCode returnValue('-') -- return a dash for each character entered.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {integer keyCode, integer shift}
The keyCode is the raw scan code value of the key. Use the VK_ constants to determine the value of the key.
The shift parameter has bits set indicating the if the shift, control, and alt keys are pressed.
See onKeyDown for details.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {focusControl}
focusControl is the id of the control that had the focus. This is normally the
same as the self parameter but in the case where self is a parent Window
focusControl is the control within that window that had focus.
Note: That focusControl parameter is not supported with the onXXX interface.
Focus means that keyboard events are directed to that control. See onGotFocus.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { integer event, integer x, integer y, integer shift, integer wheelmove }
The event parameter will be one of the following values:
The x and y parameters specify where the mouse is located. If the mouse has been grabbed (see captureMouse), the values of x and y can be negative if the mouse is outside the client area.
The shift parameter has bits set indicating the if the keyboard
shift, control, and alt keys are pressed, and which mouse button was
pressed.
The masks are:
-- Is one of the shift keys is held down? if and_bits( shift, ShiftMask ) then . . . end if -- Check for the combination Ctrl and Right Mouse. if and_bits( shift, ControlMask+RightBtnMask ) then . . . end if
NOTE wheelmove is not supported for the onXXX interface, only the
setHandler interface is supported.
The WheelMove parameter describes the direction and size of the mouse wheel
movement. A value greater than 0 means that the wheel moved 'up' or away
from the user, and a value less than zero means the wheel moved 'down'
or towards the user. And of course, a value of 0 means that
it didn't move at all.
The speed, or size, of the movement is the absolute value of this parameter. You
can use this in conjunction with getWheelScrollLines() to work out how the
mouse wheel movement should effect your application.
Example:
TopLine += parms[5] * getWheelScrollLines() RefreshDisplay()
Special Note: If you call returnValue(0) inside your mouse handler routine, this has the effect of causing the control that received the mouse event to ignore it. This is only needed in rare circumstances where your processing of the mouse event interferes with the control's normal processing. For example, if you trap a Right Down event to cause a popup menu to show, sometimes you also need to tell the underlying control to ignore the button down event 'cos you used it.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { integer event, integer x, integer y, integer z, sequence traps, integer id }
The event parameter will be one of the following values:
The x and y parameters specify where the mouse is located. If the mouse has been grabbed (see captureMouse), the values of x and y can be negative if the mouse is outside the client area.
The z parameter only applies to WheelMouse events and is the amount and direction that the wheel moved. Positive values mean it move away from the user (up), and negative values mean that it moved towards the user (down).
The traps parameter is a list of one or more mousetrap areas that are
under the mouse pointer. Each mousetrap is a sequence of 8 elements:
The id parameter is the control id that received the mouse event.
Note: This event is only invoked for MouseTraps that are enabled. When a mousetrap is created it is automatically enabled, but this can be changed by calling enableMouseTrap().
sequence mt mt = {} mt &= createMouseTrap(vWin, {10,10,30,30}) mt &= createMouseTrap(vWin, {30,10,50,30}) mt &= createMouseTrap(vWin, {10,30,30,50}) mt &= createMouseTrap(vWin, {30,30,50,50}) filterMouseTrap(vWin, mt[2], {WheelMove}) filterMouseTrap(vWin, mt[4], {WheelMove})procedure MouseTrap_MyWindow(integer self, integer event, sequence parms) sequence lMsg
lMsg = sprintf("event=%d x=%d y=%d", parms[1..3]) for i = 1 to length(parms[4]) do lMsg &= sprintf("(depth=%d left=%d top=%d right=%d bottom=%d id=%d) ", parms[4][i]) end for showMessage(lMsg) -- Only interested in the top mousetrap area... if parms[4][1][6] = mt[2] then -- Wheel moved inside mousetrap #2 elsif parms[4][1][6] = mt[1] then -- Left Button down inside mousetrap #1 end if end procedure setHandler(vWin, w32HMouseTrap, routine_id("MouseTrap_BasicWindow"))
If the hander for the w32HMouseTrap event returns any value, by calling returnValue(), the mouse event is not passed through to the underlying control.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { integer sender, integer event, object userdata, sequence parms }
A control gets this event when the sender control has just processed an event of type event with parameters parms. This only happens to controls that have told the sender that they want to be notified via the registerNotification() routine. The userdata is the same as that passed in the registerNotification() routine.
An example of using this facility could be if you wish a control to be notified whenever its parent is resized. Or when a specific control gets focus.
Note: This event is not supported by the onXXX interface.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {}
This is typically triggered by WinMain, or openWindow, before the window is visible by the user.
Typically, code that is run at this point does some sort of initialization.
This event is only triggered for a Window.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {atom x1, atom y1, atom x2, atom y2}
The parameters indicate the portion of the window that needs to be updated.
Not only does {x1,y1,x2,y2} define the area that needs to be redrawn, Windows restricts your application to only being able to draw in those areas! If your application tries to write outside this rectangle on an paint event, nothing will be drawn there.
Since Windows expects you application to be able to redraw any part of the application's window when responding to an paint event, this means that the paint routine must know how to render any part of the window.
For programs without any graphics and text drawn on the window, there is no problem - since there are no graphics, there is nothing to update.
If the application is fairly lightweight (such as a tic-tac-toe game), you simply choose to ignore the parameters passed to your paint handler, and redraw the entire window with each paint event.
If there is sufficient graphics to make the task of repainting the window complex, the best approach is probably to do double-buffering with a Pixmap.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPause, w32HResize, w32HScroll, w32HTimer, w32Start
parms = {integer keyCode, integer shift}
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HResize, w32HScroll, w32HTimer, w32Start
parms = { integer style, integer x, integer y}
The style is one of the following:
The x and y parameters are the new size of the id.
If your handler returns a value via returnValue() then the control is forced to be repainted. If it returns a zero (0) then the control's background is not erased before repainting otherwise it is erased first.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HScroll, w32HTimer, w32Start
parms = { integer position, integer ScrollType, integer WhichBar }
position indicates the new value of a scrollbar or trackbar.
ScrollType is one of...
WhichBar is one of...
Note: However, the ScrollType and WhichBar are only available when using the setHandler() interface.
This event is only triggered for ...
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HTimer, w32Start
parms = {atom TimerID}
Timers are clocks that are maintained by Windows, and they trigger these events at a user-specified interval, measured in milliseconds.
They are created and removed with the calls:
A timer is not treated as an actual control. Rather, the event is sent to the window that the timer is associated with.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32Start
and uses startApp() with the application-defined "AppCallback" as the application's callback routine, and the application-defined "main" routine as the application's start up routine.
See Also: AppCallback, closeApp, doEvents, getHandler, getLastMsg, getReturnValue, invokeHandler, main, onXXX, removeHandler, resetReturnValue, returnValue, setCallback, setDefaultProcessing, setEventLoop, setHandler, setIdle, setMouseClick, setNotifyHandler, setWinMsgHandler, startApp, subClassControl, w32HActivate, w32HAfterEvent, w32HBreak, w32HChange, w32HClick, w32HClose, w32HCloseUp, w32HDataChange, w32HDestroy, w32HDragAndDrop, w32HDropDown, w32HEvent, w32HGotFocus, w32HIdle, w32HKeyDown, w32HKeyPress, w32HKeyUp, w32HLostFocus, w32HMouse, w32HMouseTrap, w32HNotify, w32HOpen, w32HPaint, w32HPause, w32HResize, w32HScroll, w32HTimer