<?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=469990&amp;view=findpost&amp;p=3932496</guid>
        <pubDate>Mon, 01 Dec 2025 14:04:33 +0000</pubDate>
        <title>Почему не создается tooltip к кнопке</title>
        <link>https://forum.sources.ru/index.php?showtopic=469990&amp;view=findpost&amp;p=3932496</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=469990&view=findpost&p=3932423'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Lun2 &#064; <time class="tag-quote__quoted-time" datetime="2025-11-30T12:43:13+03:00">30.11.25, 09:43</time></span><div class='quote '>Я хочу прикрутить к каждой кнопке tooltip, однако он не создается.</div></div><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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.cbSize = sizeof(toolInfo);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.hwnd = hButton;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.uId = &nbsp;someID;//(UINT_PTR)hwndTool; не хэндл, а некий уникальный идентификатор</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.lpszText = (LPWSTR) L&quot;tool tip&quot;;</div><div class="code_line">// vvv </div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;HINSTANCE hInstTT &nbsp;= ::GetModuleHandle(NULL); &nbsp;</div><div class="code_line">&nbsp;toolInfo.hinst &nbsp; &nbsp; = hInstTT;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;RECT rect;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;// GET COORDINATES OF THE MAIN CLIENT AREA </div><div class="code_line">&nbsp;::GetClientRect (hButton, &amp;rect);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;toolInfo.rect.left &nbsp; = rect.left; &nbsp; &nbsp;</div><div class="code_line">&nbsp;toolInfo.rect.top &nbsp; &nbsp;= rect.top;</div><div class="code_line">&nbsp;toolInfo.rect.right &nbsp;= rect.right;</div><div class="code_line">&nbsp;toolInfo.rect.bottom = rect.bottom;</div><div class="code_line">// ^^^</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&amp;toolInfo);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hwndTip, TTM_SETMAXTIPWIDTH, 0, MaxWidthTT); // у меня MaxWidthTT был по умолчанию 4096</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
И где-то раньше должен быть вызван <br>
&quot;InitCommonControls&quot;. Иначе может &quot;заглючить&quot;.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=469990&amp;view=findpost&amp;p=3932423</guid>
        <pubDate>Sun, 30 Nov 2025 09:43:13 +0000</pubDate>
        <title>Почему не создается tooltip к кнопке</title>
        <link>https://forum.sources.ru/index.php?showtopic=469990&amp;view=findpost&amp;p=3932423</link>
        <description><![CDATA[Lun2: Добрый день&#33;<br>
<br>
В окне hMainWnd создаю кнопки (это работает, они отображаются).<br>
<br>
Я хочу прикрутить к каждой кнопке tooltip, однако он не создается.<br>
Не могли бы Вы подсказать, в чем ошибка ?<br>
<br>
Немного смущает то, что все это делается до начала цикла приема сообщений, <br>
а в конце видно, что направляется сообщение для активации tooltip-a.<br>
<br>
Насколько это правильно - направлять сообщение здесь ?<br>
Если неправильно, то где это сделать ?<br>
<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">// создание кнопки</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HWND hButton = CreateWindow(L&quot;BUTTON&quot;, b.Caption.c_str(),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WS_VISIBLE | WS_CHILD,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartX, 0, ButtonWidth, 30,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hMainWnd, ButtonID, hInst, NULL);</div><div class="code_line">&nbsp;</div><div class="code_line">// создание tooltip-a</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HWND hwndTool = GetDlgItem(hMainWnd, b.ButtonID);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//hwndTool &#60;&#62; 0 =&#62; ошибки нет,</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Create the tooltip. g_hInst is the global instance handle.</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CW_USEDEFAULT, CW_USEDEFAULT,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CW_USEDEFAULT, CW_USEDEFAULT,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hMainWnd, NULL,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hInstance, NULL);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//hwndTip &#60;&#62; 0 =&#62; ошибки нет, hwndTip создался нормально</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Associate the tooltip with the tool.</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TOOLINFO toolInfo = { 0 };</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.cbSize = sizeof(toolInfo);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.hwnd = hMainWnd;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.uId = (UINT_PTR)hwndTool;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toolInfo.lpszText = (LPWSTR) L&quot;tool tip&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&amp;toolInfo);</div></ol></div></div></div></div><br>
<div class="tag-mod"><div class="tag-mod__prefix">M</div><div class="tag-mod__body">Используем тег <strong class='tag-b'>CODE</strong>&#33;</div></div>]]></description>
        <author>Lun2</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      </channel>
      </rss>
	