#include once "window9.bi"

Function UndoEditor(ByVal gadget As Long) As Integer Export
	Return SendMessage(GadgetID(gadget),EM_UNDO,0,0)
End Function

Function RedoEditor(ByVal gadget As Long) As Integer Export
	Return SendMessage(GadgetID(gadget),1108,0,0)
End Function

Sub PasteEditor(ByVal gadget As Long, ByRef txt As USTRING, ByVal param As integer)  Export
	#ifdef UNICODE
		SendMessage(GadgetID(gadget),EM_REPLACESEL, param, Cast(LPARAM,*txt))
	#else	
		SendMessage(GadgetID(gadget),EM_REPLACESEL, param, Cast(LPARAM,StrPtr(txt)))
	#EndIf
End Sub

Function CanUndoEditor(ByVal gadget As Long) As Integer Export
	Return SendMessage(GadgetID(gadget),EM_CANUNDO,0,0)
End Function

Function CanRedoEditor(ByVal gadget As Long) As Integer Export
	Return SendMessage(GadgetID(gadget),(&H400 + 85),0,0)
End Function

Sub EmptyUndoBufferEditor(ByVal gadget As Long)  Export
	SendMessage(GadgetID(gadget),EM_EMPTYUNDOBUFFER,0,0)
End Sub

Sub SetModifyEditor(ByVal gadget As Long, ByVal flag As Long) Export
	SendMessage(GadgetID(gadget),em_SetModify,CInt(flag),0)
End Sub

Sub SetPasswordChar(ByVal gadget As Long, ByVal CharCode As UBYTE) Export
	SendMessage(GadgetID(gadget),em_SetPasswordChar,CharCode,0)
End Sub

Function GetPasswordChar(ByVal gadget As Long) As UByte Export
	Return SendMessage(GadgetID(gadget),em_GetPasswordChar,0,0)
End Function

Function GetModifyEditor(ByVal gadget As Long) As Integer Export
	Return SendMessage(GadgetID(gadget),em_GetModify,0,0)
End Function

Function GetRectEditor(ByVal gadget As Long, ByVal rect As RECT Ptr) As integer Export
	Return SendMessage(GadgetID(gadget),EM_GetRect,0,Cast(LPARAM,rect))  
End Function

Function SetLimitTextEditor(ByVal gadget As Long, ByVal limit As integer) As integer Export
	Return SendMessage(GadgetID(gadget),em_LimitText,limit,0)  
End Function

Function SetRectEditor(ByVal gadget As Long, ByVal rect As RECT Ptr) As integer Export
	Return SendMessage(GadgetID(gadget),EM_SetRect,0,Cast(LPARAM,rect))  
End Function

