Ooops
March 05, 2021, 06:53:27 AM

Author Topic: [bb] cut / copy / paste / undo / redo by Red [ 1+ years ago ]  (Read 487 times)

Offline BlitzBot

Title : cut / copy / paste / undo / redo
Author : Red
Posted : 1+ years ago

Description : B+
Note : it's not a multilevel undo / redo
Userlibs : userlibs/user32.decls
Code: [Select]
.lib "user32.dll"
SendMessage%(hwnd, msg, wParam, mParam):"SendMessageA"


Example :
Code: [Select]
win=CreateWindow("",0,0,300,300,0,1)

mytext=CreateTextArea (5,5,280,200,win)

cut=CreateButton("cut",5,210,30,20,win )
copy=CreateButton("copy",45,210,30,20,win )
paste=CreateButton("paste",85,210,30,20,win )

undo=CreateButton("undo",5,240,30,20,win )
redo=CreateButton("redo",45,240,30,20,win )

Repeat
If EventID()=$401
Select EventSource()
Case cut
TextAreaCut(mytext)

Case copy
TextAreaCopy(mytext)

Case paste
TextAreaPaste(mytext)

Case undo
TextAreaUndo(mytext)

Case redo
TextAreaRedo(mytext)

End Select
EndIf
Until WaitEvent()=$803

Functions : [/i]

Code :
Code: BlitzBasic
  1. ;---------------------------------------------------
  2.  
  3. Function TextAreaUndo(txt)
  4.         Local EM_UNDO=$C7
  5.         SendMessage(QueryObject(txt,1), EN_UNDO, 0, 0)
  6. End Function
  7.  
  8. ;---------------------------------------------------
  9.  
  10. Function TextAreaRedo(txt)
  11.         Local EM_REDO=$454
  12.         SendMessage(QueryObject(txt,1), EM_REDO, 0, 0)
  13. End Function
  14.  
  15. ;---------------------------------------------------
  16.  
  17. Function TextAreaCut(txt)
  18.         Local WM_CUT=$300
  19.         SendMessage(QueryObject(txt,1), WM_CUT, 0, 0)
  20. End Function
  21.  
  22. ;---------------------------------------------------
  23.  
  24. Function TextAreaCopy(txt)
  25.         Local WM_COPY=$301
  26.         SendMessage(QueryObject(txt,1), WM_COPY, 0, 0)
  27. End Function
  28.  
  29. ;---------------------------------------------------
  30.  
  31. Function TextAreaPaste(txt)
  32.         Local WM_PASTE=$302
  33.         SendMessage(QueryObject(txt,1), WM_PASTE, 0, 0)
  34. End Function
  35.        
  36. ;---------------------------------------------------


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal