[python-win32] HookMessage fails

Mark Hammond mhammond at skippinet.com.au
Thu May 24 05:03:41 CEST 2007


I think the problem is likely related to the "main frame" issue quoted below.  I suggest you debug what the app's "main frame" is at any given point in time, and confirming the value is still appropriate.

Mark

> On 5/15/07, Mark Hammond <mhammond at skippinet.com.au> wrote:
> > > > This is the magic of MFC - if no parent is specified, the
> > > "main window" for
> > > > the application is automatically used.
> > > >
> > >
> > > Isn't that the issue, then?  He's writing a dialog to plug in to
> > > Explorer, and every time he runs, there's a different 
> "main window".
> > > MFC gets its concept of a "main window" from its global
> > > state, so unless
> > > something in the process tells MFC to refresh its global
> > > state, it will
> > > have stale information.
> >
> > Quite possibly - I'm afraid I can't recall the exact 
> semantics for dialog
> > based apps, but I suspect that a number of things in MFC 
> will end up getting
> > upset if the nominated main window dies but the application 
> does not - but
> > win32ui.GetApp().SetMainFrame() can be used to change this value
> > dynamically.  I'm afraid I haven't found the time to read 
> the other messages
> > in enough detail to offer more concrete suggestions (other 
> than to possibly
> > consider using win32gui to avoid future MFCisms from biting)
> 
> Hi Mark,
> 
> Not sure it's helps to clarify my situation, but the dialog in
> question is actually a simple subclass of pywin.mfc.dialog, with a
> resize handler hooked to WM_SIZE with HookMessage().
> 
> This dialog forms part of the shell extension registered to Explorer,
> which does work similar to TortoiseSVN or TortoiseCVS. The dialog is
> then called from the context menu in the Explorer windows by a simple
> call of something like this:
> 
>    dlg = MyResizableDialog()
>    dlg.CreateWindow()
> 
> Everything in the dialog works fine, except the ability to resize is
> somehow lost when the dialog is opened from subsequent Explorer
> windows.
> 
> In any case, if you think it helps, I can email you the code. It'd be
> great if you can suggest anything I can try to debug this.Thanks.
> 



More information about the Python-win32 mailing list