I have an ActivX OleControl Microsoft treeView V6.0 and as a part of Init() procedure I use DISKSPACE() function just to determine which disk drives (physical as well as mapped network drives) are currently available. If the drive A: does not have a disk in it I get repeated error messages: "Drive is empty, please insert...." It does not do anything like this with DVD/CD R/W drives. They are empty and it is OK.
Likewise, if I simply click on the image of Drive A: after the control is initialized and try to move the cursor away from it, I get 3 messages of this type in a row. It is annoying.
SET NOTIFY OFF does not help
An obvious solution is to insert a floppy into drive A:. For some reason I want a more general resolution to the problem.
Any ideas
Thanks.

DISKSPACE() trouble
ti_m
Part 2: Thinking this Treeview might be about Xlplorer like view here is a derivative of code originally published in universalthread magazine June 2001 edition (passing a provider class we separate TV logic from node supplier logic - ie: With an Active Directory provider class this might list groups available in AD):
* Define some constants.
#Define tvwFirst 0
#Define tvwLast 1
#Define tvwNext 2
#Define tvwPrevious 3
#Define tvwChild 4
Local oForm
oForm = Createobject('myForm', ;
NewObject('FileDirectoryProvider'))
oForm.Show
lcReturnValue = oForm.NodeSelected
oForm.Release
Release oForm
Return lcReturnValue
Define Class myForm As Form
Height = 300
Width = 600
DoCreate = .T.
Caption = "On demand sample - Xplorer"
oProvider = .Null.
WindowType = 1
ShowWindow = 1
*-- Node key
NodeSelected = ""
Add Object oletreeview As OleControl With ;
Top = 0, ;
Left = 0, ;
Height = 200, ;
Width = 540, ;
Name = "OleTreeView", ;
OleClass = 'MSComCtlLib.TreeCtrl'
Add Object mySelect As CommandButton With Caption = 'Select'
Procedure Init(toProvider)
With This.oletreeview
.linestyle =1
.labeledit =1
.indentation = 5
.PathSeparator = '\'
.Height = This.Height - This.mySelect.Height - 10
.Width = This.Width
This.mySelect.Top = .Height + 5
Endwith
This.mySelect.Left = This.Width - This.mySelect.Width - 5
* This.Show
This.oProvider = toProvider
This.GetNodes(.Null.)
Endproc
Procedure mySelect.Click
With Thisform
If !Isnull(.oletreeview.SelectedItem)
.NodeSelected = .oProvider.ReturnKey(.oletreeview.SelectedItem)
Endif
.Hide
Endwith
Endproc
Procedure oletreeview.Expand
*** ActiveX Control Event ***
Lparameters Node
Thisform.GetNodes(Node)
Node.ensurevisible
Endproc
Procedure oletreeview.NodeClick
*** ActiveX Control Event ***
Lparameters Node
Node.ensurevisible
Endproc
Procedure GetNodes(oNode)
Local oItems,ix
oItems = This.oProvider.GetNodes(oNode)
Asort(oItems.Items) && Sorted on NodeText
For ix=1 To oItems.Count
This.AddNode(oItems.Items[m.ix,1],oItems.Items[m.ix,2],oNode,oItems.Count)
Endfor
Endproc
Procedure AddNode(tcNodeText,tcNodeKey,oParentNode,tnItems)
Local oNode
With This.oletreeview.nodes
If Isnull(oParentNode) Or ;
(Type('oParentNode') # 'O' And Empty(oParentNode))
oNode=.Add(,tvwFirst,m.tcNodeKey,m.tcNodeText)
Else
If oParentNode.Children > 0
If oParentNode.Child.Key = oParentNode.Key+"dummy"
.Remove(oParentNode.Child.Index)
Endif
If oParentNode.Children = m.tnItems && already added
Return
Endif
Endif
oNode= .Add(oParentNode.Key, ;
tvwChild, m.tcNodeKey, m.tcNodeText)
Endif
If This.oProvider.HasChildren(oNode)
oNode= .Add(oNode.Key, ;
tvwChild, oNode.Key+'dummy', 'Populating...')
Endif
Endwith
Endproc
Enddefine
Define Class NodeProviderBase As Custom && Abstract class
Procedure CreateItemsObject
Local loItems As Line
loItems = Createobject('Line')
loItems.AddProperty('Count',0)
loItems.AddProperty('Items[1,2]')
Return loItems
Endproc
Procedure _AddItem(toItems, ItemText,ItemKey)
If Type('toItems.Items[1,1]') != 'L'
Dimension toItems.Items[Alen(toItems.Items,1)+1,2]
Endif
toItems.Items[Alen(toItems.Items,1),1] = m.ItemText
toItems.Items[Alen(toItems.Items,1),2] = m.ItemKey
Endproc
Procedure HasChildren(toNode) && return T/F
Endproc
* Get children of given node
* If oNode=.null. get root nodes
Procedure GetNodes(oNode)
Endproc
Procedure ReturnKey(oNode) && return prefferred value - key,fullpath,text
Endproc
Enddefine
Define Class FileDirectoryProvider As NodeProviderBase
oFS = .Null.
Procedure Init
This.oFS = Createobject('Scripting.FileSystemObject')
DoDefault()
Endproc
Procedure GetNodes(oNode) && Get children of given node
Local loItems
loItems = This.CreateItemsObject()
If Isnull(oNode)
For Each oDrive In This.oFS.Drives
If oDrive.IsReady
loItems.Count = loItems.Count + 1
This._AddItem(loItems, oDrive.Rootfolder.Path, Sys(2015))
Endif
Endfor
Else
Local lcFolder, oFolder, ix
lcFolder = Strtran(oNode.Fullpath,":\\",":\")
oFolder = This.oFS.GetFolder(m.lcFolder)
For Each loSubFolder In oFolder.Subfolders
loItems.Count = loItems.Count + 1
This._AddItem(loItems, loSubFolder.Name, Sys(2015))
Endfor
Endif
Return loItems
Endproc
Procedure HasChildren(oNode)
Local oFolder
oFolder = This.oFS.GetFolder(Strtran(oNode.Fullpath,":\\",":\"))
Return ( Lower(oFolder.Name) # "system volume information" ;
and oFolder.Subfolders.Count > 0 )
Endproc
Procedure ReturnKey(oNode) && return prefferred value - key,fullpath,text
Return Strtran(oNode.Fullpath,":\\",":\")
Endproc
Enddefine
big t
Alex,
If you mean something like:
do form home()+'tools\filer\filer'
then the filer.dll it uses is ready to be used from within VFP. It looks like:
oFiler = createobject('Filer.FileUtil')
* set properties like include subdirs, search skeleton, search for patterns etc
oFiler.Find(0)
* process results
Wayne Taylor
Part 1: Determine if there is a disk in drive. Could be done using winAPI or FSO etc. For simplicity here is how to check with FSO:
oFS = Createobject('Scripting.FileSystemObject')
For Each oDrive In oFS.Drives
If oDrive.IsReady
oDrive.Rootfolder.Path
Endif
Endfor
Or just check if drive 'A' is ready with OFS:
oFS = Createobject('Scripting.FileSystemObject')
oFS.GetDrive('a').IsReady
Anthony Coelho
oFS = Createobject('Scripting.FileSystemObject')
oFS.GetDrive('a').IsReady
It solved my problem completely. Thanks.
Kev at PwC
Thanks a lot, Cetin. As always, your answers are very helpful. I should read more on the subject of your previous post: FSO.
My treeView is a reincarnation of a similar app I had in Visual dBase. It was extremely helpful but unfortunately, the DBE now fails on some directories after I unzipped some cab files. I cannot figure out what the matter is. There is no support for dBase anymore and anyhow I've decided that it is about time for me to switch to FoxPro, thus it could be for the better.
That application allowed me to search subdirectories for files/directories and extensions and analyze the content of files for patters. Windows "search" facility does not go into subdirectories (I mean you cannot start your search with a subdirectory) thus a lot of time is wasted on every search.
I am almost done with this treeView thing. In the process I've discovered that FoxPro is perhaps much more powerful in terms of many additional options and the code appears to be significantly more compact in part because of ActiceX things and OLEs.
Thanks.