Problem with Handling Rich Text Box Control in VB 6.0


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Problem with Handling Rich Text Box Control in VB 6.0

  1. #1
    Join Date
    Oct 2007
    Location
    India,Maharashtra,Pune,Khadakwasla
    Posts
    5

    Arrow Problem with Handling Rich Text Box Control in VB 6.0

    Hi all,
    I have problem with RichTextBox control in vb 6.0I need to drag text/picture/mail message files
    & drop them onto richtextbox.When user double clicks on that file in richtextbox the corresponding file should open
    (as the richtextbox control may contain multiple files dropped on it).Is there any way to do this in vb 6?


    1.I set OLEDropMode property to rtfOLEDropAutomatic,OLEDragMode property to rtfOLEDragAutomatic.
    Then when I dropped text file into RichTextBox control, it displays file name in richtextbox
    When I double clicked on the text file it is not displayed but only shows some window in taskbar for a moment
    and the window gets closed.Nothing happens ,file not displayed.

    When I set OLEDragMode property to rtfOLEDragAutomatic and OLEDropMode property to rtfOLEDropManual ,I can catch OLEDragDrop event but when I dragged a text file into RichTextBox control file name is not shown in richtextbox control.


    Thanks
    -Kiran

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome to DevX

    Post the code that you are using.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Oct 2007
    Location
    India,Maharashtra,Pune,Khadakwasla
    Posts
    5
    Hi,
    Here is my code
    I used RichTextBox control as RichTextBox1
    I set OLEDropMode property to rtfOLEDropManual.
    I set OLEDragMode property to rtfOLEDragManual.
    How I show Text file in a RichTextBox control ?
    How I open Text file On double click ?
    Is there any other way to handle drag drop events programmatically in vb6?
    Code:
    Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    
          RichTextBox1.OLEDrag
    End Sub
    
    Private Sub RichTextBox1_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
         RichTextBox1.Text = Data.Files(1)
    End Sub
    
    Private Sub RichTextBox1_OLEDragOver(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
        If Data.GetFormat(vbCFFiles) Then
          RichTextBox1.OLEDropMode = vbOLEDropManual
        End If
    End Sub
    
    Private Sub RichTextBox1_OLEStartDrag(Data As RichTextLib.DataObject, AllowedEffects As Long)
        AllowedEffects = vbDropEffectCopy
        Data.Clear
        Data.SetData RichTextBox1., vbCFFiles
    End Sub
    Last edited by Hack; 10-29-2007 at 08:10 AM. Reason: Added Code Tags

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Do you want to open it in like Notepad or display the contents in another RTB?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Oct 2007
    Location
    India,Maharashtra,Pune,Khadakwasla
    Posts
    5
    hello
    I want to open the text file when user clicks on the text file draged & droped onto richtextbox.On some machine it is opened but on other it is not.
    why so? how to resolve it,pls help
    thanks

  6. #6
    Join Date
    Oct 2007
    Location
    India,Maharashtra,Pune,Khadakwasla
    Posts
    5
    I mean ,for text file display in Notepad,for paint display it in mspaint

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by kiran.mate
    I want to open the text file when user clicks on the text file draged & droped onto richtextbox.On some machine it is opened but on other it is not.
    This concerns me. In situations like this, it generally is not the fault of the code, but something wrong with the machine.

    How are the machines that it does not work on different from the machines that it does work on?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Oct 2007
    Location
    India,Maharashtra,Pune,Khadakwasla
    Posts
    5
    The m/c on which it worked is having vb 6 sp6 on other m/c no sp6.So I installed sp6 on non working 3 m/c.Now on One of 3 non working m/c,it worked ,prompted me for open file dlg(packager window) when I dbl click on file but rest of 2 m/c still same behavior.
    I finally set richtextbox OLEDropMode Manual,catched OLEDragDrop event & in that event written below code
    Richtextbox1.OLEObjects.add ,,data.files(1)
    Now I'm able to catch OLEDragDrop as well as Dropped text/paint files r shown in richtextbox.But with above code ,when I DragDrop text file it is opened automatically,When I dragDrop Paint file it is activated in richtextbox itself.I don't want to display/activate the file dragdropped on richtextbox.I want it to be opened only when user dbl clicks on the file name in richtextbox.
    Is there any way to avoid automatic display/activation of file dragdropped on richtextbox
    thanks

  9. #9
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    You must have some programming code that opens it right?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 5
    Last Post: 06-18-2007, 01:13 PM
  2. Replies: 0
    Last Post: 08-29-2003, 12:15 AM
  3. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 12:45 PM
  4. Rich Edit Control
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 16
    Last Post: 08-08-2001, 08:35 PM
  5. WEIRD ActiveX control problem
    By Glenn in forum ASP.NET
    Replies: 0
    Last Post: 12-13-2000, 08:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center