Some of you may have read this post over on the forums or wx mailing
list, I'm hoping I can find someone that has gone through this problem
already. Canceling this event in other languages seems to work just
fine, but in python it doesn't work.
The IDL for the function is:
void BeforeClick(long Button, long Shift, long X, long Y, bool* Cancel)
Based on this I've tried canceling the event by:
return 0, True
So that the byref cancel param gets set to true which should cancel the
click event (works in c#).
I've tried working with the calendar control and have successfully
canceled the BeforeUpdate event using the same line. The only
difference I can see between the two is that the calendar control is
using a short for the cancel param while mappoint is using a bool. I'm
using early binding btw.
Below is the code I'm using to test (just the calendar code with some
simple replacements for the mappoint control):
def GetTestMapPointClass():
global mpParentModule
win32ui.DoWaitCursor(1)
mpParentModule =
gencache.EnsureModule("{51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}", 0, 1, 0)
win32ui.DoWaitCursor(0)
if mpParentModule is None:
return None
class TestMPDialog(dialog.Dialog):
def OnInitDialog(self):
class MyMP(activex.Control, mpParentModule.MappointControl):
def OnBeforeClick(self, Button, Shift, X, Y, Cancel):
print "clicked"
return 0, True
rc = dialog.Dialog.OnInitDialog(self)
self.olectl = MyMP()
try:
self.olectl.CreateControl("OCX", win32con.WS_TABSTOP |
win32con.WS_VISIBLE, (7,43,500,300), self._obj_, 131)
self.olectl.NewMap(win32com.client.constants.geoMapNorthAmerica)
except win32ui.error:
self.MessageBox("The MP Control could not be created")
self.olectl = None
self.EndDialog(win32con.IDCANCEL)
return rc
def OnOK(self):
pass
return TestMPDialog
Any help appreciated.
OLIVER
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32