Kuan Hsu wrote:
We can't insert text in ACTION callback function, this callback function trigger when the text is edited, but before its value is actually changed.(from IUP document)
In poseidonFB, I declare a global variable( just boolean ) and catch the "ENTER" in K_ANY( or ACTION ) callback to change the value, if the variable is true, insert the "bla bla" in CARET_CB callback( if ENTER, the CARET_CB must trigger ).
Many thanks to my friend, I already began to think this way, but until recently I hoped that there was still some way to make changes in the event "ACTION". In Windows, using the technique of subclassing, you can change the value for Control "EDIT" before the changes in the editor (ниже пример). But, since in the IUP library, this can not be done in the Scintilla, I will do it according to your method.
--------------------------
Perhaps you know all this, but I decided to show the really correct approach applied in the Windows API. It's unclear why the IUP author did not do this for the ACTION event. The example works with freebasic compilier 32-bit, I did not test it with 64-bit compilier. After starting the example and pressing "Enter" , Instead, it will "SPACE":
Code: Select all
#INCLUDE "windows.bi"
LoadLibrary "RICHED20.DLL"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass"
Dim As HINSTANCE Hinst=GetModuleHandle(0)
Dim Shared As Integer OldWndproc
' EDIT proc CALLBACK
Function editproc_cb(hwnd As HWND, msg As Uinteger,_
wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_CHAR
Dim As Byte bChar = Cast(Byte ,LoByte(wparam))
If bChar = 13 Then
*Cast(Byte Ptr ,@wparam) = 32 ' change to space
EndIf
Case WM_KEYDOWN
If LoByte(wparam) = VK_RETURN Then
Return 0
EndIf
End Select
Return CallWindowProc(Cast(Any Ptr,OldWndproc),hwnd, msg, wparam ,lparam)
End Function
Function wndproc(hwnd As HWND, msg As Uinteger,_
wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_DESTROY
PostQuitMessage(0)
Case WM_CREATE
Var edit = CreateWindowEx(WS_EX_CLIENTEDGE, "RICHEDIT20A", "RichEdit Control",_
WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL Or ES_MULTILINE Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL,_
10,10,200,200, hwnd, Cast(HMENU,1), 0, 0)
OldWndproc = SetWindowLongPtr(edit ,GWL_WNDPROC , Cast(Integer , @editproc_cb))
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc=@wndproc
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_WINLOGO)
.hCursor=LoadCursor(0,IDC_ARROW)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
If RegisterClassEx(@wc)=0 Then
Print "Register error, press any key"
Sleep
End
Endif
CreateWindowEx(0,NameClass,"RichEdit",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,240,260,0,0,Hinst,0)
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend