Re: Windows Help - how to change text color of an edit field when it changes?
- Posted by Dan Moyer <danielmoyer at prodigy.net> Mar 20, 2007
- 544 views
Andrew Katz wrote: > > I am new to Windows programming, so I would like to know where to code the > following > situation: > > I have an edit control, and I want the text color to change if the user alters > that field. I tried the onChange (IDE class module for the event) (for > w32HChange) > of the edit control. But it does not do anything. And if I place a setText > call > for that control in the event handler, it crashes. > > Andy Katz > > B.S. Computer Science, 1978 > Rensselaer Polytechnic Institute (RPI) Andy, The following worked for me:
-- code generated by Win32Lib IDE v0.20.1 include Win32Lib.ew without warning -------------------------------------------------------------------------------- -- Window Window1 constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, 0, 0 ) constant EditText2 = createEx( EditText, "EditText2", Window1, 76, 64, 200, 20, 0, 0 ) --------------------------------------------------------- -------------------------------------------------------------------------------- sequence SomeTextInEdit -------------------------------------------------------------------------------- procedure Window1_onActivate (integer self, integer event, sequence params)--params is () SomeTextInEdit = getText(EditText2) end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) -------------------------------------------------------------------------------- procedure EditText2_onKeyPress (integer self, integer event, sequence params)--params is ( int keyCode, int shift ) if params[1] = VK_RETURN and not equal(SomeTextInEdit, getText(EditText2))then setWindowBackColor(EditText2, Pink) end if end procedure setHandler( EditText2, w32HKeyPress, routine_id("EditText2_onKeyPress")) WinMain( Window1,Normal )
Dan Moyer