RE: Moving the Cursor

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi All,

Here is my attempt at moving the caret (not the cursor - I think that 
means the mouse pointer):

-- Set caret position whilst editing
-- Phil Russell August 2002

include win32lib.ew
without warning
with trace

constant
    Win     = create( Window, "Caret Position", 0, Default, Default, 
200, 100, 0 ),
    Sle    = create( EditText, "", Win, 10, 20, 120, 20, 0 )

-- Add formatting to text string
function addDashes( sequence text)

     if find( length( text), {3,8}) then
		text = text &'-'
     end if

     return text
end function

-- Process events after windows handling is completed
procedure after_event (integer self, integer event, sequence parms)
     atom key, junk, msg
     msg = parms[1]
     key = parms[2]

     -- Amend text after wm_char has been processed
	 if msg=WM_CHAR and key != VK_BACK then
	 	setText(self, addDashes(getText(self)))
	 	junk = sendMessage(self, EM_SETSEL, 0, -1 )
	 	junk = sendMessage(self, EM_SETSEL, -1, -1 )
	 end if

end procedure

setHandler(Sle, w32HAfterEvent, routine_id("after_event"))
WinMain( Win, Normal )

Works for me on Win2K

Regards,

Phil Russell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu