by konisi » 2007年10月02日(火) 23:03
どうもありがとうございます。
とりあえずこんなコードを打ってみました。
[ここをクリックすると内容が表示されます] [ここをクリックすると非表示にします]コード: 全て選択
Type TtlExpand
wVersion As Word
dwSelIin As DWord
dwSelFin As DWord
End Type
Dim ptrDataEx As*TtlExpand
Function Export TtlPlgIn_Work(dwHandle As DWord,hWnd As HWND,pszFile As*Byte,pszText As*Byte,pszSel As*Byte,ByRef pzNText As*Byte,ByRef pzNSel As*Byte,dwReserved As DWord)As DWord
Dim pst As*DllItemDist
Dim nRet As DWord
Dim strBuf As String
Dim dwReserved_TtlExpand As TtlExpand
pst=dwHandle As*DllItemDist
If dwReserved Then'0でなければ
ptrDataEx=dwReserved As VoidPtr
End If
'テキスト処理の実行
Select Case pst->nIndex
Case 0
strBuf=Menu1_Work(hWnd,pszFile,pszText,pszSel,nRet)
Case 1
strBuf=Menu2_Work(hWnd,pszFile,pszText,pszSel,nRet)
Case 2
strBuf=Menu3_Work(hWnd,pszFile,pszText,pszSel,nRet)
End Select
'返却テキストの設定
Select Case nRet
Case TTL_PLUGIN_ALLTEXT
pzNText=HeapAlloc(pst->hHeap,HEAP_ZERO_MEMORY,Len(strBuf)+1)
lstrcpy(pzNText,StrPtr(strBuf))
Case TTL_PLUGIN_SELECTED
pzNSel = HeapAlloc(pst->hHeap,HEAP_ZERO_MEMORY,Len(strBuf)+1)
lstrcpy(pzNSel,StrPtr(strBuf))
Case TTL_PLUGIN_FALSE
'返却文字列は準備しない。
End Select
'返り値の設定
TtlPlgIn_Work=nRet
End Function
コード: 全て選択
'プラグインメニューの3つ目
Function Menu3_Title(ByRef fEnable As Char)As String
fEnable=TRUE
Menu3_Title="削除のテスト。"
End Function
Function Menu3_Work(hWnd As HWND,pszFile As*Byte,pszText As*Byte,pszSel As*Byte,ByRef dwAction As DWord)As String
Dim buffer[80] As Byte
If ptrDataEx then'バージョン照合は可能か
If ptrDataEx->wVersion<160 then'バージョンが1.60より下なら
MessageBox(hWnd,"このエディタのバージョンでは動作できません。Ver1.61(V161)以上で使用してください。","Warning",MB_OK)
wsprintf(buffer,"今のバージョン識別番号:V%d",ptrDataEx->wVersion)
MessageBox(hWnd,buffer,"Warning",MB_OK)
Menu3_Work=""
dwAction=TTL_PLUGIN_FALSE
Exit Function
End If
Else'バージョン照合不可能なら(Ver 1.60)
MessageBox(hWnd,"このエディタのバージョンでは動作できません。Ver1.61(V161)以上で使用してください。","Warning",MB_OK)
MessageBox(hWnd,"今のバージョン識別番号:多分V160","Warning",MB_OK)
Menu3_Work=""
dwAction=TTL_PLUGIN_FALSE
Exit Function
End If
'以下本処理
Dim buf As*Byte
Dim si As Long,sf As Long
si=ptrDataEx->dwSelIin
sf=ptrDataEx->dwSelFin
If si<>sf then
buf=calloc(lstrlen(pszText)+1)
If si then
memcpy(buf,pszText,si)
memcpy(buf+si,pszText+sf,lstrlen(pszText)-sf+si)
Else
memcpy(buf,pszText+sf,lstrlen(pszText)-sf)
End If
Menu3_Work=buf
free(buf)
dwAction=TTL_PLUGIN_ALLTEXT
Else
Menu3_Work=""
dwAction=TTL_PLUGIN_FALSE
End If
End Function
それと今気が付いたのですが、エディタのフォント名とかフォントサイズとか使用中の文字コードとかが分かると、それはそれで使い道がありそうです。
どうもありがとうございます。
とりあえずこんなコードを打ってみました。
[hide][code]Type TtlExpand
wVersion As Word
dwSelIin As DWord
dwSelFin As DWord
End Type
Dim ptrDataEx As*TtlExpand
Function Export TtlPlgIn_Work(dwHandle As DWord,hWnd As HWND,pszFile As*Byte,pszText As*Byte,pszSel As*Byte,ByRef pzNText As*Byte,ByRef pzNSel As*Byte,dwReserved As DWord)As DWord
Dim pst As*DllItemDist
Dim nRet As DWord
Dim strBuf As String
Dim dwReserved_TtlExpand As TtlExpand
pst=dwHandle As*DllItemDist
If dwReserved Then'0でなければ
ptrDataEx=dwReserved As VoidPtr
End If
'テキスト処理の実行
Select Case pst->nIndex
Case 0
strBuf=Menu1_Work(hWnd,pszFile,pszText,pszSel,nRet)
Case 1
strBuf=Menu2_Work(hWnd,pszFile,pszText,pszSel,nRet)
Case 2
strBuf=Menu3_Work(hWnd,pszFile,pszText,pszSel,nRet)
End Select
'返却テキストの設定
Select Case nRet
Case TTL_PLUGIN_ALLTEXT
pzNText=HeapAlloc(pst->hHeap,HEAP_ZERO_MEMORY,Len(strBuf)+1)
lstrcpy(pzNText,StrPtr(strBuf))
Case TTL_PLUGIN_SELECTED
pzNSel = HeapAlloc(pst->hHeap,HEAP_ZERO_MEMORY,Len(strBuf)+1)
lstrcpy(pzNSel,StrPtr(strBuf))
Case TTL_PLUGIN_FALSE
'返却文字列は準備しない。
End Select
'返り値の設定
TtlPlgIn_Work=nRet
End Function[/code][code]
'プラグインメニューの3つ目
Function Menu3_Title(ByRef fEnable As Char)As String
fEnable=TRUE
Menu3_Title="削除のテスト。"
End Function
Function Menu3_Work(hWnd As HWND,pszFile As*Byte,pszText As*Byte,pszSel As*Byte,ByRef dwAction As DWord)As String
Dim buffer[80] As Byte
If ptrDataEx then'バージョン照合は可能か
If ptrDataEx->wVersion<160 then'バージョンが1.60より下なら
MessageBox(hWnd,"このエディタのバージョンでは動作できません。Ver1.61(V161)以上で使用してください。","Warning",MB_OK)
wsprintf(buffer,"今のバージョン識別番号:V%d",ptrDataEx->wVersion)
MessageBox(hWnd,buffer,"Warning",MB_OK)
Menu3_Work=""
dwAction=TTL_PLUGIN_FALSE
Exit Function
End If
Else'バージョン照合不可能なら(Ver 1.60)
MessageBox(hWnd,"このエディタのバージョンでは動作できません。Ver1.61(V161)以上で使用してください。","Warning",MB_OK)
MessageBox(hWnd,"今のバージョン識別番号:多分V160","Warning",MB_OK)
Menu3_Work=""
dwAction=TTL_PLUGIN_FALSE
Exit Function
End If
'以下本処理
Dim buf As*Byte
Dim si As Long,sf As Long
si=ptrDataEx->dwSelIin
sf=ptrDataEx->dwSelFin
If si<>sf then
buf=calloc(lstrlen(pszText)+1)
If si then
memcpy(buf,pszText,si)
memcpy(buf+si,pszText+sf,lstrlen(pszText)-sf+si)
Else
memcpy(buf,pszText+sf,lstrlen(pszText)-sf)
End If
Menu3_Work=buf
free(buf)
dwAction=TTL_PLUGIN_ALLTEXT
Else
Menu3_Work=""
dwAction=TTL_PLUGIN_FALSE
End If
End Function[/code][/hide]それと今気が付いたのですが、エディタのフォント名とかフォントサイズとか使用中の文字コードとかが分かると、それはそれで使い道がありそうです。