Wz Editor上でキャレットのある位置の単語のクイックポップアップ検索を行います。
PDICU.exeが起動されていない場合は自動的に起動されます。
熟語も検索されます。
Wzのバージョンは3.00Dで動作確認。Ver.4.0で動作するかどうかは?です。
ファイル名:popup.c
#include <windows.h>
#include "winregtx.h"
BOOL StartPDIC();
#include "ddewz.h"
void main()
{
if ( !ddeConnect( "PDICU", "Dictionary"
) ){
if
( !StartPDIC() ){
return;
}
if ( !ddeConnect( "PDICU",
"Dictionary" ) ){
attention("DDEリンク失敗しました");
return;
}
}
// ddePoke( "SetAnsi", "" ); //
文字列の文字コードをANSI(ShiftJIS)にする PDIC Ver.5.1.x以降は不要
if ( !ddePoke( "Open",
"" ) ){
ddeDisconnect();
attention(
"Open失敗です" );
return;
}
DWORD adr0 = txGetAddress(
text );
int ly0 = text->ly;
txJumpWordTop(text);
#if 0
txLeft(text);
WORD code = txGetChar(text);
if ( ((code>='A')
&& (code<='Z'))
||
((code>='a') && (code<='z'))
||
(code=='\'') )
{
txRight(text);
txLeftWord(text);
} else {
txRight(text);
}
#endif
// 検索語の取得
txstr line;
txGetLineRear( text,
line );
// 表示を元に戻す
txJumpAddress(text,adr0);
txSetLy(text,ly0);
// 表示座標を求める
RECT rc;
GetWindowRect( text->hwndtext,
&rc );
char buf[20];
wsprintf( buf, "%d,%d",
rc.left+text->x, rc.top + (text->ly+1)
* text->cyLine );
ddePoke( "PopupSearchPoint",
buf );
// 検索!
// ddePoke( "PopupSearchConfig", "h0" );
ddePoke( "PopupSearch",
line );
ddePoke( "Close",
"" );
ddeDisconnect();
}
BOOL StartPDIC()
{
HKEY hKey;
if ( RegOpenKey( HKEY_CURRENT_USER, "SOFTWARE\\ReliefOffice\\PDIC2\\Common",
&hKey ) != ERROR_SUCCESS ){
attention("PDICU.exeが見つかりません(1)");
return FALSE;
}
char pdic[ 256 +
20 ];
DWORD type;
LONG size = sizeof(pdic);
if ( RegQueryValueEx( hKey, "Path", NULL,
&type, pdic, &size ) != ERROR_SUCCESS ){
RegCloseKey( hKey );
attention("PDICU.exeが見つかりません(2)");
return FALSE;
}
RegCloseKey( hKey
);
strcat(pdic, "\\PDICU.exe");
// PDICの実行(最小化で起動)
int r = WinExec( pdic, SW_SHOWMINNOACTIVE );
//★ 辞書グループを指定したい場合は代わりに次のようにする
// strcat( pdic, "
-d GroupName" );
// WinExec( pdic, SW_SHOWMINNOACTIVE );
if ( r <= 31 ){
attention("PDICU.exeが起動できません.");
return FALSE;
}
return TRUE;
}