<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Creating a docked window from a background thread]]></title><description><![CDATA[<p dir="auto">Did anyone try to do the following? -</p>
<ol>
<li>Create a thread;</li>
<li>In that thread, create a modeless dialog;</li>
<li>In that thread, call NPPM_DMMREGASDCKDLG, MODELESSDIALOGADD and NPPM_DMMSHOW for that modeless dialog.<br />
After I do that, Notepad++ seems to hang :(<br />
Do I understand correctly that a docked dialog must not be created and registered from within another thread?</li>
</ol>
]]></description><link>https://community.notepad-plus-plus.org/topic/13116/creating-a-docked-window-from-a-background-thread</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 01:56:32 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13116.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Jan 2017 20:15:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Creating a docked window from a background thread on Fri, 20 Jan 2017 17:22:28 GMT]]></title><description><![CDATA[<p dir="auto">That’s interesting. Can’t say I know for sure why that is calling <code>createToolbar()</code>. My plugin also uses a toolbar icon but it registers it during <code>NPPN_TBMODIFICATION</code>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21107</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21107</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Fri, 20 Jan 2017 17:22:28 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Fri, 20 Jan 2017 17:15:02 GMT]]></title><description><![CDATA[<p dir="auto">@Claudia,<br />
Yes, installing the WinDDK fixes that.<br />
Though, as I said, I really don’t like Notepad++ to use ATL. Moreover, it’s just for a small feature, which could be rewritten.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dail" aria-label="Profile: Dail">@<bdi>Dail</bdi></a>,<br />
I’ve found the root cause. It’s because my plugin has a toolbar icon and here is what Notepad++ does with it:</p>
<p dir="auto">in DockingManager::createDockableDlg:</p>
<pre><code>_vContainer[iCont]-&gt;createToolbar(data);
</code></pre>
<p dir="auto">where DockingCont::createToolbar calls DockingCont::viewToolbar, where the following is done:</p>
<pre><code>// show dialog and notify parent to update dialog view
if (isVisible() == false)
{
	this-&gt;doDialog();
	::SendMessage(_hParent, WM_SIZE, 0, 0);
}
</code></pre>
<p dir="auto">So the docked dialog is forced to be shown by that code :(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21106</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21106</guid><dc:creator><![CDATA[Vitaliy Dovgan]]></dc:creator><pubDate>Fri, 20 Jan 2017 17:15:02 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Fri, 20 Jan 2017 15:57:26 GMT]]></title><description><![CDATA[<p dir="auto">Actually, if you look in Notepad++'s source where it uses these messages <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/c235e17f7dbfec9e2006f414e33feb0a039d3708/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp#L1971-L1983" rel="nofollow ugc">internally</a> it normally calls:</p>
<ol>
<li><code>NPPM_MODELESSDIALOG</code> with <code>MODELESSDIALOGADD</code></li>
<li><code>NPPM_MODELESSDIALOG</code> with <code>MODELESSDIALOGREMOVE</code></li>
<li><code>NPPM_DMMREGASDCKDLG</code></li>
</ol>
<p dir="auto">I think 1 and 2 are just a side effect of how the class inheritance works within Notepad++. So, it would appear that <code>NPPM_MODELESSDIALOG</code> may not even be needed for docked dialogs. I will look into this more if I get a chance.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21103</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21103</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Fri, 20 Jan 2017 15:57:26 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Fri, 20 Jan 2017 15:22:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vitaliy-dovgan" aria-label="Profile: Vitaliy-Dovgan">@<bdi>Vitaliy-Dovgan</bdi></a></p>
<p dir="auto">Try calling <code>NPPM_MODELESSDIALOG</code> first.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21102</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21102</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Fri, 20 Jan 2017 15:22:33 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Fri, 20 Jan 2017 14:38:01 GMT]]></title><description><![CDATA[<p dir="auto">If you aren’t concerned about the new license agreements I would use the community edition<br />
as this should behave like the pro versions.<br />
If you still want to use express - didn’t the changes help?</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21094</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21094</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 20 Jan 2017 14:38:01 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Fri, 20 Jan 2017 14:17:32 GMT]]></title><description><![CDATA[<p dir="auto">Ah, looks I’ll need to debug Notepad++ to understand what is wrong.<br />
Which is not straightforward because I’m having exactly the same issues with VS 2013 Express as mentioned here:<br />
<a href="https://notepad-plus-plus.org/community/topic/11388/errors-building-current-repository" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/11388/errors-building-current-repository</a><br />
If you ask my opinion, I’d rather suggest to get rid of these CStringW in Notepad++'s code - these things are not true and pure Win API way!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/21088</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/21088</guid><dc:creator><![CDATA[Vitaliy Dovgan]]></dc:creator><pubDate>Fri, 20 Jan 2017 14:17:32 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Tue, 17 Jan 2017 23:49:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vitaliy-dovgan" aria-label="Profile: Vitaliy-Dovgan">@<bdi>Vitaliy-Dovgan</bdi></a></p>
<p dir="auto">that is strange, indeed.<br />
Npp, does more or less the same checkings before creating the dialog</p>
<pre><code>	case NPPM_DMMREGASDCKDLG:
	{
		tTbData *pData = reinterpret_cast&lt;tTbData *&gt;(lParam);
		int		iCont	= -1;
		bool	isVisible	= false;

		getIntegralDockingData(*pData, iCont, isVisible);
		_dockingManager.createDockableDlg(*pData, iCont, isVisible);
		return TRUE;
	}
</code></pre>
<p dir="auto">…</p>
<pre><code>bool Notepad_plus::getIntegralDockingData(tTbData &amp; dockData, int &amp; iCont, bool &amp; isVisible)
{
    DockingManagerData &amp; dockingData = (DockingManagerData &amp;)(NppParameters::getInstance())-&gt;getNppGUI()._dockingData;

    for (size_t i = 0, len = dockingData._pluginDockInfo.size(); i &lt; len ; ++i)
    {
        const PluginDlgDockingInfo &amp; pddi = dockingData._pluginDockInfo[i];

        if (!generic_stricmp(pddi._name.c_str(), dockData.pszModuleName) &amp;&amp; (pddi._internalID == dockData.dlgID))
        {
            iCont				= pddi._currContainer;
            isVisible			= pddi._isVisible;
            dockData.iPrevCont	= pddi._prevContainer;

            if (dockData.iPrevCont != -1)
            {
                int cont = (pddi._currContainer &lt; DOCKCONT_MAX ? pddi._prevContainer : pddi._currContainer);
                RECT rc;
                if (dockingData.getFloatingRCFrom(cont, rc))
                    dockData.rcFloat = rc;
            }
            return true;
        }
    }
    return false;
}
</code></pre>
<p dir="auto">…</p>
<pre><code>void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
{
...
// if floated rect not set
if (memcmp(&amp;data.rcFloat, &amp;rc, sizeof(RECT)) == 0)
{
	// set default rect state
	::GetWindowRect(data.hClient, &amp;data.rcFloat);

	// test if dialog is first time created
	if (iCont == -1)
	{
		// set default visible state
		isVisible = (::IsWindowVisible(data.hClient) == TRUE);
...
</code></pre>
<p dir="auto">This would lead to the assumption that you might, maaayyyybeeee, checked<br />
the false config.xml?? I know you are familiar with npps configuration<br />
but, at least for me, sometimes you don’t see the wood for the trees.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20994</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20994</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 17 Jan 2017 23:49:49 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Tue, 17 Jan 2017 23:08:27 GMT]]></title><description><![CDATA[<p dir="auto">My <a href="https://github.com/dail8859/LuaScript" rel="nofollow ugc">LuaScript</a> plugin uses a docked dialog and is not shown by default (assuming the config.xml doesn’t contain any info about it).</p>
<p dir="auto">Take a look at <a href="https://github.com/dail8859/LuaScript/blob/master/src/Dialogs/ConsoleDialog.cpp#L458-L467" rel="nofollow ugc">this section of code</a> which is how I’ve been doing it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20991</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20991</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Tue, 17 Jan 2017 23:08:27 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Tue, 17 Jan 2017 21:25:04 GMT]]></title><description><![CDATA[<p dir="auto">Nope! In the “config.xml” there is:</p>
<pre><code>isVisible="no".
</code></pre>
<p dir="auto">And here is some verification code:</p>
<pre><code>::OutputDebugStringA(::IsWindowVisible(hDialogWnd) ? "1. Visible\n" : "1. Not visible\n");
SendNppMsg( NPPM_DMMREGASDCKDLG, 0, (LPARAM) &amp;dockData );
SendNppMsg( NPPM_MODELESSDIALOG, (WPARAM) MODELESSDIALOGADD, (LPARAM) hDialogWnd );
::OutputDebugStringA(::IsWindowVisible(hDialogWnd) ? "2. Visible\n" : "2. Not visible\n");
</code></pre>
<p dir="auto">It shows:</p>
<pre><code>1. Not visible
2. Visible
</code></pre>
<p dir="auto">If there was isVisible=“yes” in the “config.xml”, there would be an additional explicit call of the function which functionId was specified as the dockData.dlgID. But in my case isVisible=“no”, there was no explicit call of the plugin’s function - but the docked window became visible…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20990</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20990</guid><dc:creator><![CDATA[Vitaliy Dovgan]]></dc:creator><pubDate>Tue, 17 Jan 2017 21:25:04 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Tue, 17 Jan 2017 20:58:23 GMT]]></title><description><![CDATA[<p dir="auto">AFAIK it is not shown by default. You might check your <code>config.xml</code> file because it stores information about docked dialogs (position, visibility, etc). It might think it is supposed to be open already.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20989</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20989</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Tue, 17 Jan 2017 20:58:23 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Tue, 17 Jan 2017 20:49:25 GMT]]></title><description><![CDATA[<p dir="auto">That must be it. MSDN says “GetMessage - Retrieves a message from the <em>calling thread’s</em> message queue”:<br />
<a href="https://msdn.microsoft.com/en-us/library/ms644936(VS.85).aspx" rel="nofollow ugc">https://msdn.microsoft.com/en-us/library/ms644936(VS.85).aspx</a><br />
Anyway, creating a dialog in a main thread and then calling NPPM_DMMREGASDCKDLG and NPPM_DMMSHOW from another thread does the trick.</p>
<p dir="auto">Though there’s another thing I don’t understand, this time in Notepad++. Why a docked dialog becomes visible immediately after NPPM_DMMREGASDCKDLG and MODELESSDIALOGADD? I mean, logically MODELESSDIALOGADD means “<em>add a dialog</em>” - correct? - so a dialog should not be shown before NPPM_DMMSHOW is sent explicitly!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20988</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20988</guid><dc:creator><![CDATA[Vitaliy Dovgan]]></dc:creator><pubDate>Tue, 17 Jan 2017 20:49:25 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Tue, 17 Jan 2017 00:03:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vitaliy-dovgan" aria-label="Profile: Vitaliy-Dovgan">@<bdi>Vitaliy-Dovgan</bdi></a></p>
<p dir="auto">For me it sounds like you are running into some kind of race condition.<br />
One thread might receives the window messages whereas the other<br />
threads expect it. Did you check this?</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20977</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20977</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 17 Jan 2017 00:03:21 GMT</pubDate></item><item><title><![CDATA[Reply to Creating a docked window from a background thread on Mon, 16 Jan 2017 20:53:17 GMT]]></title><description><![CDATA[<p dir="auto">Well, yes, I think it was not a good idea to create it in another thread.<br />
Once I move the dialog creation &amp; registering as a docked dialog to the main thread, everything works OK.<br />
Though, the question remains.<br />
Why doing it in another thread causes Notepad++ to hang?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20973</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20973</guid><dc:creator><![CDATA[Vitaliy Dovgan]]></dc:creator><pubDate>Mon, 16 Jan 2017 20:53:17 GMT</pubDate></item></channel></rss>