گلپسر ببخشید دیر شد چون اولا پیامت رو دیر دیدم و دوما کار برام پیش اومد و سوما یه کم ویرایش اش سخت بود و نیاز به زمان داشتمبرای مشاهده این لینک/عکس می بایست عضو شوید ! برای عضویت اینجا کلیک کنید ارسالی توسط gla021 برای مشاهده این لینک/عکس می بایست عضو شوید ! برای عضویت اینجا کلیک کنید
داخل رویداد On Preload همه ی کدها رو پاک کن و بجاش اینو بزار :
کد:-- PDF Root Folder Defined in Global Functions -- Variable: sPDFRootFolder sFirstPDFToLoad = ""; function AddToTree(sFullPath) if (sFirstPDFToLoad == '') then sFirstPDFToLoad = sFullPath; end -- Split the path tPathParts = String.SplitPath(sFullPath); -- Get length of root folder (so we know how many chars to skip) nRootLength = String.Length(sPDFRootFolder); -- sFullPath minus last character sFullFolderPath = tPathParts.Drive .. tPathParts.Folder; nFullFolderPathLength = String.Length(sFullFolderPath); sFullFolderPath = String.Mid(sFullFolderPath, 1, nFullFolderPathLength - 1); -- Check of PDF should be inserted into root of tree if(String.Compare(sPDFRootFolder, sFullFolderPath) == 0) then -- We're inserting this PDF into the root, configure node values tNodeData = {}; tNodeData['Text']=tPathParts.Filename; tNodeData['Data']=sFullPath; tNodeData['ImageIndex']="0"; -- Insert the node Tree.InsertNode("Tree1", Tree.GetChildCount("Tree1", "0") + 1, tNodeData); else -- We need to search for an existing node by 'folder' value (ie sub folder) ... so let's create the search string -- Initialize sSearchString = tPathParts.Folder; FolderName = {} Counter = 1 StringCheck = "" while StringCheck do -- Strip the last slash off sSearchString = String.TrimRight(sSearchString, '\\'); -- Find the last occuring slash (will be before the final folder name nPosLastSlash = String.ReverseFind(sSearchString, '\\'); -- Get rid of all the stuff before the last occuring slash FolderName[Counter] = String.Mid(sSearchString, nPosLastSlash + 1, -1); StringCheck = FolderName[Counter] sSearchString = String.Mid(sSearchString, 1, nPosLastSlash); if StringCheck=="PDFs" then Table.Remove(FolderName, Counter); break end Counter = Counter + 1 end FolderNameCount = #FolderName SortedFolderName = {} for i,v in pairs(FolderName) do SortedFolderName[i] = FolderName[FolderNameCount] if SortedFolderName[i]~=nil then if i==1 then ------------------------------------------------------------------------------------------------- -- Search the tree by node name (folder name) sFoundNodeIndex = Tree.FindNodeByText("Tree1", "0", SortedFolderName[i]); if sFoundNodeIndex == "" then -- Node wasn't found, create it -- Create node data (data part is left blank ... this is a 'category', not a document) tNodeData = {}; tNodeData['Text']=SortedFolderName[i]; tNodeData['Data']=""; tNodeData['ImageIndex']="1"; sParentIndex = Tree.GetChildCount("Tree1", "0") + 1; Tree.InsertNode("Tree1", sParentIndex, tNodeData); else sParentIndex = sFoundNodeIndex; end else if sParentIndex~=nil and sParentIndex~="" and sParentIndex~=-1 then -- Search the tree by node name (folder name) sFoundNodeIndex = Tree.FindNodeByText("Tree1", sParentIndex, SortedFolderName[i]); if sFoundNodeIndex == "" then -- Node wasn't found, create it -- Create node data (data part is left blank ... this is a 'category', not a document) tNodeData = {}; tNodeData['Text']=SortedFolderName[i]; tNodeData['Data']=""; tNodeData['ImageIndex']="1"; sParentIndexNew = Tree.GetChildCount("Tree1", sParentIndex) + 1; sParentIndex = sParentIndex.."."..sParentIndexNew Tree.InsertNode("Tree1", sParentIndex, tNodeData); else sParentIndex = sFoundNodeIndex; end end end FolderNameCount = FolderNameCount - 1 else break end end if sParentIndex~=nil and sParentIndex~="" and sParentIndex~=-1 then -- Insert actual file tNodeData = {}; tNodeData['Text']=tPathParts.Filename; tNodeData['Data']=sFullPath; tNodeData['ImageIndex']="0"; Tree.InsertNode("Tree1", sParentIndex .. "." .. (Tree.GetChildCount("Tree1", sParentIndex) + 1), tNodeData); end end return true; end -- Find all PDF's in the folder File.Find(sPDFRootFolder, "*.pdf", true, false, nil, AddToTree); -- Load the first PDF PDF.LoadFile("PDF1", sFirstPDFToLoad);






پاسخ با نقل قول
Bookmarks