Re: Edit text fields in child windows
Dan Moyer wrote:
>
> Rad wrote:
> >
> > CChris wrote:
> > >
> > > I tried various things, and came up with the following:
> > > 1/ the window procedure associated to a window with the WS_CHILD flag
> > > doesn't send the right messages to an edit field when the latter gets
> > > mouse
> > > clicks (and it actually gets them). Edit fields are supposed to appear in
> > > top level windows or in dialog boxes.
> > >
> > > 2/ Edit fields are antiquated components that existed before win 3.0. This
> > > may explain 1/, and why 1/ doesn't have an easy fix.
> > >
> > > 3/ But after all, RichEdit controls are more recent and don't depend so
> > > much
> > > on the parent, so use RichEdit instead of EditText in child windows.
> > >
> > > 4/ But you'll have to create them with the right styles, and using
> > > findText()
> > > will fail on NT based systems (will be fixed in the next version of
> > > win32lib).
> > > Does the code in <a
> > > href="http://www.listfilter.com/EUforum/m13681.htm">http://www.listfilter.com/EUforum/m13681.htm</a>
> > > help? See if it works for you.
> > >
> > > CChris
> >
> > Hi CChris,
> >
> > As I would like to use RichEdit in place of the EditText control, is there a
> > way to limit text to specified characters within one line at the same time
> > not
> > allowing to move to next line within RichEdit by pressing RETURN key?
> >
> > I used "Limit Text To:" property in IDE to set max characters, but I can
> > press
> > Return key and continue on next line, which I want to avoid.
> >
> > Regards,
> > Rad.
>
> Rad,
>
> I can't be sure if this will help, nor can I fill in the details right now,
> but:
>
> I think you could set a trap for the enter/return key in some event like
> w32HKeyDown, or w32HKeyPress, for the RichEdit,
> and then make the routine have a return if the enter key pressed,
> which should/might make the enter key be ignored.
> (ie, if keypressed equal "enter" key, then return from procedure)
>
> Dan Moyer
And here's a variation on above that uses Win32Lib "returnValue",
which might be the right way to do what you want,
from the Win32Lib documentation:
(just use VK_RETURN instead of VK_SPACE, and put in event for RichEdit
instead of Button1 in example below)
-- prevent Button1 from seeing any space bar keys
procedure Button1_KeyDown( integer self, integer event, sequence parms)
integer keycode
integer shift
keycode = parms[1]
shift = parms[2]
if keycode = VK_SPACE then
-- set return value
returnValue( w32True )
end if
end procedure
setHandler( Button1, w32HKeyDown, routine_id("Button1_KeyDown"))
Dan Moyer
|
Not Categorized, Please Help
|
|