Re: EditBox control: increase capacity
Posted: Thu Jul 11, 2013 11:22 pm
Wow Carlos, nice idea.
but with the new functions of HMG the code is more simple.
but with the new functions of HMG the code is more simple.
Code: Select all
#include "hmg.ch"
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'HMG Demo' ;
ICON 'DEMO.ICO' ;
MAIN
@ 30,10 EDITBOX Edit_1 ;
WIDTH 410 ;
HEIGHT 140 ;
VALUE 'EditBox!!';
MAXLENGTH 0 // same as --> SendMessage (GetControlHandle("Edit_1","Form_1"), 197, 0, 0 )
DEFINE BUTTON D
ROW 250
COL 290
WIDTH 130
CAPTION '_GetCaretPos'
ACTION MsgInfo (Form1.Edit_1.CaretPos) // ---> MsgInfo() --> convert xData to STR
END BUTTON
END WINDOW
// CREATE EVENT PROCNAME OnkeyEdit_1() HWND GetControlHandle("Edit_1","Form_1") // --> Work only with Form1.Edit_1
CREATE EVENT PROCNAME OnkeyAllEditBox() // --> Work with all EditBox controls
Form_1.Center()
Form_1.Activate()
Return Nil
Function OnkeyEdit_1()
IF EventMSG() == WM_CHAR
IF .NOT. (GetKeyState(VK_INSERT) == 0) .AND. HMG_GetLastVirtualKeyDown() != VK_RETURN .AND. HMG_GetLastVirtualKeyDown() != VK_BACK
SendMessage (EventHWND(), WM_KEYDOWN, VK_DELETE, 0)
ENDIF
ENDIF
Return NIL
Function OnkeyAllEditBox()
LOCAL nIndex := GetControlIndexByHandle (EventHWND())
IF nIndex > 0 .AND. GetControlTypeByIndex (nIndex) == "EDIT"
IF EventMSG() == WM_CHAR
IF .NOT. (GetKeyState (VK_INSERT) == 0) .AND. HMG_GetLastVirtualKeyDown() != VK_RETURN .AND. HMG_GetLastVirtualKeyDown() != VK_BACK
SendMessage (EventHWND(), WM_KEYDOWN, VK_DELETE, 0)
ENDIF
ENDIF
ENDIF
Return NIL