Difference between revisions of "Multilines"

From Team Developer SqlWindows Wiki
Jump to: navigation, search
Line 1: Line 1:
This page covers multiline tips & tricks.
+
'''This page covers Multiline tips & tricks.'''
  
 
__TOC__
 
__TOC__
 
<br>
 
<br>
  
<h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold;border:1px solid #afa3bf;text-align:left;color:#000;padding:0.2em 0.4em;">[[Image:Pointer.png]]How to place the cursor at a specific location in the text, text selection and insertion</h2>
+
<!------------------------------------------------------------------------------------------------------------------------------>
 +
{{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:
  
  
<h2 style="margin:0;background-color:#ddcef2;font-size:120%;font-weight:bold;border:1px solid #afa3bf;text-align:left;color:#000;padding:0.2em 0.4em;">[[Image:Pointer.png]]How to make a scrollable but disabled multiline</h2>
+
<!------------------------------------------------------------------------------------------------------------------------------>
 +
{{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 20:48, 24 September 2008

This page covers Multiline tips & tricks.

Contents


Pointer2.png How to place the cursor at a specific location in the text, text selection and insertion Pointer.png

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 )


Pointer2.png How to make a scrollable but disabled multiline Pointer.png

When you disable the field, the scrollbars are also disabled.

Use this instead to have scrolling

   Call VisWinSetFlags ( hWndField, WF_DisplayOnly, TRUE )