i:=MaskEdit1.SelStart;

解决方案 »

  1.   

    to Apollo47:
         谢谢你的帮助。但在TEdit控件中是如何获取光标位置的?
      

  2.   

    这在简单了:一样是用edit1.selstart;请看帮助里讲:
    Read SelStart to determine the position of the first selected character, where 0 indicates the first character. 
    **If there is no selected text, SelStart indicates the position of the cursor.
      

  3.   

    看来你们还没有理解我的另一问。在TEdit控件里并没有选定哪个字符,光标是处于insert的状态的。此时如何取的光标的位置值?
      

  4.   

    是我没有说清楚TEdit控件光标位置问题。另对于SendMessage(MaskEdit1.Handle,EM_GETSEL,StartLoc,EndLoc)返回的两个参数值是什么意思?我追进代码时看到的是一个16个数字的整数,请问这个又代表什么意思?
      

  5.   

    If there is no selected text, SelStart indicates the position of the cursor;
    这句话的意思应该是:如果没有选择文本(字符),SelStart就指出了光标所处的位置。你也可试一下嘛,我试过了,精准!
      

  6.   

    谢谢clacklin(海风),昨天没有仔细看所以没看到If there is no selected text, SelStart indicates the position of the cursor这句话。对于那个消息哪位有何见解呀!
      

  7.   

    EM_GETSEL返回的是两个位置:开始选择的位置和结束选择的位置,帮助上面说得很明白!
    如果要用消息获得光标的位置,不是这个消息,而是:EM_EXLINEFROMCHAR, EM_LINEINDEX