[python-win32] Canceling OnBeforeClick event in MapPoint 2006

Mark Hammond mhammond at skippinet.com.au
Mon Aug 27 01:36:08 CEST 2007


Hi Oliver,
  Over the last couple of days, Roger Upole has diagnosed a very similar
issue as being related to a bug in pywin32 handling 'named' params passed
from COM, which will result in such params being passed in reversed order.
I'd bet this is the same issue you are seeing.  I hope to have this fixed in
the next pywin32 build.

See
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1648655&group_i
d=78018 for details.

Cheers,

Mark

> 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
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



More information about the python-win32 mailing list