Win32gui... file dialogs?

Alex Martelli alex at magenta.com
Sat Aug 26 04:45:29 EDT 2000


"Mark Hammond" <MarkH at ActiveState.com> wrote in message
news:VlFp5.12261$Xg.115457 at news-server.bigpond.net.au...
> "Alex Martelli" <alex at magenta.com> wrote in message
> news:8o592h0cuo at news2.newsguy.com...
> > "Kevin Cazabon" <kcazabon at home.com> wrote in message
> > news:I_kp5.201386$8u4.2042579 at news1.rdc1.bc.home.com...
>
> > There's a win32gui.GetOpenFileName function, but I can't find
> > usable docs on it; trying to call it elicits the info that it
> > requires a 76-byte string, but it's hard to fathom what is to
> > go into that string.
>
> It is worth recalling that win32gui was actually created for Windows
> CE, where I didnt want to bloat the module with support for all the
> win32 structures you may need.  Hence I went the string route, and

I didn't know that!  So, thanks for clarifying.


> OTOH, maybe working out the struct magic for win32gui, and putting
> that into a .py file would be a better option?

It seems to be something that could be made to work right now.
And maybe a good general approach -- when speed is not an issue
(and it isn't, when one is about to open a modal dialog:-), it could
be best to minimize the amount of C, using Python instead.

So, let's see.  struct OPENFILENAME has 20 fields, all 4-byte
except nFileOffset and nFileExtension which are 2-byte each;
I guess that's where the 76-byte size comes from, right?
18*4+2*2=72+4=76.

So far, so good.  Most of the fields are either DWORD's with
values that are easy to understand, or can be left at 0 without
too much pain.  Only issue: how does one set the various
LPCTSTR and LPCSTR parameters with struct?  The only way
I see with struct to place a pointer/extract a pointer is with
format 'p' -- but that corresponds to a Python int; how do I
get the int equivalent of a string's initial address, and vv...?

The buildin id() could work since the implementation note
says it's the object's address (but is string format OK, with
a null at the end?), or maybe I need array & buffer_info()...?


Alex






More information about the Python-list mailing list