Code archives/Miscellaneous/cut / copy / paste / undo / redo

This code has been declared by its author to be Public Domain code.

Download source code

cut / copy / paste / undo / redo by Red2003
B+
Note : it's not a multilevel undo / redo


Userlibs : userlibs/user32.decls
.lib "user32.dll"
SendMessage%(hwnd, msg, wParam, mParam):"SendMessageA"


Example :
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 :
;---------------------------------------------------

Function TextAreaUndo(txt)
	Local EM_UNDO=$C7
	SendMessage(QueryObject(txt,1), EN_UNDO, 0, 0)
End Function 

;---------------------------------------------------

Function TextAreaRedo(txt)
	Local EM_REDO=$454
	SendMessage(QueryObject(txt,1), EM_REDO, 0, 0)
End Function 

;---------------------------------------------------

Function TextAreaCut(txt)
	Local WM_CUT=$300
	SendMessage(QueryObject(txt,1), WM_CUT, 0, 0)
End Function 

;---------------------------------------------------

Function TextAreaCopy(txt)
	Local WM_COPY=$301
	SendMessage(QueryObject(txt,1), WM_COPY, 0, 0)
End Function 

;---------------------------------------------------

Function TextAreaPaste(txt)
	Local WM_PASTE=$302
	SendMessage(QueryObject(txt,1), WM_PASTE, 0, 0)
End Function 
	
;---------------------------------------------------

Comments

None.

Code Archives Forum