|
From: Brian S. <br...@ic...> - 2008-12-23 23:03:13
|
Sean,
Many thanks for your help in pointing me in the right direction!!
Here's the partial code listing I got working.
use constant DIR_NORMALFILES => \&H0;
~
~
~
sub AddItemsToListBox1{
my $dir = "C:/*.*";
my $result=Win32::GUI::Listbox::Dir($Listbox1, $dir ,
DIR_NORMALFILES);
}
Notes:
It turns out that the VB method DirDlgList is not an issue at all, nor do I
need to use AddFile to populate the Listbox after calling ListBox::Dir.
However, the constants that you found do not seem to work. The constants
defined in http://www.vbexplorer.com/VBExplorer/SourceCode/vbs_fd.asp#tip1
as written by Gordon F. MacLeod for Visual Basic do seem to work:
' Note**, The author defined these constants, so you
' won't find them in API documentation, although they
' are based on values used with LB_DIR.
Global Const WM_USER = &H400
Global Const LB_DIR = (WM_USER + 14)
Global Const DIR_NORMALFILES = &H0
Global Const DIR_READONLY = &H8001
Global Const DIR_HIDDEN = &H8002
Global Const DIR_SYSTEM = &H8004
Global Const DIR_DIRECTORIES = &H8010
Global Const DIR_ARCHIVED = &H8020
Global Const DIR_DRIVES = &HC000
Thanks,
Brian
------------------------------
Message: 2
Date: Mon, 15 Dec 2008 17:08:07 +0100
From: Sean Healy <jal...@ho...>
Subject: Re: [perl-win32-gui-users] Filling Listbox with Dir and
AddFile
To: per...@li...
Message-ID: <COL...@ph...>
Content-Type: text/plain; charset=windows-1252; format=flowed
Brian Somers wrote:
> Basically, I?m trying to implement a dual listbox interface quite
> similar to what Eric Hansen wrote about in 1999. What I can?t find
> anywhere is how to fill the left listbox with the files in a given
> directory, although the closest I found was a tutorial in VB out on the
> web. I?m trying to use the methods Dir and AddFile, but something?s not
> working. I can?t figure out what the Dir method is supposed to return,
> nor what parameters/arguments to send. I try AddFile and my app crashes.
> I can make AddString work, though.
MSDN is your friend!
(Seriously, MSDN is your best bet for figuring out undocumented
Win32::GUI methods.)
AddFile($path)
http://msdn.microsoft.com/en-us/library/bb775165(VS.85).aspx
Take note: "The list box to which lParam is added must have been filled
by the DlgDirList function." This is presumably why you're crashing
Unfortunately, however, Win32::GUI does not expose the DlgDirList
function to Perl. (At least, a search of the source files does not find
"DlgDirList".)
Dir($path, $flags)
http://msdn.microsoft.com/en-us/library/bb775185(VS.85).aspx
Some notes:
2) The order of parameters is swapped in Win32::GUI.
3) The constants don't seem to be available via Win32::GUI::Constants,
so here they are:
DDL_READWRITE = 0x00
DDL_READONLY = 0x01
DDL_HIDDEN = 0x02
DDL_SYSTEM = 0x04
DDL_DIRECTORY = 0x10
DDL_ARCHIVE = 0x20
DDL_DRIVES = 0x4000
DDL_EXCLUSIVE = 0x8000
(I hope these are correct - I found them on the web and haven't tested
them.)
|