Re: Edit text fields in child windows
- Posted by Chris McConnell <chris at mc-data.com> Apr 25, 2007
- 516 views
CChris 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. > > > Limiting text length, ie the amount of characters, won't work, this is a > feature of EditText controls. > > I had posted the following test code: > }}} <eucode> > constant Window1 = createEx( Window, "Window1", 0, Default, Default, 200, 140, > 0, 0 ) > constant CWindow3 = createEx( Window, "", Window1, 56, 24, 200, 100, > w32or_all({WS_CHILD}), > 0 ) > openWindow(CWindow3, Normal) > constant EditText4 = createEx( RichEdit, "EditText4", CWindow3, 8, 28, 48, 20, > {w32or_all( { WS_CLIPPINGCHILD, > WS_VISIBLE, > ES_AUTOHSCROLL, > WS_TABSTOP, > ES_SAVESEL, > WS_BORDER } )} > , 0 ) > > WinMain( Window1,Normal ) > </eucode> {{{ > Try it and see if this displays decently enough for your purpose. At least, > it won't go to next line on pressing enter and won't display horizontal > scroll bars. You can't remove some styles after creation, so be sure to > create the control with the right styles. > > Why do you need the parent window to be a child window? The only benefit > this style gives you is auto clipping (wrt both parent and siblings), and I > just can't figure how windows with edit controls benefit from that. > Removing the style will enable you to use EditTexts as you initially > intended. > > CChris I liked child windows because they are contained in the parent and close with the parent. It is just a matter of preference. I am sure with some code the window can be closed with what I consider a window parent if the style is removed.