我用createwindow 创建一个windows sdk edit控件,但不知道如何处理delete操作;就是将光标移入已输入edit的字串中间,敲delete键。 此操作如何完成呢?关键是如何得到光标在字串中的确切位置。 

解决方案 »

  1.   

    看msdn
    EM_GETSEL
    The EM_GETSEL message retrieves the starting and ending character positions of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.To send this message, call the SendMessage function with the following parameters. SendMessage( 
      (HWND) hWnd,              // handle to destination window 
      EM_GETSEL,                // message to send
      (WPARAM) wParam,          // starting position (LPDWORD)
      (LPARAM) lParam          // ending position (LPDWORD)
    );
      

  2.   

    谢谢楼上。
    不过
    EM_GETSEL 
    EM_SETSEL
    是鼠标选择的部分字串吧。 光标移动位置哪来划定字串开始与结束范围呢?
      

  3.   

     还想请教一个问题。 EM_GETSEL消息需要父窗口向edit控件发送sendmessage。请问除了这种方法还有其他途径,可以让edit获取EM_GETSEL消息。 
      

  4.   

    to aaronwang81:我是用自己写的窗口函数设置成edit的窗口函数,在这里面 没有响应EM_GETSEL消息。 你所说的默认处理函数是父窗口的默认窗口函数吧? 
      

  5.   

    EM_GETSEL消息需要父窗口向edit控件发送sendmessage。??SendMessage(  
        (HWND)   hWnd,                             //   handle   to   destination   window  
        EM_GETSEL,                                 //   message   to   send
        (WPARAM)   wParam,                     //   starting   position   (LPDWORD)
        (LPARAM)   lParam                     //   ending   position   (LPDWORD)
    ); 其中的hWnd为edit控件的句柄,而调用SendMessage的可以是任何代码