菜鸟免看

silence_lamb 2002-01-26 07:25:49
TEXT文本类型的字段,如何找到光标在其中的位置?请高手指点
...全文
156 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanwei 2002-01-28
  • 打赏
  • 举报
回复
All these maybe no use for you,sorry!
zhanwei 2002-01-28
  • 打赏
  • 举报
回复
The DataWindow object in the DataWindow control must be a RichTextEdit DataWindow
zhanwei 2002-01-28
  • 打赏
  • 举报
回复
Description

Determines the line and column position of the insertion point or the start and end of selected text in an RichTextEdit control.

Controls

RichTextEdit and DataWindow controls

Syntax

rtename.Position ( fromline, fromchar {, toline, tochar } )
Argument Description
rtename The name of the RichTextEdit or DataWindow control in which you want to find the location of the insertion point or selected text. The DataWindow object in the DataWindow control must be a RichTextEdit DataWindow
fromline A long variable in which you want to save the number of the line where the insertion point or the start of the selection is
fromchar A long variable in which you want to save the number in the line of the first character in the selection or after the insertion point
toline (optional) A long variable in which you want to save the number of the line where the selection ends
tochar (optional) A long variable in which you want to save the number in the line of the character before which the selection ends
Return value
Band enumerated data type. Returns the band (Detail!, Header!, or Footer!) containing the selection or insertion point.
Usage
Position reports the position of the insertion point if you omit the toline and tochar arguments. If text is selected, the insertion point can be at the beginning or the end of the selection. For example, if the user dragged down to select text, the insertion point is at the end.
If there is a selection, a character argument can be set to 0 to indicate that the selection begins or ends at the start of a line, with nothing else selected on that line. When the user drags up, the selection can begin at the start of a line and fromchar is set to 0. When the user drags down, the selection can end at the beginning of a line and tochar is set to 0.

Selection or insertion point
To find out whether there is a selection or just an insertion point, specify all four arguments. If toline and tochar are set to 0, then there is no selection, only an insertion point. If there is a selection and you want the position of the insertion point, you will have to call Position again with only two arguments. This difference is described next.
The position of the insertion point and end of selection can differ

When reporting the position of selected text, the positions are inclusive桺osition reports the first line and character and the last line and character that are selected. When reporting the position of the insertion point, Position identifies the character just after the insertion point. Therefore, if text is selected and the insertion point is at the end, the values for the insertion point and the end of the selection differ.
To illustrate, suppose the first four characters in line 1 are selected and the insertion point is at the end. If you request the position of the insertion point:

rte_1.Position(ll_line, ll_char)

Then:

?ll_line is set to 1
?ll_char is set to 5, the character following the insertion point

If you request the position of the selection:

rte_1.Position(ll_startline, ll_startchar, &

ll_endline, ll_endchar)

?ll_startline and ll_startchar are both set to 1
?ll_endline is 1 and ll_endchar is set to 4, the last character in the selection

Passing values to SelectText

Because values obtained with Position provide more information that simply a selection range, you cannot pass the values directly to SelectText. In particular, 0 is not a valid character position when selecting text, although it is meaningful in describing the selection.
bobby_h 2002-01-27
  • 打赏
  • 举报
回复
回去练练api。
ideage 2002-01-27
  • 打赏
  • 举报
回复
Delphi有类似的例程。API可以用!关注!(虽然我是菜鸟)
silence_lamb 2002-01-27
  • 打赏
  • 举报
回复
感谢大家的支持和帮助,其实我也是菜鸟,无非是事情紧急才不得已取这样的哗众取宠的名字,请大家见谅!
tiantianpb 2002-01-26
  • 打赏
  • 举报
回复
调用windows api函数,试试,具体的那个函数,帮你查查!
killerdanny 2002-01-26
  • 打赏
  • 举报
回复
经常在战网上看到这样的话,2VS2菜鸟免进!1V1高手来!没做过,不过可以给你试试!

401

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 非技术版
社区管理员
  • 非技术版社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧