
Newbie question: Rich Text Box vs. Text Box
In my VB project (a text editor), I have been confused about the issue
of whether to make my client writing area a "TextBox" or a
"RichTextBox". Through experimentation, I have seen how the Cut, Copy,
and Paste processes are handled automatically and seemlessly for
RichTextBoxes, and I was very encouraged by this.
Currently, the only obstacle I am encountering with respect to my
RichTextBox has to do with OLE Drag and Drop. Specifically, my code to
handle the dropping of a file onto my TextBox was...
Private Sub txtDoc_OLEDragDrop(Data As DataObject, Effect As Long,
Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.GetFormat(vbCFFiles) Then
Dim vFN
For Each vFN In Data.Files
DropFile txtDoc, vFN
Exit For
Next vFN
End If
End Sub
...and this worked OK when I was using a "TextBox" instead of a
"RichTextBox". Please note that the cludgy aborted For Each loop was
done because I only accept the first of multiple files dropped onto this
TextBox. Also, I have a routine called "DropFile" which does the
processing for a given file.
The problems I encountered when I tried to use this same code with a
RichTextBox are...
(1) the parameter...
Data As DataObject needed to be changed to "Data As
RichTextLib.DataObject"
I make this change, and that problem was solved.
(2) the expression "Data.Files" (in "For Each vFN In Data.Files") causes
the run-time error.
Runtime error "438" - Object doesn't support this property or method.
Does anyone know what property I would use in place of "Files" for a
RichTextBox? The object browser tells me that I should be able to use
the "Files" property.
Thanks.
Jon Kinsting
P.S. The documentation says that if I declare both the Drag property and
Drop property (in my RichTextBox) to be automatic, then the drop
handling will be automatic, and I will not need to code anything.
However, when I do this and attempt to drop a file onto the RichTextBox,
only the file's icon appears in that RTB (not the files content/text).