Announcement

Collapse
No announcement yet.

Rich Edit Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gösta H. Lovgren-2
    replied
    Originally posted by Steve Bouffe View Post
    I'll hve a dig around the forums tomorrow and see if I can find how to do this.

    Cheers!
    Maybe I can save you a little time, Steve. The function "Clipboard_Get_Text" (below) will just return straight text, which you can retrieve and plug into your control. Or just use the Macro.

    Code:
    '<== Start of Clipboard as an Include ==>
    'Clipboard stuff gotten from Poffs but I forget from whom
    '
    'Note t$ must be initialized - Local t$
     
    Function Clipboard_Set_Text Alias "Clipboard_Set_Text" _
    (ByVal sText As String) Export As Long
    Local hData As Long, hGlob As Long
     
    ' ** Create a global memory object and copy the data into it
    hData = GlobalAlloc(%GMEM_MOVEABLE Or %GMEM_DDESHARE, Len(sText) + 1)
    hGlob = GlobalLock(hData)
    Poke$ hGlob, sText + Chr$(0)
    GlobalUnlock hData
     
    ' ** Open the clipboard
    If IsFalse(OpenClipboard(%Null)) Then
    GlobalFree hData
    Exit Function
    End If
     
    ' ** Paste the data into the clipboard
    EmptyClipboard 'WinAPI
    Function = SetClipboardData(%CF_TEXT, hData) 'WinAPI
    CloseClipboard 'WinAPI
    End Function
     
    Function Clipboard_Get_Text Alias "Clipboard_Get_Text"() Export As String
    Local zPtr As Asciiz Ptr
    OpenClipboard 0 'WinAPI
    zPtr = GetClipboardData(%CF_TEXT)
    If zPtr <> 0 Then Function = @zPtr
    CloseClipboard 'WinAPI
    End Function
    ' 
     
    '
    Macro Get_Clipboard = t$ = Clipboard_Get_Text 'put cb in tb at program start 
    '
    Macro Set_Clipboard = Clipboard_Set_Text(t$)
    '
     
    '<== End of Clipboard as an Include ==>
    ===============================================
    Talk sense to a fool and he calls you foolish.
    Euripides
    ===============================================
    Last edited by Gary Beene; 12 Jul 2014, 12:02 AM. Reason: Speling

    Leave a comment:


  • Steve Bouffe
    replied
    I'll hve a dig around the forums tomorrow and see if I can find how to do this.

    Cheers!

    Leave a comment:


  • Kev Peel
    replied
    If you mean when the user is pasting text from the clipboard, you have to subclass the RichEdit control and intercept WM_PASTE - from there you can grab the clipboard data as plain text and use EM_REPLACESEL to insert it, then exit the subclass proc without allowing the control to ever receive WM_PASTE.

    Leave a comment:


  • Steve Bouffe
    replied
    Ronald, sounds like a great solution but I have no idea how to do this!

    Leave a comment:


  • Ronald Zutz
    replied
    Paste In Another Format

    Assuming you mean cutting from web page and pasting into an MS richedit control:
    1. Subclass the richedit control.
    2. Monitor for the Ctrl+V paste command.
    3. OpenClipboard.
    4. Browsers (at least Firefox and IE) copy multiple clipboard formats, including a standard clipboard format %CF_TEXT. (You may want to check for another which better meets your needs.) Use IsClipboardFormatAvailable to verify clipboard has data in that format.
    5. Retrieve your desired format with GetClipboardData into a memory block.
    6. Insert the memory block at the richedit control's selection.
    7. CloseClipboard, which will also free the memory block.
    Hope this helps.

    Ron Zutz

    Leave a comment:


  • Steve Bouffe
    started a topic Rich Edit Question

    Rich Edit Question

    I'm using a richedit control for user input. When the user copies text from a web page, I need to discard all font/ colour formatting. Can this be done?
Working...
X