<?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[MenuIcon problem with latest version of NPP]]></title><description><![CDATA[<p dir="auto">It has been reported and I have confirmed that the menu icons added by MenuIcon plugin disappear when:</p>
<ol>
<li>recent file list is cleared</li>
<li>recent file is opened or changed</li>
<li>menu shortcuts get updated</li>
</ol>
<p dir="auto">I performed some investigations that it seems to me (amateur programmer) that the issue may be related to the use (twice) of ::ModifyMenu(…) in shortcut.cpp.</p>
<p dir="auto">I did perform some basic test and it seems that changing the text with ::ModifyMenu wipes everything.<br />
The use of the more modern ::SetMenuInfo instead seems to maintain the check marks and bitmaps.</p>
<p dir="auto">I would like to kindly suggest these two changes (untested), or some variations of them, in the code:</p>
<ol>
<li>
<p dir="auto">At line 631 I think the intention is to update the text of the menu and keep the check state:</p>
<p dir="auto">//  Ensure that the menu item checks set prior to this update remain in affect.<br />
UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND );<br />
cmdFlags = MF_BYCOMMAND | ((cmdFlags&amp;MF_CHECKED) ? MF_CHECKED : MF_UNCHECKED);<br />
::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str());</p>
</li>
</ol>
<p dir="auto">This should become something like this (untested)… which should keep the icon and the check state:</p>
<pre><code>MENUITEMINFO mii;
mii.cbSize = sizeof mii;
mii.fMask = MIIM_STRING;
mii.dwTypeData = _csc.toMenuItemString().c_str();
mii.cch = _tsrlen(mii.dwTypeData);
::SetMenuItemInfo(_hAccelMenu, cmdID, FALSE, &amp;mii);
</code></pre>
<ol start="2">
<li>
<p dir="auto">At line 780</p>
<pre><code> ::ModifyMenu(_hAccelMenu, id, MF_BYCOMMAND, id, menuItem.c_str());
</code></pre>
</li>
</ol>
<p dir="auto">Should become:</p>
<pre><code>MENUITEMINFO mii;
mii.cbSize = sizeof mii;
mii.fMask = MIIM_STRING;
mii.dwTypeData = menuItem.c_str();
mii.cch = _tsrlen(mii.dwTypeData);
::SetMenuItemInfo(_hAccelMenu, id, FALSE, &amp;mii);
</code></pre>
<p dir="auto">May be somebody with more experience than me can form the githup repository and test these changes and make a pull request.</p>
<p dir="auto">I home this helps.</p>
<p dir="auto">Franco</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/13863/menuicon-problem-with-latest-version-of-npp</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 10:07:22 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13863.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 May 2017 13:15:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 16 Jun 2017 23:17:20 GMT]]></title><description><![CDATA[<p dir="auto">Hello Claudia,</p>
<p dir="auto">Welcome back. I hope you had a good time.<br />
The forum is not what it is when you’re away. :)</p>
<p dir="auto">Thanks again for your kind help.</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24944</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24944</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Fri, 16 Jun 2017 23:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 16 Jun 2017 17:53:54 GMT]]></title><description><![CDATA[<p dir="auto">Hello Yaron and Pavel,</p>
<p dir="auto">coming back from a short trip it is nice to see that you got it sorted out.</p>
<p dir="auto">Pavel, thank you very much for your insights - very much appreciated.<br />
Your explanation gives me the feeling that I’ve done another step in<br />
understanding this pointer stuff, although it seems to be more like<br />
an variable lifetime issue. :-)</p>
<p dir="auto">Yaron, thanks for asking the questions I would have asked also. :-)</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24934</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24934</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 16 Jun 2017 17:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Wed, 14 Jun 2017 23:08:44 GMT]]></title><description><![CDATA[<p dir="auto">Hello Pavel,</p>
<p dir="auto">The issue is clearer now.<br />
Some of the terms you’ve used are new to me. I’ll have to expand my basic knowledge. :)</p>
<p dir="auto">Thank you for the interesting explanation. As always, I appreciate your patience.</p>
<p dir="auto">BR</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24920</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24920</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Wed, 14 Jun 2017 23:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Wed, 14 Jun 2017 07:19:00 GMT]]></title><description><![CDATA[<p dir="auto">Hello Yaron,</p>
<blockquote>
<p dir="auto">My idea was that returnIntPointer() is not destroyed until the following ; is reached.<br />
IOW: since we use useIntPointer(returnIntPointer());, it’s valid until we return to );</p>
</blockquote>
<p dir="auto">That’s true for <code>returnInteger()</code> not for <code>returnIntPointer()</code> and <code>returnIntPointer()</code> is a function - it is not destroyed. The value (variable) it returns is not destroyed until the next <code>;</code>.</p>
<p dir="auto">Let’s look at <code>returnIntPointer()</code>'s code:</p>
<pre><code>int * returnIntPointer()
{
    int ret = 5;
    return &amp;ret;
}
</code></pre>
<p dir="auto">When we enter the function, <code>ret</code> is created on the stack, the stack pointer is moved (let’s say incremented for clarity).<br />
Now we return <code>ret</code>’s address and exit the function. When we exit, <code>ret</code> is freed -&gt; the stack pointer is decremented.<br />
Now the returned pointer points to free stack memory that will hold the old <code>ret</code>’s value until another local (automatic) variable is created and that usually happens when you enter another function. In our case this function is <code>useIntPointer()</code>. So in <code>useIntPointer()</code> our pointer points to invalid data.</p>
<p dir="auto">When you return <code>ret</code> by value (as in <code>returnInteger()</code>) the returned value is either in processor register or on the stack before all <code>returnInteger()</code> local variables are put there and later - destroyed. IOW there is no copy performed - it is simply a compiler matter.</p>
<p dir="auto">Your assumption is correct to the point that whatever variable a function returns (temporary) lives until the next <code>;</code> where the function is called.<br />
In <code>returnIntPointer()</code>  the returned variable is <code>int*</code> and it lives until next <code>;</code> after the call but it points to what? Some free memory that is overwritten perhaps and assigned to another variable.<br />
In <code>returnInteger()</code> the returned variable is <code>int</code> and it’s just what you need (it is not extra-copied on return, don’t worry, it’s just created by the compiler in the appropriate way). You can assign it to another variable to store it or directly give it to another function (copying it or using it’s address - doesn’t matter) - it is valid until the next <code>;</code> after the call.</p>
<p dir="auto">Hope that clarifies.</p>
<p dir="auto">BR</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24913</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24913</guid><dc:creator><![CDATA[pnedev]]></dc:creator><pubDate>Wed, 14 Jun 2017 07:19:00 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Wed, 14 Jun 2017 00:25:15 GMT]]></title><description><![CDATA[<p dir="auto">Hello Pavel,</p>
<blockquote>
<p dir="auto"><code>ret</code> is a local variable of <code>returnIntPointer()</code> after all.</p>
</blockquote>
<p dir="auto">I understand that.<br />
My idea was that <code>returnIntPointer()</code> is not destroyed until the following <code>;</code> is reached.<br />
IOW: since we use <code>useIntPointer(returnIntPointer());</code>, it’s valid until we return to <code>);</code>.</p>
<p dir="auto">Otherwise, is a <em>new</em> temporary copy of <code>ret</code> created?<br />
And what’s the exact definition? You can copy it just at the very beginning of the function? Isn’t it a bit far fetched?</p>
<p dir="auto">Another option is that you assume there’s not enough time to destroy <code>ret</code> because of the events proximity.<br />
But that doesn’t make sense either.</p>
<p dir="auto">I suppose this question can be tested.</p>
<p dir="auto">Thanks again. I appreciate your contribution to MenuIcons as well. :)<br />
BR</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24910</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24910</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Wed, 14 Jun 2017 00:25:15 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Tue, 13 Jun 2017 22:10:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello Yaron,</p>
<p dir="auto">You are welcome.</p>
<p dir="auto">No, the assumption is not correct.</p>
<p dir="auto"><code>ret</code> is destroyed (stops existing) the moment we exit <code>returnIntPointer()</code>:<br />
<code>ret</code> is a local variable of <code>returnIntPointer()</code> after all.</p>
<p dir="auto">If you return it by value (as in my example) a temporary copy of <code>ret</code> is returned where the call to <code>returnInteger()</code> is. This temporary exist only in that place and if it is not immediately copied  then it is lost.</p>
<p dir="auto">BR</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24909</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24909</guid><dc:creator><![CDATA[pnedev]]></dc:creator><pubDate>Tue, 13 Jun 2017 22:10:17 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Tue, 13 Jun 2017 17:46:24 GMT]]></title><description><![CDATA[<p dir="auto">Hello Pavel,</p>
<p dir="auto">Thank you for the detailed and well built explanation.</p>
<p dir="auto">The issue is clear.<br />
With your permission, I’ll try to slightly sharpen it.</p>
<pre><code>int * returnIntPointer()
{
    int ret = 5;
    return &amp;ret;
}

void useIntPointer(const int* pInt)
{
    ...
}

useIntPointer(returnIntPointer());
</code></pre>
<p dir="auto"><code>ret</code> <em>is stored and valid</em> for the duration of <code>useIntPointer()</code>.<br />
It should lose its validity only when we reach the end of <code>useIntPointer(returnIntPointer());</code>; i.e. when <code>useIntPointer()</code> ends.</p>
<p dir="auto">Is that correct?</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24907</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24907</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Tue, 13 Jun 2017 17:46:24 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Tue, 13 Jun 2017 07:33:02 GMT]]></title><description><![CDATA[<p dir="auto">Hello Yaron,</p>
<p dir="auto">The problem is the same.</p>
<p dir="auto">In</p>
<pre><code>LPCTSTR test =  csc.toMenuItemString().c_str();
::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, test);
</code></pre>
<p dir="auto"><code>test</code> is a pointer to <code>const TCHAR</code> that is pointing to the data of a temporary <code>std::basic_string&lt;TCHAR&gt;</code> object returned by <code>toMenuItemString()</code>. The problem is that the string object (the one actually holding the data) is temporary - it is not saved by the assignement to <code>test</code> and it is destroyed immediately after the assignment.</p>
<p dir="auto">That code is practically equivalent to:</p>
<pre><code>int returnInteger()
{
    int ret = 5;
    return ret;
}

const int* pInt = returnInteger();
</code></pre>
<p dir="auto">Here <code>pInt</code> is pointing to nonexistent <code>int</code> object.</p>
<p dir="auto">Now</p>
<pre><code>::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str());
</code></pre>
<p dir="auto">is a function call which takes a pointer to temporary object. I’m not sure how this will behave and if it will behave consistently if the code is compiled with different compilers but that might work. That’s because here the temporary might still be alive even though it is not stored anywhere - it might still live on the stack. For sure the temporary ceases to exist on the next line (as is the case with the ‘in-between’ assignment).<br />
As an illustration (continued from the above one) it is equivalent to</p>
<pre><code>void useIntPointer(const int* pInt)
{
    ...
}

useIntPointer(returnInteger());
</code></pre>
<p dir="auto">To be perfectly safe there’s nothing wrong with doing that:</p>
<pre><code>std::basic_string&lt;TCHAR&gt; menuItem =  csc.toMenuItemString();
::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, menuItem.c_str());
</code></pre>
<p dir="auto">Now the <code>menuItem</code> variable is actually holding the whole string data (it is not just a pointer) and it will be valid in our current scope.<br />
The new compilers might not even make a copy of the string (there might be no assignment penalty) as they might simply apply move operation and directly reuse the string data returned by <code>toMenuItemString()</code>.</p>
<p dir="auto">BR,<br />
Pavel</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24902</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24902</guid><dc:creator><![CDATA[pnedev]]></dc:creator><pubDate>Tue, 13 Jun 2017 07:33:02 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Mon, 12 Jun 2017 17:12:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello Pavel,</p>
<p dir="auto">Thank you for the explanation. I appreciate it.</p>
<p dir="auto">There’s still a “missing link”:<br />
What’s the difference between</p>
<pre><code>::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str());
</code></pre>
<p dir="auto">and</p>
<pre><code>LPCTSTR test =  csc.toMenuItemString().c_str();
::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, test);
</code></pre>
<p dir="auto">?</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24894</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24894</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Mon, 12 Jun 2017 17:12:38 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Mon, 12 Jun 2017 08:12:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi again,</p>
<p dir="auto">If the code below is the original one that is not working as expected I might have an explanation why it is not behaving well.</p>
<pre><code>void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
{
    MENUITEMINFO mii;
    mii.cbSize = sizeof(MENUITEMINFO);
    mii.fMask = MIIM_STRING;
    mii.dwTypeData = const_cast&lt;LPTSTR&gt;(csc.toMenuItemString().c_str());
    ::SetMenuItemInfo(_hAccelMenu, csc.getID(), FALSE, &amp;mii);
}
</code></pre>
<p dir="auto">The problem is that when <code>SetMenuItemInfo</code> is called the <code>mii.dwTypeData</code> is not valid.<br />
That’s because <code>mii.dwTypeData</code> is a pointer to a <code>TCHAR</code> array - it is not the actual array and something needs to hold the actual data. But <code>const_cast&lt;LPTSTR&gt;(csc.toMenuItemString().c_str())</code> is not holding anything because <code>toMenuItemString()</code> returns temporal <code>std::basic_string&lt;TCHAR&gt;</code> object that is not saved in our scope and this temporal string ceases to exist the moment its pointer is stored in <code>mii.dwTypeData</code>. At the moment <code>SetMenuItemInfo</code> is called the <code>mii.dwTypeData</code> is pointing to a free memory that is on the stack and is overwritten the moment a new automatic variable is created.</p>
<p dir="auto">That’s why Claudia’s solution with local variable that is holding the new string is working - <code>mii.dwTypeData</code> is pointing to local array that is still valid when <code>SetMenuItemInfo</code> is called.</p>
<p dir="auto">BR,<br />
Pavel</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24889</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24889</guid><dc:creator><![CDATA[pnedev]]></dc:creator><pubDate>Mon, 12 Jun 2017 08:12:00 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 09 Jun 2017 22:26:44 GMT]]></title><description><![CDATA[<p dir="auto">Hello Claudia,</p>
<blockquote>
<p dir="auto">so you are saying when assinging csc.toMenuItemString().c_str() to a variable<br />
even ModifyMenu corrupts the menu?</p>
</blockquote>
<p dir="auto">Indeed.</p>
<blockquote>
<p dir="auto">But when using ModifyMenu and csc.toMenuItemString().c_str() as parameter<br />
which is expected to be a LPCTSTR what is the difference when using…?</p>
</blockquote>
<p dir="auto">That’s a good question. It requires some serious investigation (and investigator). :)</p>
<p dir="auto">Thanks again.<br />
Have a nice weekend.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24874</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24874</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Fri, 09 Jun 2017 22:26:44 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 09 Jun 2017 17:24:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yaron" aria-label="Profile: Yaron">@<bdi>Yaron</bdi></a></p>
<p dir="auto">so you are saying when assinging csc.toMenuItemString().c_str() to a variable<br />
even ModifyMenu corrupts the menu?<br />
Doesn’t this mean that there is something wrong with the expected result of<br />
csc.toMenuItemString().c_str().<br />
Franco already had the idea that there might be some kind of conversion going on<br />
but I didn’t find it in the code (but this means nothing could be easily overlooked).</p>
<p dir="auto">But when using ModifyMenu and csc.toMenuItemString().c_str() as parameter<br />
which is <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms647993(v=vs.85).aspx" rel="nofollow ugc">expected to be a LPCTSTR</a> what is the difference when using</p>
<pre><code>LPCTSTR test =  csc.toMenuItemString().c_str();
::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, test);
</code></pre>
<p dir="auto">???</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24865</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24865</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 09 Jun 2017 17:24:46 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 09 Jun 2017 15:24:55 GMT]]></title><description><![CDATA[<p dir="auto">Hello Claudia and Pavel,</p>
<p dir="auto">Both <code>LPTSTR test =</code> and <code>LPCTSTR test =</code> have the same result as Franco’s original code.</p>
<pre><code>mii.fMask = MIIM_TYPE;
mii.fType = MFT_STRING;
</code></pre>
<p dir="auto">I’ve tried that and some other combinations: again, the same result.</p>
<p dir="auto">Thank you both. I appreciate your kind help.</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24862</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24862</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Fri, 09 Jun 2017 15:24:55 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 09 Jun 2017 09:08:54 GMT]]></title><description><![CDATA[<p dir="auto">Hello guys,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/franco-stellari250" aria-label="Profile: Franco-Stellari250">@<bdi>Franco-Stellari250</bdi></a> ,</p>
<p dir="auto">I’m sorry if you have already tried this but the correct usage according to MENUITEMINFO specification should be</p>
<p dir="auto">mii.fMask = MIIM_TYPE;<br />
mii.fType = MFT_STRING;</p>
<p dir="auto">Best Regards,<br />
Pavel</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24855</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24855</guid><dc:creator><![CDATA[pnedev]]></dc:creator><pubDate>Fri, 09 Jun 2017 09:08:54 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Fri, 09 Jun 2017 01:18:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/franco-stellari250" aria-label="Profile: Franco-Stellari250">@<bdi>Franco-Stellari250</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/yaron" aria-label="Profile: Yaron">@<bdi>Yaron</bdi></a></p>
<p dir="auto">I tried to find something which could explain the behavior but<br />
was out of luck. In general I would expect that it works as Franco initially<br />
wrote, const_cast removes or adds the “constness” of a variable.<br />
Maybe you wanna check the memory window while debugging npp,<br />
like settings a breakpoint before SetMenuItemInfo and check the location where<br />
mii.dwTypeData refers to - maybe this gives a hint what is going on.<br />
Or compare with ModifyMenu function like</p>
<pre><code>void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
{
    int cmdID = csc.getID();
    // Ensure that the menu item checks set prior to this update remain in affect.
    UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND);
    cmdFlags = MF_BYCOMMAND | ((cmdFlags&amp;MF_CHECKED) ? MF_CHECKED : MF_UNCHECKED);
    LPTSTR test =  const_cast&lt;LPTSTR&gt;(csc.toMenuItemString().c_str());
    ::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str());
}
</code></pre>
<p dir="auto">if test variable is behaving the same? Maybe give it a try with</p>
<pre><code>void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
{
    int cmdID = csc.getID();
    // Ensure that the menu item checks set prior to this update remain in affect.
    UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND);
    cmdFlags = MF_BYCOMMAND | ((cmdFlags&amp;MF_CHECKED) ? MF_CHECKED : MF_UNCHECKED);
    LPCTSTR test =  csc.toMenuItemString().c_str();
    ::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, test);
}
</code></pre>
<p dir="auto">to see if there is a problem when assigning to a new variable.</p>
<p dir="auto">I know, nothing specific and a lot of fishing in the dark. Sorry.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24849</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24849</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 09 Jun 2017 01:18:01 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Thu, 08 Jun 2017 20:53:01 GMT]]></title><description><![CDATA[<p dir="auto">Hello Claudia,</p>
<p dir="auto">Thank you very much. I appreciate your help.<br />
I’ll keep discussing it with Franco.</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24845</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24845</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Thu, 08 Jun 2017 20:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Thu, 08 Jun 2017 17:16:19 GMT]]></title><description><![CDATA[<p dir="auto">My understanding is that cch is need only for the GetMenuInfo… to tell how big is your string. It’s not needed for the SetMenuInfo since you are passing a null terminated string. Anyhow, I did try to play with it with no result.</p>
<p dir="auto">I also tried your other hypothesis that using the fType may have an effect but I also could not get it to work.</p>
<p dir="auto">I think the use of the SetMenuInfo is correct… I just don’t understand why the string gets mangled… and only related to the “&amp;”… may be there is some char type conversion going on. At the end the char pointer returned by the wstring or the c_str should be theoretically identical.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24836</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24836</guid><dc:creator><![CDATA[Franco Stellari250]]></dc:creator><pubDate>Thu, 08 Jun 2017 17:16:19 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Thu, 08 Jun 2017 15:55:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi Yaron,</p>
<blockquote>
<p dir="auto">I assume you can not test it or it did not arouse your curiosity. :)</p>
</blockquote>
<p dir="auto">I’m curios about it but unfortunately can’t test it. :-)<br />
This makes it very hard to see what happens under the hood.<br />
I always need to read the documentation and afterwards do testing<br />
in order to understand what is going on.</p>
<p dir="auto">From <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms647578(v=vs.85).aspx" rel="nofollow ugc">documentation</a> <strong>dwTypeData</strong></p>
<p dir="auto">When using with the <strong>SetMenuItemInfo</strong> function, this member should contain a value whose type is specified by the <strong>fType</strong> member.</p>
<p dir="auto"><strong>dwTypeData</strong> is used only if the <strong>MIIM_STRING</strong> flag is set in the <strong>fMask</strong> member</p>
<p dir="auto">For me it is not 100% clear what it means, so testing would have, maybe, shed some light on it,<br />
but without environment …<br />
Maybe you could give it a try and add</p>
<pre><code>mii.fType = MFT_STRING
</code></pre>
<p dir="auto">in addition it could be that <strong>cch</strong> member needs to be specified as well.</p>
<p dir="auto">You see, testing …</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24833</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24833</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Thu, 08 Jun 2017 15:55:12 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Thu, 08 Jun 2017 14:04:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello again,</p>
<p dir="auto">Franco’s original code is as follows:</p>
<pre><code>void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
{
   MENUITEMINFO mii;
   mii.cbSize = sizeof(MENUITEMINFO);
   mii.fMask = MIIM_STRING;
   mii.dwTypeData = const_cast&lt;LPTSTR&gt;(csc.toMenuItemString().c_str());
   ::SetMenuItemInfo(_hAccelMenu, csc.getID(), FALSE, &amp;mii);
}
</code></pre>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24832</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24832</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Thu, 08 Jun 2017 14:04:09 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Thu, 08 Jun 2017 13:15:32 GMT]]></title><description><![CDATA[<p dir="auto">Hello Claudia,</p>
<p dir="auto">I hope you’re doing well.</p>
<p dir="auto">I’ve been discussing this issue with Franco.<br />
Your code works perfectly. Thank you very much.</p>
<p dir="auto">Still, I’d like to further investigate why Franco’s original code does not work as expected.</p>
<p dir="auto"><img src="https://camo.nodebb.org/6a10d2bc7b8def9b8cce1321753544b86301b505?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F10229320%2F26930176-282b8410-4c65-11e7-8946-7cd7de884175.png" alt="default" class=" img-fluid img-markdown" /></p>
<p dir="auto">Not referring to this point, I assume you can not test it or it did not arouse your curiosity. :)<br />
Is that correct?</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24831</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24831</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Thu, 08 Jun 2017 13:15:32 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Mon, 05 Jun 2017 23:20:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/franco-stellari" aria-label="Profile: Franco-Stellari">@<bdi>Franco-Stellari</bdi></a></p>
<p dir="auto">not sure if this is the way to go, this pointer and const … stuff still confuses me,<br />
but what about</p>
<pre><code>void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
{
	MENUITEMINFO mii;
	mii.cbSize = sizeof(MENUITEMINFO);
	mii.fMask = MIIM_STRING;
	wstring sMenu(csc.toMenuItemString().c_str());
	mii.dwTypeData = &amp;sMenu[0];
	::SetMenuItemInfo(_hAccelMenu, csc.getID(), FALSE, &amp;mii);
}
</code></pre>
<p dir="auto">Unfortunately, I cannot test the code on linux but the conversion should be ok.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24802</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24802</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Mon, 05 Jun 2017 23:20:35 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Mon, 05 Jun 2017 20:11:44 GMT]]></title><description><![CDATA[<p dir="auto">Original code that causes the MenuIcons to disappear every time the menu text is updated by selecting/removing a recent file and changing the menu accelerators:</p>
<p dir="auto">void Accelerator::updateMenuItemByCommand(CommandShortcut csc)<br />
{<br />
int cmdID = csc.getID();<br />
//  Ensure that the menu item checks set prior to this update remain in affect.<br />
UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND);<br />
cmdFlags = MF_BYCOMMAND | ((cmdFlags&amp;MF_CHECKED) ? MF_CHECKED : MF_UNCHECKED);<br />
::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str());<br />
}</p>
<p dir="auto">The solution is “theoretically simple” (replace ::ModiyMenu with ::SetMenuInfo) but for mysterious reasons it corrupts the menus that contain the “&amp;” accelerator:</p>
<p dir="auto">void Accelerator::updateMenuItemByCommand(CommandShortcut csc)<br />
{<br />
MENUITEMINFO mii;<br />
mii.cbSize = sizeof(MENUITEMINFO);<br />
mii.fMask = MIIM_STRING;<br />
mii.dwTypeData = sMenu;<br />
mii.dwTypeData = const_cast&lt;LPTSTR&gt;(csc.toMenuItemString().c_str());<br />
::SetMenuItemInfo(_hAccelMenu, csc.getID(), FALSE, &amp;mii);<br />
}</p>
<p dir="auto">So the simple solution becomes ugly:</p>
<p dir="auto">void Accelerator::updateMenuItemByCommand(CommandShortcut csc)<br />
{<br />
LPTSTR sMenu = new TCHAR[_tcslen(csc.toMenuItemString().c_str()) + 1];<br />
_tcscpy_s(sMenu, _tcslen(csc.toMenuItemString().c_str()) + 1, (LPTSTR)csc.toMenuItemString().c_str());</p>
<pre><code>MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STRING;
mii.dwTypeData = sMenu;
::SetMenuItemInfo(_hAccelMenu, csc.getID(), FALSE, &amp;mii);

delete[]sMenu;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">The above works but it would be great if one could figure out how to make the simple one work… I searched the internet but could not find a solution.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24801</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24801</guid><dc:creator><![CDATA[Franco Stellari]]></dc:creator><pubDate>Mon, 05 Jun 2017 20:11:44 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Mon, 22 May 2017 16:01:15 GMT]]></title><description><![CDATA[<p dir="auto">Yes it is but for whatever reason I could not add a message to the thread.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24528</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24528</guid><dc:creator><![CDATA[Franco Stellari250]]></dc:creator><pubDate>Mon, 22 May 2017 16:01:15 GMT</pubDate></item><item><title><![CDATA[Reply to MenuIcon problem with latest version of NPP on Mon, 22 May 2017 15:55:53 GMT]]></title><description><![CDATA[<p dir="auto">Seems related to <a href="https://notepad-plus-plus.org/community/topic/13262/menuicons-plugin-1v21-released/12" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13262/menuicons-plugin-1v21-released/12</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/24527</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24527</guid><dc:creator><![CDATA[chcg]]></dc:creator><pubDate>Mon, 22 May 2017 15:55:53 GMT</pubDate></item></channel></rss>