1. Win32lib question RE: edit controls
- Posted by SR Williamson <sr.williamson at OSHA.GOV> Mar 15, 2000
- 446 views
I'm trying to rebuild a program in Eu that I wrote in BCPPB. It's a small HTML formatting pad for people that frequently use message boards. Basically, a user types text into an edit control, highlights a section, pushes a button, and the program inserts HTML tags at the beginning and the end of the highlighted section. In BCPPB, the program was trivial because the Builder Edit Control has a SelectAll method. I can't seem to find an equivalent procedure in Win32lib, or anywhere else in Eu for that matter, and I can't figure out a way to write the program without it. Any suggestions? Sherm
2. Re: Win32lib question RE: edit controls
- Posted by Brian Broker <bkb at CNW.COM> Mar 15, 2000
- 421 views
On Wed, 15 Mar 2000 09:49:45 -0500, SR Williamson wrote: >I'm trying to rebuild a program in Eu that I wrote in BCPPB. It's a small >HTML formatting pad for people that frequently use message boards. >Basically, a user types text into an edit control, highlights a section, >pushes a button, and the program inserts HTML tags at the beginning and the= >end of the highlighted section. > >In BCPPB, the program was trivial because the Builder Edit Control has a >SelectAll method. I can't seem to find an equivalent procedure in Win32lib,= >or anywhere else in Eu for that matter, and I can't figure out a way to >write the program without it. > >Any suggestions? >Sherm Hi Sherm, To select all text in an Edit Control, you will need to send an EM_SETSEL message to the control. Win32Lib provides 'sendMessage( control, command, wParam, lParam )'. In this case, wParam is the starting position (nStart) and lParam is the ending position (nEnd). If the nStart parameter is 0 and the nEnd parameter is =961, all the text in the edit control is selected. If nStart is =961, an= y current selection is removed. The caret is placed at the end of the selection indicated by the greater of the two values nEnd and nStart. You don't need to define EM_SETSEL because it is already defined in Win32Lib. Hope this helps. (I'm not sure if this is what you are asking but there are many other Edit control messages that should help you do what you want.)= -- Brian
3. Re: Win32lib question RE: edit controls
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Mar 15, 2000
- 450 views
SR Williamson wrote: > Basically, a user types text into an edit control, > highlights a section, pushes a button, and the > program inserts HTML tags at the beginning and the > end of the highlighted section. I'd suggest getting the "WIN32 API Documentation" help file from the RDS site. There's a ton of good information there, and it's not difficult to add new wrappers and traps to Win32Lib. I consider it essential when writing Windows programs. Use EM_GETSEL to get the position of the selected text. Use EM_REPLACESEL to replace the text with the new code. I haven't had a chance to test it, but something along the lines of this should work. I should add setSelectedText and getSelectedText to Win32Lib: -- selected text messages global constant EM_GETSEL = 176, EM_SETSEL = 177 integer firstPos, lastPos atom result, addrFirst, addrLast, addrText sequence text -- allocate addresses to store the results addrFirst = allocate( 4 ) addrLast = allocate( 4 ) -- get the range of selected text result = sendMessage( TheMle, EM_GETSEL, addrFirst, addrLast ) firstPos = peek4s( addrFirst ) lastPos = peek4s( addrLast ) - 1 -- is any text selected? if firstPos then -- get all the text text from the mle text = getText( TheMle ) -- get the selected portion of the text selText = text[firstPos..lastPos] -- add html formatting text = "<tag>" & text & "</tag>" -- convert to lpsz addrText = allocate_string( text ) -- replace selection; True means allow undo result = sendMessage( TheMle, EM_REPLACESEL, True, addrText ) -- free the string free_string( addrText ) end if -- free memory free( addrFirst ) free( addrLast ) Hope this helps! -- David Cuny
4. Re: Win32lib question RE: edit controls
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Mar 15, 2000
- 445 views
SR Williamson wrote: > ... edit control ... Try these; they're more generic and I've had a chance to test them a bit. -- David Cuny global function getSelectedText( integer id ) integer firstPos, lastPos atom result sequence text -- get the range of selected text result = sendMessage( id, EM_GETSEL, NULL, NULL ) firstPos = lo_word( result ) lastPos = hi_word( result ) -- is any text selected? if firstPos < lastPos then -- get all the text text from the mle text = getText( id ) -- get the selected portion of the text return text[firstPos+1..lastPos] else -- no text selected return "" end if end function global procedure setSelectedText( integer id, sequence text ) atom addrText, result -- is there any text selected? result = sendMessage( id, EM_GETSEL, NULL, NULL ) if lo_word( result ) < hi_word( result ) then -- convert to lpsz addrText = allocate_string( text ) -- replace selection; True means allow undo result = sendMessage( id, EM_REPLACESEL, True, addrText ) -- free the string free( addrText ) end if end procedure