COM event handler parameters returning values
Posted: 20 Apr 2016, 12:48
I've been successfully using COM events with AHK for a while, but I've so far avoided the issue of event handlers that expect values to be returned in the parameter list.
Eg. Excel's workbook event, BeforeClose, defined in VBA as:
Private Sub Workbook_BeforeClose( Cancel As Boolean)
Cancel is False when the event occurs. If the event procedure sets this argument to True, the close operation stops and the workbook is left open.
So the parameter "Cancel" needs to be passed by reference in order for the handler to pass back a value in it. Can you do that in AHK with:
I don't think this is touched upon in the ComObjConnect documentation.
Many thanks for any help in advance!
Eg. Excel's workbook event, BeforeClose, defined in VBA as:
Private Sub Workbook_BeforeClose( Cancel As Boolean)
Cancel is False when the event occurs. If the event procedure sets this argument to True, the close operation stops and the workbook is left open.
So the parameter "Cancel" needs to be passed by reference in order for the handler to pass back a value in it. Can you do that in AHK with:
Code: Select all
class Workbook_Events
{
BeforeClose(ByRef cancel, wkb)
{
cancel := True ; Prevent the workbook from closing.
}
}
Many thanks for any help in advance!