Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Win32::OLE messes up dialogs?

Reply
Thread Tools

Win32::OLE messes up dialogs?

 
 
zorg.borg@gmail.com
Guest
Posts: n/a
 
      08-31-2005
Hi all,

i'm experiencing some strange problems when using the module Win32::OLE
together with windows dialogs.

In the following code snippet, I use an opendialog to pick a file. The
dialog works as expected: when a different file type is selected in the
combobox, the file listing changes accordingly.

However, if I uncomment the two Win32::OLE lines, the behaviour
changes: if
I pick any file type the file list becomes empty, not even showing
folders. The only way to have some file names displayed is typing
something like '*.*' in the file name box and then clicking 'Open'.

I first experienced this problem using Tk's getopenfile. I switched to
Win32::FileOp as I was thinking it was a Tk problem (as it had other
problem, like the handling od unicode file names).

I'm using activestate perl 810, Win32::FileOp 0.14.1.0 and Win32::OLE
0.1702.0.0, both from http://www.bribes.org/perl/, and I get the same
results under win98, win2000 and winxp sp2.

anyone experiencing the same thing? any suggestions?

thanks,
davide

[code snippet follows]

use strict;
use warnings;
#use Win32::OLE;
#my $EXC = Win32::OLE->GetActiveObject('Excel.Application');

use Win32::FileOp;
use File::Slurp;

my %parameters = (
title => 'test',
filters => [ 'log files' => '*.log;*.txt',
'Files .log' => '*.log',
'Files .txt' => '*.txt',
'All files' => '*.*'],
defaultfilter => 1,
dir => 'c:\\',
options => (OFN_HIDEREADONLY, OFN_OVERWRITEPROMPT),
);


my $file = OpenDialog %parameters;
exit unless ($file);
print "you picked $file\n";
my $contents=read_file($file);

print "----------------\n$contents\n--------------\n";

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      08-31-2005
wrote in
news: oups.com:

> Hi all,
>
> i'm experiencing some strange problems when using the module
> Win32::OLE together with windows dialogs.
>
> In the following code snippet, I use an opendialog to pick a file. The
> dialog works as expected: when a different file type is selected in
> the combobox, the file listing changes accordingly.
>
> However, if I uncomment the two Win32::OLE lines, the behaviour
> changes: if
> I pick any file type the file list becomes empty, not even showing
> folders. The only way to have some file names displayed is typing
> something like '*.*' in the file name box and then clicking 'Open'.


I do not see this problem when I run the code you provided. However, I
do get a warning:

D:\Home\asu1\UseNet\clpmisc> fo
Odd number of elements in hash assignment at D:\Home\asu1\UseNet\clpmisc
\fo.pl line 9, <DATA> line 164.

> use strict;
> use warnings;
> #use Win32::OLE;
> #my $EXC = Win32::OLE->GetActiveObject('Excel.Application');
>
> use Win32::FileOp;
> use File::Slurp;
>
> my %parameters = (
> title => 'test',
> filters => [ 'log files' => '*.log;*.txt',
> 'Files .log' => '*.log',
> 'Files .txt' => '*.txt',
> 'All files' => '*.*'],
> defaultfilter => 1,
> dir => 'c:\\',
> options => (OFN_HIDEREADONLY, OFN_OVERWRITEPROMPT),


The warning is probably caused by this line.

You probably want to use

options => OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,

instead.

Sinan
--
A. Sinan Unur <>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      08-31-2005

"A. Sinan Unur" <> wrote in message
news:Xns96C3B68F74F67asu1cornelledu@127.0.0.1...
> wrote in
> news: oups.com:
>
>> Hi all,
>>
>> i'm experiencing some strange problems when using the module
>> Win32::OLE together with windows dialogs.
>>
>> In the following code snippet, I use an opendialog to pick a file. The
>> dialog works as expected: when a different file type is selected in
>> the combobox, the file listing changes accordingly.
>>
>> However, if I uncomment the two Win32::OLE lines, the behaviour
>> changes: if
>> I pick any file type the file list becomes empty, not even showing
>> folders. The only way to have some file names displayed is typing
>> something like '*.*' in the file name box and then clicking 'Open'.

>
> I do not see this problem when I run the code you provided. However, I
> do get a warning:
>


Did you uncomment the two lines? I can get the same behaviour with build 813
on an XP SP2 box, even making the change you noted to the OP. If you call
the GetActiveObject method before OpenDialog the problem the OP noted
occurs.

I would hazard a guess from the documentation that this is the source of the
problem:

<quote>
There is a little problem with the underlying function. You have to
preallocate a buffer for the selected filenames and if the buffer is too
smallyou will not get any results. I've consulted this with the guys on
Perl-Win32-Users and there is not any nice solution. The default size of
buffer is 256B if the options do not include OFN_ALLOWMULTISELECT and 64KB
if they do. You may change the later via variable
$Win32::FileOp::BufferSize.
</quote>

If I set the ofn_allowmultiselect option the problem disappears (albeit you
get a different dialog, too). I couldn't tell you why the call to
GetActiveObject affects the buffer; you should probably try emailing the
author.

Matt


 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      09-01-2005
"Matt Garrish" <> wrote in
news:LrrRe.4402$:

>
> "A. Sinan Unur" <> wrote in message
> news:Xns96C3B68F74F67asu1cornelledu@127.0.0.1...
>> wrote in
>> news: oups.com:
>>

....
>>> However, if I uncomment the two Win32::OLE lines, the behaviour
>>> changes: if
>>> I pick any file type the file list becomes empty, not even showing
>>> folders. The only way to have some file names displayed is typing
>>> something like '*.*' in the file name box and then clicking 'Open'.

>>
>> I do not see this problem when I run the code you provided. However,
>> I do get a warning:
>>

>
> Did you uncomment the two lines?


Ooops! I thought I had, but apparently not. I can also replicate it with
XPP SP2.

Sorry about that.

Sinan

--
A. Sinan Unur <>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
zorg.borg@gmail.com
Guest
Posts: n/a
 
      09-01-2005
Sinan, thanks for the heads up on the options.

Matt, I don't know if the problems are related to the buffer. I would
guess they aren't, as the problem comes up only when using Win32::OLE.

I'll try to contact the authors

thanks,
davide

 
Reply With Quote
 
zorg.borg@gmail.com
Guest
Posts: n/a
 
      09-02-2005
For the record:
here's what Jan Dubois replied to me in perl-win32-users on
activestate.com: it fixes the problem.

ciao
davide

----------------------------------
Please call

Win32::OLE-> Initialize(Win32::OLE::COINIT_OLEINITIALIZE);

*before* you instantiate any Win32::OLE objects. This should fix the
problem
with the Windows Common Dialogs. Since you are writing a program with
a message
loop there should be no bad side effects of running in apartment
threading mode.

Cheers,
-Jan


______

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Masterpages/themes messes up designmode =?Utf-8?B?TWFya3VzIFJ5dHRlcmt1bGw=?= ASP .Net 3 02-28-2006 12:55 PM
COM Interop messes with IE hosted windows forms control Dilip ASP .Net 3 12-30-2004 04:36 PM
ASP.Net messes with my form's action attributes! =?Utf-8?B?TWFydGlu?= ASP .Net 3 04-06-2004 03:11 PM
Please Help, NEWBIE, .net, .apsx, access external site messes up data access when using firewall ASP .Net 0 02-09-2004 04:56 PM
Please Help, NEWBIE, .net, .apsx, access external site messes up data access when using firewall ASP .Net 2 02-02-2004 01:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57