Richard Bell wrote: > Here is some example code: > > --- code --- > # test events WITHOUT a message pump > import win32com.client > > class events(): > def OnVisible(self, vis): > print 'OnVisible is:', vis > def OnBeforeNavigate2(self,pDisp,url,flags, > targetFrameName,postData, > headers,cancel): > print "OnBeforeNavigate2 on url [%s] on frame [%s]"% \ > (url,targetFrameName) > def OnCommandStateChange(self, > Command, > Enable): > print 'OnCommandStateChange: %s %s'%(Command,Enable) > > ie = win32com.client.DispatchWithEvents( > 'InternetExplorer.Application', > events) > # NO PUMP MESSAGE > ie.Visible = 1 > ie.Navigate('www.google.com') > --- end code --- > > And here is the output I get > --- output --- > OnVisible is: True > OnCommandStateChange: 2 False > OnBeforeNavigate2 on url [http://www.google.com/] on frame [] > OnCommandStateChange: 1 False > --- end output --- > > In this example there is no message pump that I'm aware of yet the event > routines clearly execute. What's going on? >
These are synchronous events. That is, these events are generated directly by the requests you made. I believe you will find that the "OnVisible" callback occurs before "ie.Visible = 1" returns. It's being handled by that same thread, which is suspended waiting for IE to finish. A message pump is only required for events that arrive asynchronously. It's still single threaded. If you're familiar with the Windows GUI, this is similar to the difference between PostMessage and SendMessage (ignoring interprocess calls for now). SendMessage calls directly into the window procedure of the target window without going through the message queue; when it returns, the message is handled. PostMessage is fire-and-forget; it will be processed later, when the message loop gets around to pulling the message. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32