<?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=444595&amp;view=findpost&amp;p=3903199</guid>
        <pubDate>Wed, 17 Apr 2024 12:50:42 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903199</link>
        <description><![CDATA[Timon K: При желании можно и рамку сделать с закругленными краями и заливку с градиентом. Это уже при наличии времени поэкспериментировать.<br>
<span class="b-attach" data-size="15696" data-hits="477" data-attach-id="65731" data-attach-post-id="3903199">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3903199&amp;attach_id=65731' title='Скачать файл' target='_blank'>2024_04_17_16_47_56.png</a> (, : 477)
		</span><br>
<span class="b-attach" data-size="19060" data-hits="472" data-attach-id="65732" data-attach-post-id="3903199">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3903199&amp;attach_id=65732' title='Скачать файл' target='_blank'>2024_04_17_16_47_28.png</a> (, : 472)
		</span>]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903198</guid>
        <pubDate>Wed, 17 Apr 2024 12:46:04 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903198</link>
        <description><![CDATA[Timon K: <strong class='tag-b'>ЫукпШ</strong>, так в том теперь и фишка, что я хочу сделать со сменой цвета.<br>
Вот так у меня получилось.<br>
<br>
<br>
<span class="b-attach" data-size="27691" data-hits="509" data-attach-id="65729" data-attach-post-id="0">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=0&amp;attach_id=65729' title='Скачать файл' target='_blank'>2024_04_17_15_47_42.png</a> (, : 509)
		</span><br>
<span class="b-attach" data-size="29841" data-hits="487" data-attach-id="65730" data-attach-post-id="3903198">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3903198&amp;attach_id=65730' title='Скачать файл' target='_blank'>2024_04_17_15_48_21.png</a> (, : 487)
		</span>]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903184</guid>
        <pubDate>Wed, 17 Apr 2024 10:16:46 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903184</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=444595&view=findpost&p=3903156'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Timon K &#064; <time class="tag-quote__quoted-time" datetime="2024-04-16T16:28:29+00:00">16.04.24, 16:28</time></span><div class='quote '>А как сделать так, что бы цвет текста тоже менялся (например, на белый) при наползании на него заливки прогресса?</div></div><br>
Рисуем в памяти две копии прогресс-бара.<br>
Не залитую и 100% залитую системной заливкой.<br>
В оба образа выводим одну и ту же цифру процента<br>
по одинаковым координатам, но своего цвета.<br>
Вычисляем процент выполнения в пикселах и копируем<br>
этот процент залитого образа в окно. Остальное<br>
копируем из не залитого.<br>
---<br>
По моему это не удобно.<br>
Лучше поверх прогресс-бара вывести маленькое окно<br>
и туда выводить цифры.<br>
Вот так:<br>
<img class='tag-img' src='https://i.postimg.cc/K86dJZKN/2024-04-17-131915910.png' alt='user posted image'>]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903183</guid>
        <pubDate>Wed, 17 Apr 2024 10:12:03 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903183</link>
        <description><![CDATA[Timon K: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=444595&view=findpost&p=3903158'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>macomics &#064; <time class="tag-quote__quoted-time" datetime="2024-04-16T21:40:46+00:00">16.04.24, 21:40</time></span><div class='quote '>Например, рисовать заливку самостоятельно используя xor.</div></div><br>
Сделал так.<br>
При событии PAINT:<br>
1. Залил прямоугольник в желаемом месте и под желаемый размер заливкой пустого прогресс (белый)<br>
2. Нарисовал посередине текст (статус прогресса в процентах) цветом для пустого прогресса (чёрный), с прозрачным фоном. Предварительно задал желаемый шрифт и вычислил длину текущего текста в пикселях.<br>
3. Залил прямоугольник на тех же начальных координатах, той жы высоты, но ширина = статусу прогресса заливкой прогресса (например, красным).<br>
4. Нарисовал текст с теми же координатами, что и в пункте 2, только такой длины, что бы текст обрывался там, где кончается заливка - текущий статус прогресса. Цвет шрифта белый с прозрачным фоном. При этом, если заливка ещё не наползла на показ процентов, то длина текста = 0 и он не затирает уже имеющийся чёрный.<br>
При событии TIMER:<br>
1. Проверяю, не изменился ли счётчик (глобальная переменная, менять может, например, трид в котором функция работы с устройством через USB).<br>
2. Если изменился, нужно перерисовать, вызываю InvalidateRect, который снова посылает сообщение PAINT. Прогресс меняет статус.<br>
<br>
Вроде пока нормально работает отдельным приложением, но в теле своего проекта ещё не проверял.]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903158</guid>
        <pubDate>Tue, 16 Apr 2024 21:40:46 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903158</link>
        <description><![CDATA[macomics: Например, рисовать заливку самостоятельно используя xor.]]></description>
        <author>macomics</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903156</guid>
        <pubDate>Tue, 16 Apr 2024 16:28:29 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903156</link>
        <description><![CDATA[Timon K: Да, отлично, спасибо всем&#33;<br>От мерцания избавились.<br>А как сделать так, что бы цвет текста тоже менялся (например, на белый) при наползании на него заливки прогресса?]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903103</guid>
        <pubDate>Tue, 16 Apr 2024 07:30:22 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903103</link>
        <description><![CDATA[B.V.: Мерцание вызвано частыми перерисовками. Лечится не только уменьшением частоты обновлений, но и применением двойной буферизации. Системная двойная буферизация включается стилем WS_EX_COMPOSITED для родительского окна, должно помочь]]></description>
        <author>B.V.</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903021</guid>
        <pubDate>Sun, 14 Apr 2024 21:27:01 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903021</link>
        <description><![CDATA[ЫукпШ: Посредством сообщений - да.<br>Точно помню, что прогрессом из рабочего<br>потока я управлял.<br>---<br>Вот сейчас (на всякий случай) попробовал - в Эдит<br>из другого потока выводится строка посредством SendMessage.<br>Устойчиво работает.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903008</guid>
        <pubDate>Sat, 13 Apr 2024 10:29:08 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3903008</link>
        <description><![CDATA[Timon K: <strong class='tag-b'>ЫукпШ</strong>, а безопасно управлять контролами напрямую из другого потока?]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902977</guid>
        <pubDate>Fri, 12 Apr 2024 09:36:18 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902977</link>
        <description><![CDATA[ЫукпШ: <strong class='tag-b'>Timon K</strong>, я бы попытался сделать другое.<br>
Использовал бы PostMessage для изменения прогресса.<br>
Не стал бы читать прогресс. И пользоваться таймером.<br>
---<br>
Можно при изменении счётчика считать процент (запоминая предыдущий).<br>
При значимом изменении процента слать сообщение эдиту прямо<br>
из ThreadProc.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902951</guid>
        <pubDate>Thu, 11 Apr 2024 20:01:49 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902951</link>
        <description><![CDATA[Timon K: <strong class='tag-b'>macomics</strong>, да, вы правы.<br>
Только при обновлении в 100 мс и при высокой скорости прогресса его движение получается не очень плавным. А вот при 50 нормально. И мерцание пропало полностью. По крайней мере на моём компе.<br>
Спасибо&#33;]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902949</guid>
        <pubDate>Thu, 11 Apr 2024 19:21:29 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902949</link>
        <description><![CDATA[macomics: Скорее просто уменьшите количество обновлений в таймере (TIMER_PAUSE = 100 // 1000 / 100 = 10 раз в секунду). Этого вполне достаточно. Не надо обновлять компоненты слишком часто (все равно кадров у монитора 50 - 100). У вас же перерисовывается 200 раз (TIMER_PAUSE = 5 // 1000 / 5 = 200).]]></description>
        <author>macomics</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902941</guid>
        <pubDate>Thu, 11 Apr 2024 14:48:02 +0000</pubDate>
        <title>Мерцание дочернего EDIT</title>
        <link>https://forum.sources.ru/index.php?showtopic=444595&amp;view=findpost&amp;p=3902941</link>
        <description><![CDATA[Timon K: Просьба помочь избавиться от мерцания при перерисовке дочернего контрола вывода процентов на прогресс-баре.<br>
Если скорость прогресса не высока (THREAD_PAUSE&gt;40), то мерцаний не видно. А если меньше, например, 10 как выставлено в примере, то выглядит не очень симпатично.<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">#include &#60;tchar.h&#62;</div><div class="code_line">#include &#60;windows.h&#62;</div><div class="code_line">#include &#60;commctrl.h&#62; </div><div class="code_line">#include &#60;sstream&#62;</div><div class="code_line">#include &#60;string&#62;</div><div class="code_line">//#include &#60;stdio.h&#62;</div><div class="code_line">//#include &#60;richedit.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">#define TIMER_PAUSE 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // пауза таймера - как часто проверять значение счётчика</div><div class="code_line">#define THREADS_NUMBER 1 &nbsp; &nbsp; &nbsp; &nbsp;// кол-во одновременно запущенных тридов, тут не нужно</div><div class="code_line">#define ITERATIONS_NUMBER 101 &nbsp; //сколько раз выполнить трид, должно быть 100 (%), сейчас специально выставлено 101</div><div class="code_line">#define THREAD_PAUSE 10 &nbsp; &nbsp; &nbsp; &nbsp; // пауза в триде - скорость счётчика</div><div class="code_line">#define PROGRESS_MAX 100 &nbsp; &nbsp; &nbsp; &nbsp;// </div><div class="code_line">#define EXIT_ERR(mess) &nbsp;{MessageBox(NULL, TEXT(mess), TEXT(&quot;Error&quot;), MB_OK); return 0;}// выход из программы при ошибке</div><div class="code_line">&nbsp;</div><div class="code_line">const enum </div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;ID_PROGRESS_1=100,</div><div class="code_line">&nbsp;&nbsp; &nbsp;ID_EDIT_1,</div><div class="code_line">&nbsp;&nbsp; &nbsp;ID_TIMER_1</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">DWORD GL_COUNTER=0;//счётчик</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">LRESULT APIENTRY WndProc(HWND, UINT, WPARAM, LPARAM);</div><div class="code_line">LRESULT APIENTRY EditSubclassProc(HWND, UINT, WPARAM, LPARAM);</div><div class="code_line">template &#60;typename T&#62; std::string to_string (const T &amp;x);// INT, указатель в STRING</div><div class="code_line">DWORD WINAPI ThreadProc(CONST LPVOID);</div><div class="code_line">&nbsp;</div><div class="code_line">int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)</div><div class="code_line">&nbsp;</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;HWND hMainWnd;</div><div class="code_line">&nbsp;&nbsp; &nbsp;HANDLE hThreads[THREADS_NUMBER];</div><div class="code_line">&nbsp;&nbsp; &nbsp;CONST HANDLE hMutex = CreateMutex(NULL, FALSE, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp;TCHAR szClassName[] = TEXT(&quot;MyClass&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp;MSG msg;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WNDCLASSEX wc;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.cbSize &nbsp; &nbsp; &nbsp; =sizeof(wc);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.style &nbsp; &nbsp; &nbsp; &nbsp;=CS_HREDRAW | CS_VREDRAW;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.lpfnWndProc &nbsp;=WndProc;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.cbClsExtra &nbsp; =0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.cbWndExtra &nbsp; =0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.hInstance &nbsp; &nbsp;=hInstance;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.hIcon &nbsp; &nbsp; &nbsp; &nbsp;=LoadIcon(NULL, IDI_APPLICATION);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.hCursor &nbsp; &nbsp; &nbsp;=LoadCursor(NULL, IDC_ARROW);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.lpszMenuName =NULL;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.lpszClassName=szClassName;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wc.hIconSm &nbsp; &nbsp; &nbsp;=LoadIcon(NULL, IDI_APPLICATION);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!RegisterClassEx(&amp;wc)) EXIT_ERR(&quot;Cannot register the class&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp;hMainWnd = CreateWindow(szClassName, TEXT(&quot;Application&quot;), WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, 0, 0, 700, 500, (HWND)NULL, (HMENU)NULL, (HINSTANCE)hInstance, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!hMainWnd) EXIT_ERR(&quot;Cannot creat the Main Win&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp;ShowWindow(hMainWnd, nCmdShow);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!SetTimer(hMainWnd, ID_TIMER_1, TIMER_PAUSE, (TIMERPROC) NULL)) EXIT_ERR(&quot;Cannot creat the Timer&quot;) </div><div class="code_line">&nbsp;&nbsp; &nbsp;hThreads[0]=CreateThread(NULL, 0, &amp;ThreadProc, hMutex, 0, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!hThreads[0]) EXIT_ERR(&quot;Cannot creat the Thread&quot;)</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while (GetMessage(&amp;msg, NULL, 0, 0))</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;TranslateMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DispatchMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;CloseHandle(hThreads[0]);</div><div class="code_line">&nbsp;&nbsp; &nbsp;CloseHandle(hMutex);</div><div class="code_line">&nbsp;&nbsp; &nbsp;return msg.wParam;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">LRESULT APIENTRY WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;static HWND hWndEdit, hProgBar;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch (msg)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_CREATE:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// прогресс </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hProgBar=CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | PBS_SMOOTH, 60, 40, 140, 40, hWnd, (HMENU)ID_PROGRESS_1, NULL, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hProgBar, PBM_SETRANGE, 0, (LPARAM)MAKELONG(0, PROGRESS_MAX));// мин и макс</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hProgBar, PBM_SETSTEP, (WPARAM)1, 0);// шаг - по умолчанию 10</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hProgBar, PBM_SETBARCOLOR, 0, (LPARAM)RGB(0, 255, 0));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hProgBar, PBM_SETBKCOLOR, 0, (LPARAM)RGB(255,255,255));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// дочерний от прогресса контрол для показа процентов</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hWndEdit=CreateWindow(TEXT(&quot;EDIT&quot;), TEXT(&quot;&quot;), WS_VISIBLE | WS_CHILD| ES_READONLY | SS_CENTER, 50, 10, 40, 20, hProgBar, (HMENU)ID_EDIT_1, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE)/*зачем это?*/, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetWindowLongPtr(hProgBar, GWL_USERDATA, SetWindowLongPtr(hProgBar, GWL_WNDPROC, (LPARAM)EditSubclassProc));// вешаем новый обработчик и одновременно запоминаем адрес первого (вносим в DATA)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_TIMER: </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;switch (wParam) </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case ID_TIMER_1: </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (SendMessage(hProgBar, PBM_GETPOS, 0, 0)!=GL_COUNTER)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(hProgBar, PBM_SETPOS, GL_COUNTER, 0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetWindowText(hWndEdit, (to_string(GL_COUNTER)+&quot;%&quot;).c_str());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_CHAR:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;switch (LOWORD(wParam))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wParam == 13)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox(hWnd,(to_string(hWnd)+&quot; : &quot;).c_str(),TEXT(&quot;MessageBox&quot;),MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_CLOSE:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DestroyWindow(hWnd);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_DESTROY:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetWindowLongPtr(hWndEdit,GWLP_WNDPROC,(LPARAM)GetWindowLongPtr(hWndEdit,GWLP_WNDPROC));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PostQuitMessage(0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;default:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return DefWindowProc(hWnd, msg, wParam, lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;return DefWindowProc(hWnd, msg, wParam, lParam);</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">LRESULT APIENTRY EditSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)</div><div class="code_line">{// обработчик событий №2- контрол прогресс бара на которм дочерний EDIT с процентами</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch(msg)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_COMMAND:// перерисовать EDIT что бы текст с процентами отрисовывался правильно </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(HIWORD(wParam)==EN_CHANGE)//(иначе на прозрачном фоне бардак)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RECT rect;//</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetClientRect(HWND(lParam), &amp;rect);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InvalidateRect(HWND(lParam), &amp;rect, TRUE);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MapWindowPoints(HWND(lParam), hWnd, (POINT *) &amp;rect, 2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RedrawWindow(hWnd, &amp;rect, NULL, RDW_ERASE | RDW_INVALIDATE);//*/</div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowWindow(HWND(lParam),SW_HIDE);// можно сделать проще всего двумя стироками</div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowWindow(HWND(lParam),SW_SHOW);// но так мерцает вроде сильнее</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_CTLCOLORSTATIC:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetBkMode((HDC)wParam, TRANSPARENT);// это делает фон под шрифтом прозрачным</div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return (LRESULT)CreateSolidBrush(RGB(255, 255, 255));// это устанавлмвает цвет полностью фона</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return (LRESULT)GetStockObject(NULL_BRUSH);// это делает фон прозрачным</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">// &nbsp;PostMessage(GetParent(GetParent(hWnd)), msg, wParam, lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp;return CallWindowProc((WNDPROC)GetWindowLongPtr(hWnd, GWL_USERDATA), hWnd, msg, wParam, lParam);</div><div class="code_line">}</div><div class="code_line">template &#60;typename T&#62;</div><div class="code_line">std::string to_string(const T &amp;x)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;std::stringstream buf;</div><div class="code_line">&nbsp;&nbsp; &nbsp;buf &#60;&#60; x;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return buf.str();</div><div class="code_line">}</div><div class="code_line">DWORD WINAPI ThreadProc(CONST LPVOID lpParam) </div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;const HANDLE hMutex = (CONST HANDLE)lpParam;</div><div class="code_line">&nbsp;&nbsp; &nbsp;DWORD i;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(i = 0; i &#60; ITERATIONS_NUMBER; i++)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;WaitForSingleObject(hMutex, INFINITE);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;GL_COUNTER++;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ReleaseMutex(hMutex);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Sleep(THREAD_PAUSE);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;ExitThread(0);</div><div class="code_line">}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>Timon K</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      </channel>
      </rss>
	