|
|
case IDM_FIND:
SendMessage( hMedit, EM_SETSEL, 10, 15 );
break;
| |
|
|
|
|
#include "stdafx.h"
#define INCLUDE_TYPE extern
#include "Global.h"
DWORD
FindFirst( HWND hWnd, LPSTR lpTarget )
{
GetWindowText( hMedit, mem, 64000 );
DWORD ret;
DWORD len,i;
DWORD KenLen;
KenLen = lstrlen( lpTarget );
len = lstrlen( mem );
ret = -1;
for( i = 0; i < len; i++ ) {
if ( memcmp( mem+i, lpTarget, KenLen ) == 0 ) {
ret = i;
break;
}
}
return ret;
}
| |
|
|
|
|
DWORD FindFirst( HWND hWnd, LPSTR lpTarget );
| |
|
|
|
|
case IDM_FIND:
DWORD ret;
ret = FindFirst( hWnd, "インクルード" );
if ( ret != -1 ) {
SendMessage( hMedit, EM_SETSEL, ret, ret + lstrlen("インクルード") );
}
break;
| |
|
|
|
|
case IDM_FIND:
DWORD ret;
ret = FindFirst( hWnd, "インクルード" );
if ( ret != -1 ) {
SendMessage( hMedit, EM_SETSEL, ret, ret + lstrlen("インクルード") );
SendMessage( hMedit, EM_SCROLLCARET, 0, 0 );
}
break;
| |
|
|
|
但し、逆検索する場合は mem の加工が必要なので前述の方法のほうが理解しやすいでしょう。
|
DWORD
FindFirst( HWND hWnd, LPSTR lpTarget )
{
GetWindowText( hMedit, mem, 64000 );
LPSTR lpRet;
DWORD ret;
lpRet = strstr( mem, lpTarget );
if ( lpRet == NULL ) {
return -1;
}
if ( lstrlen( lpTarget ) == 0 ) {
return -1;
}
ret = (DWORD)lpRet - (DWORD)mem;
return ret;
}
| |
|
|
|