Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 3 of 3

Thread: Need Help

  1. #1
    Join Date
    Feb 2002
    Posts
    13

    Grin Need Help

    I am trying to create a document browser and have followed the knowledge base directions. That works fine, but I want to take it to the next level.

    I want it to goto a folder on the cd and list all the PDF files. I have got it to list pdf files but can't get it to goto a specified folder.

    Next problem, I also have to embedded Adobe Reader on the cd since LE can't install software without the Chief's ok. I know how to that and have, but with the list box whenI click on the file I want it opens that as well as the first file in the list. Here is the code I am using:

    --Disable listbox Updating ListBox.SetUpdate("ListBox1", false);

    --Get the desired folder to browse
    folder = Dialog.FolderBrowse("Open Folder", "_SourceFolder\\Docs\\");

    --populate a table with all the .pdf files
    file = File.Find(folder, "*.pdf", false, false, nil);
    --do the following for each file:
    for j, file_path in file do
    --add the item to the listbox, with the name visible and path as data
    ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
    end

    --Allow the listbox to display the updated content ListBox.SetUpdate("ListBox1", true);


    Here is the open code:

    path_short = File.GetShortName(_SourceFolder);
    File.Run("AutoPlay\\Adobe Reader\\AcroRd32.exe", path_short .. "\\AutoPlay\\Docs\\*.pdf", "", SW_SHOWNORMAL, false);
    selected = ListBox.GetSelected("ListBox1");
    for j,k in selected do
    File.Open(ListBox.GetItemData("ListBox1", k),"", SW_SHOWNORMAL);
    end

  2. #2
    Join Date
    Jul 2003
    Posts
    712

    Re: Need Help

    Hello,

    I'm not quite clear on your first question . . . What do you mean you can't get it to goto a specified folder? Are you trying to ask the user to specify the folder, or do you want to specify the folder yourself, and (without any user input) populate the listbox on file load?

    Your second issue . . . I think it's your second line:
    Code:
    path_short = File.GetShortName(_SourceFolder); 
    File.Run("AutoPlay\\Adobe Reader\\AcroRd32.exe", path_short .. "\\AutoPlay\\Docs\\*.pdf", "", SW_SHOWNORMAL, false);  
    selected = ListBox.GetSelected("ListBox1"); 
    for j,k in selected do 
    File.Open(ListBox.GetItemData("ListBox1", k),"", SW_SHOWNORMAL); 
    end
    That is more than likely opening the first pdf file in the directory. Since (im' assuming) you only want the user to open one file at a time, make sure your listbox is not set to multi select.

    Then try using the following code:
    Code:
    -- Get the path to the source folder
    path_short = File.GetShortName(_SourceFolder); 
    
    -- Get the selected index(s) from the listbox.
    selected = ListBox.GetSelected("ListBox1"); 
    
    -- Ensure there is something selected, and open the item
    -- (We are only concerned with the first selected, use selected[1])
    if selected[1] then
    File.Run("AutoPlay\\Adobe Reader\\AcroRd32.exe", ListBox.GetItemData("ListBox1", selected[1]), "", SW_SHOWNORMAL, false);
    end
    Play around with that for a while. You'll probably have to change the logic to ensure the File.Run command points to your correct files. Let me know if that works for you!

  3. #3
    Join Date
    Feb 2002
    Posts
    13
    Desmond

    Thanks for the help, I got the second part working. You are right about the first part. When they hit the load button I want it to populate the listbox without any user input?

    CoreyTL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts