求问大神 一下注释的地方为什么两个指针相减之后 要除以2
是在反汇编中看到的
BOOL PopFindFindText (HWND hwndEdit, int * piSearchOffset, LPFINDREPLACE pfr)
{
int iLength, iPos ;
PTSTR pstrDoc, pstrPos ;
// Read in the edit document
iLength = GetWindowTextLength (hwndEdit) ;
if (NULL == (pstrDoc = (PTSTR) malloc ((iLength + 1) * sizeof (TCHAR))))
return FALSE ;
GetWindowText (hwndEdit, pstrDoc, iLength + 1) ;
// Search the document for the find string
pstrPos = _tcsstr (pstrDoc + * piSearchOffset, pfr->lpstrFindWhat) ;
free (pstrDoc) ;
// Return an error code if the string cannot be found
if (pstrPos == NULL)
return FALSE ;
// Find the position in the document and the new start offset
iPos = pstrPos - pstrDoc ;//此处两个指针相减 得出的值为什么要除以2
* piSearchOffset = iPos + lstrlen (pfr->lpstrFindWhat) ;
// Select the found text
SendMessage (hwndEdit, EM_SETSEL, iPos, * piSearchOffset) ;
SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0) ;
return TRUE ;
}Windows指针
是在反汇编中看到的
BOOL PopFindFindText (HWND hwndEdit, int * piSearchOffset, LPFINDREPLACE pfr)
{
int iLength, iPos ;
PTSTR pstrDoc, pstrPos ;
// Read in the edit document
iLength = GetWindowTextLength (hwndEdit) ;
if (NULL == (pstrDoc = (PTSTR) malloc ((iLength + 1) * sizeof (TCHAR))))
return FALSE ;
GetWindowText (hwndEdit, pstrDoc, iLength + 1) ;
// Search the document for the find string
pstrPos = _tcsstr (pstrDoc + * piSearchOffset, pfr->lpstrFindWhat) ;
free (pstrDoc) ;
// Return an error code if the string cannot be found
if (pstrPos == NULL)
return FALSE ;
// Find the position in the document and the new start offset
iPos = pstrPos - pstrDoc ;//此处两个指针相减 得出的值为什么要除以2
* piSearchOffset = iPos + lstrlen (pfr->lpstrFindWhat) ;
// Select the found text
SendMessage (hwndEdit, EM_SETSEL, iPos, * piSearchOffset) ;
SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0) ;
return TRUE ;
}Windows指针
解决方案 »
- 写入注册表是乱码,请问怎么解决,谢谢!!
- 新手求助 error PRJ0003 : 生成“rc.exe”时出错怎么解决
- 老问题,至今没解决
- 如何获取iwebbrowser2控件的链接点击事件 sdk
- 怎么在自绘窗口中添加菜单,像CDialog那样导入? 或者有别的变通方法?
- 在ATL控件中如何进行初始化(来者给分)
- 请问下使用windows media player组件的.put_fullScreen(TRUE)出错的问题
- 深入浅出MFC已经看的差不多了,请问下一步看哪一本书比较好
- 现在公司里用vc做数据库开发的多么?
- CLIST.REMOVEALL能否自动将链表每个元素开辟的空间释放掉,如果不能,如何释放
- 这个怎样写成DLL?
- 求助!MFC单文档应用程序 如何对子对话框进行初始化
比如double *p = (double *)1028;double *q = (double *)1020; 得到 p - q = 1,因为double 大小为8