Paste Text as RTF and Plain Text in EditorGadget [Windows]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Paste Text as RTF and Plain Text in EditorGadget [Windows]

Post by RASHAD »

We can Paste Text as RTF or Plain Text in the same session
Using Ctrl-V
Tested with PB 4.60 - Win 7 x86 - XP x86

Code: Select all


If OpenWindow(0, 0, 0, 400, 290, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 10,10, 380, 240)  
  ButtonGadget(1, 10, 260, 80, 20, "RTF")
  ButtonGadget(2, 100, 260, 80, 20, "Pain Text")
Repeat
 
  Select WaitWindowEvent()
      
       Case #PB_Event_CloseWindow
          Quit = 1

       Case #PB_Event_Menu
          Select EventMenu()
           Case 15
              Result = CountGadgetItems(0)              
              SetGadgetItemText(0, Result, GetClipboardText())
                          
          EndSelect       
     
      Case #PB_Event_Gadget
          Select EventGadget()
           Case 1
             RemoveKeyboardShortcut(0,#PB_Shortcut_Control | #PB_Shortcut_V)

           Case 2
             AddKeyboardShortcut(0,#PB_Shortcut_Control | #PB_Shortcut_V, 15)
                       
          EndSelect
  EndSelect
Until Quit = 1

EndIf

Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Paste Text as RTF and Plain Text in EditorGadget [Window

Post by RASHAD »

Sorry for not being clear enough

http://www.purebasic.fr/english/viewtop ... 13&t=47896

This snippet is about converting RTF to Plain Text using PB EditorGadget
For example :
1- Open Windows WordPad
2- Write any paragraph in different styles
3- Copy the paragraph
4- Run the snippet

Now you can paste the copied material in Two Different styles
RTF
Plain Text
At the same session (Keeping Both)

Have fun
Egypt my love
Post Reply