<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2318770</guid>
        <pubDate>Thu, 23 Jul 2009 06:14:56 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2318770</link>
        <description><![CDATA[Nikfel: Большое спасибо. Теперь всё ясно.]]></description>
        <author>Nikfel</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2318726</guid>
        <pubDate>Thu, 23 Jul 2009 05:20:12 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2318726</link>
        <description><![CDATA[leo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2318593'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-22T20:54:43+00:00">22.07.09, 20:54</time></span><div class='quote '>var ItemName:pchar;<br>
...<br>
ItemName:=MII.dwTypeData;</div></div><br>
Так делать нельзя, т.к. ItemName:pChar указывает на локальную переменную buffer, которая становится невалидной после выхода из функции (затирается другими данными при операциях со стеком). Нужно использовать ItemName:string<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">function GetMenuItemName(Menu_:HMenu; INDEX:integer):string;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;Buffer: array[0..63] of Char;</div><div class="code_line">&nbsp;&nbsp;MII:MENUITEMINFO;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;MII.cbSize &nbsp; &nbsp; &nbsp; &nbsp;:= SizeOf(MENUITEMINFO);</div><div class="code_line">&nbsp;&nbsp;MII.fMask &nbsp; &nbsp; &nbsp; &nbsp; := MIIM_FTYPE or MIIM_STRING;</div><div class="code_line">&nbsp;&nbsp;MII.dwTypeData &nbsp; &nbsp;:= Buffer;</div><div class="code_line">&nbsp;&nbsp;MII.cch &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := sizeof(Buffer);</div><div class="code_line">&nbsp;&nbsp;If GetMenuItemInfo(Menu_,INDEX,true,MII) and </div><div class="code_line">&nbsp;&nbsp; &nbsp; (MII.fType and MFT_STRING &#60;&#62; 0) then</div><div class="code_line">&nbsp;&nbsp; &nbsp;Result:=MII.dwTypeData</div><div class="code_line">&nbsp;&nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp;Result:=&#39;&#39;;</div><div class="code_line">end;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>leo</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2318593</guid>
        <pubDate>Wed, 22 Jul 2009 20:54:43 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2318593</link>
        <description><![CDATA[Nikfel: А вот как получить текст пункта меню, если не MFT_OWNERDRAW? Пробовал так, но не вышло:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">var ItemName:pchar;</div><div class="code_line">&nbsp;</div><div class="code_line">function GetMenuIDName(Menu_:HMenu; INDEX:integer):boolean;</div><div class="code_line">var Buffer: array[0..50] of Char;</div><div class="code_line">begin</div><div class="code_line">MII.cbSize &nbsp; &nbsp; &nbsp; &nbsp;:= SizeOf(MENUITEMINFO);</div><div class="code_line">MII.fMask &nbsp; &nbsp; &nbsp; &nbsp; := MIIM_FTYPE or miim_submenu or miim_string;</div><div class="code_line">MII.dwTypeData &nbsp; &nbsp;:= buffer;</div><div class="code_line">MII.cch &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := sizeof(buffer);</div><div class="code_line">result:=false;</div><div class="code_line">If GetMenuItemInfo(Menu_,INDEX,true,MII) then begin</div><div class="code_line">result:=true;</div><div class="code_line">ItemName:=MII.dwTypeData;</div><div class="code_line">end;</div><div class="code_line">end;</div></ol></div></div></div></div>]]></description>
        <author>Nikfel</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317824</guid>
        <pubDate>Wed, 22 Jul 2009 09:40:53 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317824</link>
        <description><![CDATA[leo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317815'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-22T09:30:01+00:00">22.07.09, 09:30</time></span><div class='quote '>Значит для типа MFT_OWNERDRAW никак нельзя получить текст пункта меню</div></div><br>
Да, т.к. при MFT_OWNERDRAW текст меню отрисовывается самим приложением и в ItemInfo не хранится]]></description>
        <author>leo</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317815</guid>
        <pubDate>Wed, 22 Jul 2009 09:30:01 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317815</link>
        <description><![CDATA[Nikfel: Спасибо. Теперь все понятно. Значит для типа MFT_OWNERDRAW никак нельзя получить текст пункта меню.]]></description>
        <author>Nikfel</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317807</guid>
        <pubDate>Wed, 22 Jul 2009 09:23:01 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317807</link>
        <description><![CDATA[leo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317762'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-22T08:54:19+00:00">22.07.09, 08:54</time></span><div class='quote '>Теперь вроде заработало, но только почему-то не получает текст пункта меню?</div></div><br>
Смотри возвращаемый тип fType - текст возвращается только для типа MII.fType = MFT_STRING, а для MFT_SEPARATOR или MFT_OWNERDRAW - нет]]></description>
        <author>leo</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317762</guid>
        <pubDate>Wed, 22 Jul 2009 08:54:19 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317762</link>
        <description><![CDATA[Nikfel: Спасибо. Теперь вроде заработало, но только почему-то не получает текст пункта меню?]]></description>
        <author>Nikfel</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317751</guid>
        <pubDate>Wed, 22 Jul 2009 08:35:36 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317751</link>
        <description><![CDATA[leo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317266'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-21T16:24:27+00:00">21.07.09, 16:24</time></span><div class='quote '>MII.fMask         := MIIM_STRING or MIIM_TYPE;</div></div><br>
Это неверное сочетание флагов, нужно юзать либо просто MIIM_TYPE (для совместимости с Win95), либо MIIM_STRING or MIIM_<strong class='tag-b'><span class="tag-color tag-color-named" data-value="red" style="color: red">F</span></strong>TYPE<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317266'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-21T16:24:27+00:00">21.07.09, 16:24</time></span><div class='quote '>If GetMenuItemInfo(Menu,itemID,true,MII) then begin</div></div><br>
Если itemID - идентификатор пункта меню (TMenuItem.Command), то 3-й параметр д.б. false, а если это порядковый номер (индекс TMenuItem.MenuIndex) пункта в выпадающем меню, то true<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317724'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-22T07:51:40+00:00">22.07.09, 07:51</time></span><div class='quote '>На Delphi пробовал задать через символ @, но не сработало</div></div><br>
В дельфи последний параметр определен как var, поэтому никаких @ задавать не нужно <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2009-07-22T08:43:54+00:00">22.07.09, 08:43</time></span></span><br>
PS:<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317266'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-21T16:24:27+00:00">21.07.09, 16:24</time></span><div class='quote '>MII.fType         := MFT_STRING or MFT_OWNERDRAW;</div></div><br>
fType в GetMenuItemInfo является вых.параметром, поэтому задавать его самому бесполезно<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317266'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-21T16:24:27+00:00">21.07.09, 16:24</time></span><div class='quote '>var Buffer: array[0..50] of Char;<br>
...<br>
MII.cch           := 1023;</div></div><br>
Обманывать не хорошо ;) Нужно задавать cch = реальному размеру буфера SizeOf(buffer)]]></description>
        <author>leo</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317724</guid>
        <pubDate>Wed, 22 Jul 2009 07:51:40 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317724</link>
        <description><![CDATA[Nikfel: GetMenuItemInfo всегда возвращает False и это значит что данные функция не получает. Состояние переменной Menu&lt;&gt;0. Я считаю что я просто не правильно записал.<br>
<br>
Вот из C++:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">mii.fMask = MIIM_SUBMENU; &nbsp;// информация, которую получаем &nbsp; &nbsp;</div><div class="code_line">GetMenuItemInfo(hmenuBar, IDM_CHARACTER, FALSE, &amp;mii);</div></ol></div></div></div></div><br>
<br>
Я вот никак не пойму что за символ &amp; в C++? На Delphi пробовал задать через символ @, но не сработало. В чем же моя ошибка не пойму ни как? Мне надо просто получить информацию о пункте меню, т.е. есть ли выпадающее меню и текст в пункте меню.]]></description>
        <author>Nikfel</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317614</guid>
        <pubDate>Wed, 22 Jul 2009 05:44:04 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317614</link>
        <description><![CDATA[Marriage: А что именно не работает ?]]></description>
        <author>Marriage</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317537</guid>
        <pubDate>Wed, 22 Jul 2009 00:09:21 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317537</link>
        <description><![CDATA[miksayer: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=277457&view=findpost&p=2317266'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Nikfel &#064; <time class="tag-quote__quoted-time" datetime="2009-07-21T16:24:27+00:00">21.07.09, 16:24</time></span><div class='quote '>Но вроде не работает</div></div><br>
вроде или не работает?<br>
откуда ты Menu берешь? оно точно создано? что возвращает эта функция? если false, то что говорит GetLastError?]]></description>
        <author>miksayer</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317266</guid>
        <pubDate>Tue, 21 Jul 2009 16:24:27 +0000</pubDate>
        <title>Как работать с GetMenuItemInfo?</title>
        <link>https://forum.sources.ru/index.php?showtopic=277457&amp;view=findpost&amp;p=2317266</link>
        <description><![CDATA[Nikfel: Пробовал так:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">function GetMenuIDName(itemID:integer):boolean;</div><div class="code_line">var Buffer: array[0..50] of Char;</div><div class="code_line">begin</div><div class="code_line">MII.cbSize &nbsp; &nbsp; &nbsp; &nbsp;:= SizeOf(MENUITEMINFO);</div><div class="code_line">MII.fMask &nbsp; &nbsp; &nbsp; &nbsp; := MIIM_STRING or MIIM_TYPE;</div><div class="code_line">MII.fType &nbsp; &nbsp; &nbsp; &nbsp; := MFT_STRING or MFT_OWNERDRAW;</div><div class="code_line">MII.dwTypeData &nbsp; &nbsp;:= buffer;</div><div class="code_line">MII.cch &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := 1023;</div><div class="code_line">result:=false;</div><div class="code_line">If GetMenuItemInfo(Menu,itemID,true,MII) then begin</div><div class="code_line">result:=true;</div><div class="code_line">ItemName:=MII.dwTypeData;</div><div class="code_line">end;</div><div class="code_line">end;</div></ol></div></div></div></div><br>
<br>
Но вроде не работает. Где ошибка? Заранее спасибо.]]></description>
        <author>Nikfel</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      </channel>
      </rss>
	