Difference between revisions of "Multilines"
From Team Developer SqlWindows Wiki
DaveRabelink (Talk | contribs) |
|||
Line 1: | Line 1: | ||
− | This page covers | + | '''This page covers Multiline tips & tricks.''' |
__TOC__ | __TOC__ | ||
<br> | <br> | ||
− | < | + | <!------------------------------------------------------------------------------------------------------------------------------> |
+ | {{TipHeader|How to place the cursor at a specific location in the text, text selection and insertion}} | ||
First define these WinApi constants | First define these WinApi constants | ||
<pre> | <pre> | ||
Line 67: | Line 68: | ||
− | < | + | <!------------------------------------------------------------------------------------------------------------------------------> |
+ | {{TipHeader|How to make a scrollable but disabled multiline}} | ||
When you disable the field, the scrollbars are also disabled.<br> | When you disable the field, the scrollbars are also disabled.<br> | ||
<br> | <br> |
Revision as of 21:48, 24 September 2008
This page covers Multiline tips & tricks.
Contents |
How to place the cursor at a specific location in the text, text selection and insertion 
First define these WinApi constants
Number: EM_GETSEL = 0x00B0 Number: EM_SETSEL = 0x00B1 Number: EM_SCROLLCARET = 0x00B7 Number: EM_REPLACESEL = 0x00C2
To place the cursor/caret at a specific character location (nPos).
0 (zero) means the first location from the left
! Place the cursor at position 200 in the text. Set left and right position at the same value Set nLeftPos = 200 Set nRightPos = 200 Call SalSendMsg( hWndField, EM_SETSEL, nLeftPos, nRightPos ) ! ! When the cursor is out of view, the field does not scroll automatically, so you should scroll it by using : Call SalSendMsg( hWndField, EM_SCROLLCARET, 0, 0 )
When text should be selected, use different values for nLeftPos and nRightPos
Set nLeftPos = 200 Set nRightPos = 210 Call SalSendMsg( hWndField, EM_SETSEL, nLeftPos, nRightPos )
To deselect text use
Call SalSendMsg( hWndField, EM_SETSEL, -1, -1 )
To insert text at a specific location
! Place the cursor at position 200 in the text. Set left and right position at the same value Set nLeftPos = 200 Set nRightPos = 200 Call SalSendMsg( hWndField, EM_SETSEL, nLeftPos, nRightPos ) ! ! Now insert some text at the current caret position Call VisSendMsgString( hWndField, EM_REPLACESEL, TRUE, "This will be inserted" )
To replace text which is selected, like above except use the appropriate nLeftPos and nRightPos values.
Now to get the current position/selection boundaries
Set nReturn = SalSendMsg( hWndField, EM_GETSEL, 0, 0 ) ! Set nLeftPos = SalNumberLow( nReturn ) Set nRightPos = SalNumberHigh( nReturn )
If no selections are performed above, you should first set the focus to the field
Call SalSetFocus( hWndField )
How to make a scrollable but disabled multiline 
When you disable the field, the scrollbars are also disabled.
Use this instead to have scrolling
Call VisWinSetFlags ( hWndField, WF_DisplayOnly, TRUE )