【发布时间】:2012-05-19 17:48:32
【问题描述】:
我要为记事本++ 创建自己的插件。有必要在我的插件中使用控制台,但我不想创建另一个控制台,因为 NppExec 插件中有一个。所以我的问题是我可以从我自己的插件中使用 NppExec 控制台吗?
【问题讨论】:
我要为记事本++ 创建自己的插件。有必要在我的插件中使用控制台,但我不想创建另一个控制台,因为 NppExec 插件中有一个。所以我的问题是我可以从我自己的插件中使用 NppExec 控制台吗?
【问题讨论】:
我从 NppExec 论坛https://sourceforge.net/projects/npp-plugins/forums/forum/672146/topic/5287950得到了答复
已编辑 从上面的链接粘贴:
当然!您可以查看 NppExec 内部的 NppExecPluginMsgTester 来源并部分或全部使用其代码。这 NppExecPluginMsgTester 使用内部声明的消息“包装器” "NppExec\src\PluginCommunication\nppexec_msgs.h"。
这里以 NppExec 源代码为例:
#define NPEM_PRINT 0x0401 // message
/*
Prints (shows) given text in NppExec's Console window.
You can separate text lines using _T('\n') or _T("\r\n").
This text can be highlighted if NppExec's Console Highlight Filters are used.
If plugin's state is "busy", this message is ignored.
Example:
const TCHAR* cszMyPlugin = _T("my_plugin");
DWORD dwState = 0;
CommunicationInfo ci = { NPEM_GETSTATE,
cszMyPlugin,
(void *) &dwState };
::SendMessage( hNppWnd, NPPM_MSGTOPLUGIN,
(WPARAM) _T("NppExec.dll"), (LPARAM) &ci );
if ( dwState == NPE_STATEREADY )
{
// the plugin is "ready"
const TCHAR* szText = _T("Hello from my plugin!\n(test message)")
CommunicationInfo ci = { NPEM_PRINT,
cszMyPlugin,
(void *) szText };
::SendMessage( hNppWnd, NPPM_MSGTOPLUGIN,
(WPARAM) _T("NppExec.dll"), (LPARAM) &ci );
}
*/
【讨论】: