当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 有熟悉行情的高手 或者 请过来人谈谈你们的感受。 说得有参考价值的都有分 ......
 · 15260 错误 (再线等待)    »显示摘要«
    摘要: microsoft windows 2000 [version 5.00.2195] (c) 版权所有 1985-2000 microsoft corp. c:\>exp export: release 9.0.1.1.1 - production on 星期一 9月 22 14:54:23 2003 (c) copyright 2001 oracle corporation. al......


editor控件中,如何能在鼠标点击后知道点击在哪一行

editor控件中,如何能在鼠标点击后知道点击在哪一行?

NO.1   作者: kulukyo

在edit的父窗体中重载PreTranslateMessage,假设编辑框为IDC_EDIT3  
   
  BOOL   CTestView::PreTranslateMessage(MSG*   pMsg)    
  {  
  //   TODO:   Add   your   specialized   code   here   and/or   call   the   base   class  
  if(pMsg->message   ==   WM_LBUTTONDOWN)  
  {  
  CEdit*   pEdit   =   (CEdit*)GetDlgItem(IDC_EDIT3);  
  if(pEdit->m_hWnd   ==   pMsg->hwnd)  
  GetLineIndexOfEdit(pMsg->lParam);  
  }  
  return   CFormView::PreTranslateMessage(pMsg);  
  }  
  然后编写函数  
  void   CTestView::GetLineIndexOfEdit(DWORD   pos)  
  {  
  CEdit*   pEdit   =   (CEdit*)GetDlgItem(IDC_EDIT3);  
   
  WORD   xPos   =   LOWORD(pos);     //   horizontal   position   of   cursor    
  WORD   yPos   =   HIWORD(pos);     //   vertical   position   of   cursor    
  CPoint   pt(xPos,yPos);  
   
  int   ret   =   pEdit->CharFromPos(pt);  
  int   charindex   =   LOWORD(ret);//这个是点击位置的字符在整个文本中的序号  
  int   lineindex   =   HIWORD(ret);//这个就是行号  
  }

NO.2   作者: bcpl

用这些函数  
  1.   BOOL   GetCursorPos(LPPOINT   lpPoint);  
  2.   int   CharFromPos(   CPoint   pt   )   const;  
  3.   int   LineFromChar(   int   nIndex   =   -1   )   const;

NO.3   作者: Phourm

EM_CHARFROMPOS  
  EM_LINEFROMCHAR


    摘要: 本人男,26, 职业:软件开发 爱好:跆拳道、文学创作、笛箫演奏 现在在陕西南路附近的威海路755号上班, 准备找人合租房子,有意者请打电话 021-32014888-734 或是通过msn kissfire5560@hotmail.com 和我联系 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE