サンプル(Ver9.35対応版)
目次−
DLL側から秀丸エディタの関数呼び出し−
サンプル
#include <windows.h>
extern "C" __declspec( dllexport )
INT_PTR _cdecl DllFuncTest( INT_PTR nHwnd ) {
HINSTANCE hinstExe = GetModuleHandle( NULL );
HGLOBAL (WINAPI* pfnHidemaru_GetTotalTextUnicode)( void );
HGLOBAL (WINAPI* pfnHidemaru_GetLineTextUnicode)( int nLineNo );
BOOL (WINAPI* pfnHidemaru_GetCursorPosUnicode)( int* pnLineNo, int* pnColumn );
(FARPROC&)pfnHidemaru_GetTotalTextUnicode = GetProcAddress( hinstExe, "Hidemaru_GetTotalTextUnicode" );
(FARPROC&)pfnHidemaru_GetLineTextUnicode = GetProcAddress( hinstExe, "Hidemaru_GetLineTextUnicode" );
(FARPROC&)pfnHidemaru_GetCursorPosUnicode = GetProcAddress( hinstExe, "Hidemaru_GetCursorPosUnicode" );
if( pfnHidemaru_GetTotalTextUnicode ) {
HGLOBAL hGlobal = pfnHidemaru_GetTotalTextUnicode();
if( hGlobal ) {
WCHAR* pwsz = (WCHAR*)GlobalLock( hGlobal );
if( wcslen( pwsz ) >= 500 ) {
pwsz[500] = '\0';
}
MessageBoxW( (HWND)nHwnd, pwsz, L"全体のテキスト(500文字上限)", MB_OK );
GlobalUnlock( hGlobal );
GlobalFree( hGlobal );
}
}
if( pfnHidemaru_GetLineTextUnicode
&& pfnHidemaru_GetCursorPosUnicode
) {
int nLineNo = 0;
int nColumn = 0;
BOOL f = pfnHidemaru_GetCursorPosUnicode( &nLineNo, &nColumn );
HGLOBAL hGlobal = pfnHidemaru_GetLineTextUnicode( nLineNo );
if( hGlobal ) {
WCHAR* pwsz = (WCHAR*)GlobalLock( hGlobal );
MessageBoxW( (HWND)nHwnd, pwsz + nColumn, L"カーソル行のカーソル位置以降のテキスト", MB_OK );
GlobalUnlock( hGlobal );
GlobalFree( hGlobal );
}
}
return 0;
}