<?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=469769&amp;view=findpost&amp;p=3932234</guid>
        <pubDate>Wed, 26 Nov 2025 19:49:52 +0000</pubDate>
        <title>Почему ListView не выводится на экран ?</title>
        <link>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932234</link>
        <description><![CDATA[sharky72: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=469769&view=findpost&p=3932233'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Lun2 &#064; <time class="tag-quote__quoted-time" datetime="2025-11-26T21:59:16+03:00">26.11.25, 18:59</time></span><div class='quote '>В этой задаче мне нужен только ListView, а не богатый интерфейс в целом (ну может пара кнопок еще).<br>
Я посчитал, что изучение MFC и одного Listview winapi не больно-то и отличаются по времени.</div></div><br>
Ну и зря. Количество кода которого надо набить руками в WinAPI и MFC различается порядками. Плюс стоит вам чуть выйти за пределы &quot;академических&quot; экзерцисов, в сторону хоть какого то вменяемого UI который бы работал на современном железе и поддерживал современные системы и те же HiDPI мониторы - мое вам сочувствие. Забудьте. Так же как писать под винду на асме. Можно, но пахнет редкими извращениями.]]></description>
        <author>sharky72</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932233</guid>
        <pubDate>Wed, 26 Nov 2025 18:59:16 +0000</pubDate>
        <title>Почему ListView не выводится на экран ?</title>
        <link>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932233</link>
        <description><![CDATA[Lun2: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=469769&view=findpost&p=3932167'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>sharky72 &#064; <time class="tag-quote__quoted-time" datetime="2025-11-25T22:18:24+00:00">25.11.25, 22:18</time></span><div class='quote '>А кто будет добавлять столбцы перед добавлением строк?</div></div><br>
<br>
<br>
sharky72, спасибо&#33;<br>
Вы правы - надо было добавить столбцы&#33;<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=469769&view=findpost&p=3932167'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>sharky72 &#064; <time class="tag-quote__quoted-time" datetime="2025-11-25T22:18:24+00:00">25.11.25, 22:18</time></span><div class='quote '>P.S. На кой вам писать оконный интерфейс на чистом WinAPI? :) Это же мазохизм чистой воды.<br>
Ну посмотрите хотя бы в сторону MFC. Про остальные фреймворки я уж не говорю. </div></div><br>
<br>
Предыдущие мои разборки (с другими диалогами) были как раз с MFC.<br>
Не сказать, чтоб слишком просто и быстро :(<br>
В этой задаче мне нужен только ListView, а не богатый интерфейс в целом (ну может пара кнопок еще).<br>
Я посчитал, что изучение MFC и одного Listview winapi не больно-то и отличаются по времени.]]></description>
        <author>Lun2</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932167</guid>
        <pubDate>Tue, 25 Nov 2025 22:18:24 +0000</pubDate>
        <title>Почему ListView не выводится на экран ?</title>
        <link>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932167</link>
        <description><![CDATA[sharky72: А кто будет добавлять столбцы перед добавлением строк?<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;LVCOLUMN lvColumn = { 0 };</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvColumn.pszText = const_cast&#60;LPWSTR&#62;(L&quot;Column 1&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvColumn.cx = 200; // Width of the column</div><div class="code_line">&nbsp;&nbsp; &nbsp;ListView_InsertColumn(hWndListView, 0, &amp;lvColumn);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;LVITEM lvI = { 0 };</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Initialize LVITEM members that are common to all items.</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message.</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.mask = LVIF_TEXT | /*LVIF_IMAGE | */ LVIF_STATE;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.stateMask = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.iSubItem = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.state = 0;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
А это зачем?<br>
Почему не вернуть 0 в случае завершения программы?<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">return (int) msg.wParam;</div></ol></div></div></div></div><br>
<br>
Инициализацию InitCommonControlsEx нужно делать всего один раз.<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">InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);</div></ol></div></div></div></div><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">&nbsp;&nbsp; if (!hListView) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; BOOL ok = InsertListViewItems(hListView, 5);</div><div class="code_line">&nbsp;&nbsp; }</div></ol></div></div></div></div><br>
P.S. На кой вам писать оконный интерфейс на чистом WinAPI? :) Это же мазохизм чистой воды.<br>
Ну посмотрите хотя бы в сторону MFC. Про остальные фреймворки я уж не говорю.]]></description>
        <author>sharky72</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932166</guid>
        <pubDate>Tue, 25 Nov 2025 21:43:47 +0000</pubDate>
        <title>Почему ListView не выводится на экран ?</title>
        <link>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932166</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=469769&view=findpost&p=3932165'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Lun2 &#064; <time class="tag-quote__quoted-time" datetime="2025-11-25T18:35:28+00:00">25.11.25, 18:35</time></span><div class='quote '>Не поможете разобраться - что не так, почему ListView нормально не рисуется ?</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">if (!hListView) {</div></ol></div></div></div></div><br>
(в функции InitInstance)]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932165</guid>
        <pubDate>Tue, 25 Nov 2025 18:35:28 +0000</pubDate>
        <title>Почему ListView не выводится на экран ?</title>
        <link>https://forum.sources.ru/index.php?showtopic=469769&amp;view=findpost&amp;p=3932165</link>
        <description><![CDATA[Lun2: [attach=#0][/attach][attach=#0][/attach]Добрый вечер&#33;<br>
Решил соорудить простой пример ListView на WinApi, но, к сожалению, я так и не смог заставить его заработать.<br>
Видно, что он что-то пытается вывести (см. серую полоску) вверху окна, но это не совсем то, что надо.<br>
Код прилагается.<br>
InitInstance создает главное окно, вызывает:<br>
- CreateListView - для создания окна ListView,<br>
- InsertListViewItems - для создания элементов ListView.<br>
Обработчик WM_MOTIFY - в конце текста, он вызывается.<br>
Не поможете разобраться - что не так, почему ListView нормально не рисуется ?<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">#pragma comment( lib, &quot;comctl32&quot; )</div><div class="code_line">&nbsp;</div><div class="code_line">#include &quot;framework.h&quot;</div><div class="code_line">#include &quot;commctrl.h&quot;</div><div class="code_line">#include &#60;windowsx.h&#62; &nbsp; &nbsp; &nbsp; // HANDLE_MSG</div><div class="code_line">#include &quot;ProcList.h&quot;</div><div class="code_line">#include &#60;assert.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">#define MAX_LOADSTRING 100</div><div class="code_line">&nbsp;</div><div class="code_line">// Глобальные переменные:</div><div class="code_line">HINSTANCE hInst; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// текущий экземпляр</div><div class="code_line">WCHAR szTitle[MAX_LOADSTRING]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Текст строки заголовка</div><div class="code_line">WCHAR szWindowClass[MAX_LOADSTRING]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// имя класса главного окна</div><div class="code_line">&nbsp;</div><div class="code_line">// Отправить объявления функций, включенных в этот модуль кода:</div><div class="code_line">ATOM &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MyRegisterClass(HINSTANCE hInstance);</div><div class="code_line">BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InitInstance(HINSTANCE, int);</div><div class="code_line">LRESULT CALLBACK &nbsp; &nbsp;WndProc(HWND, UINT, WPARAM, LPARAM);</div><div class="code_line">INT_PTR CALLBACK &nbsp; &nbsp;About(HWND, UINT, WPARAM, LPARAM);</div><div class="code_line">// --------------------------</div><div class="code_line">HWND CreateListView(HINSTANCE hInstance, HWND hwndParent);</div><div class="code_line">BOOL InsertListViewItems(HWND hWndListView, int cItems);</div><div class="code_line">void HandleWM_NOTIFY(LPARAM lParam);</div><div class="code_line">&nbsp;</div><div class="code_line">int APIENTRY wWinMain(_In_ HINSTANCE hInstance,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _In_opt_ HINSTANCE hPrevInstance,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _In_ LPWSTR &nbsp; &nbsp;lpCmdLine,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _In_ int &nbsp; &nbsp; &nbsp; nCmdShow)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;UNREFERENCED_PARAMETER(hPrevInstance);</div><div class="code_line">&nbsp;&nbsp; &nbsp;UNREFERENCED_PARAMETER(lpCmdLine);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;INITCOMMONCONTROLSEX InitCtrls;</div><div class="code_line">&nbsp;&nbsp; &nbsp;InitCtrls.dwICC = ICC_LISTVIEW_CLASSES;</div><div class="code_line">&nbsp;&nbsp; &nbsp;InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);</div><div class="code_line">&nbsp;&nbsp; &nbsp;BOOL bRet = InitCommonControlsEx(&amp;InitCtrls);</div><div class="code_line">&nbsp;&nbsp; &nbsp;assert(bRet == TRUE);</div><div class="code_line">&nbsp;&nbsp; &nbsp;//InitCommonControls();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Инициализация глобальных строк</div><div class="code_line">&nbsp;&nbsp; &nbsp;LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);</div><div class="code_line">&nbsp;&nbsp; &nbsp;LoadStringW(hInstance, IDC_PROCLIST, szWindowClass, MAX_LOADSTRING);</div><div class="code_line">&nbsp;&nbsp; &nbsp;MyRegisterClass(hInstance);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Выполнить инициализацию приложения:</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!InitInstance (hInstance, nCmdShow))</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return FALSE;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_PROCLIST));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;MSG msg;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Цикл основного сообщения:</div><div class="code_line">&nbsp;&nbsp; &nbsp;while (GetMessage(&amp;msg, nullptr, 0, 0))</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!TranslateAccelerator(msg.hwnd, hAccelTable, &amp;msg))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TranslateMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DispatchMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return (int) msg.wParam;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">//</div><div class="code_line">// &nbsp;ФУНКЦИЯ: MyRegisterClass()</div><div class="code_line">//</div><div class="code_line">// &nbsp;ЦЕЛЬ: Регистрирует класс окна.</div><div class="code_line">//</div><div class="code_line">ATOM MyRegisterClass(HINSTANCE hInstance)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;WNDCLASSEXW wcex;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.cbSize = sizeof(WNDCLASSEX);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.style &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= CS_HREDRAW | CS_VREDRAW;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.lpfnWndProc &nbsp; &nbsp;= WndProc;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.cbClsExtra &nbsp; &nbsp; = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.cbWndExtra &nbsp; &nbsp; = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.hInstance &nbsp; &nbsp; &nbsp;= hInstance;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.hIcon &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PROCLIST));</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.hCursor &nbsp; &nbsp; &nbsp; &nbsp;= LoadCursor(nullptr, IDC_ARROW);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.hbrBackground &nbsp;= (HBRUSH)(COLOR_WINDOW+1);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.lpszMenuName &nbsp; = MAKEINTRESOURCEW(IDC_PROCLIST);</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.lpszClassName &nbsp;= szWindowClass;</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcex.hIconSm &nbsp; &nbsp; &nbsp; &nbsp;= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return RegisterClassExW(&amp;wcex);</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">//</div><div class="code_line">// &nbsp; ФУНКЦИЯ: InitInstance(HINSTANCE, int)</div><div class="code_line">//</div><div class="code_line">// &nbsp; ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно</div><div class="code_line">//</div><div class="code_line">// &nbsp; КОММЕНТАРИИ:</div><div class="code_line">//</div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp;В этой функции маркер экземпляра сохраняется в глобальной переменной, а также</div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp;создается и выводится главное окно программы.</div><div class="code_line">//</div><div class="code_line">BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; if (!hWnd)</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return FALSE;</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; HWND hListView = CreateListView(hInstance, hWnd);</div><div class="code_line">&nbsp;&nbsp; assert(hListView != 0);</div><div class="code_line">&nbsp;&nbsp; if (!hListView) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; BOOL ok = InsertListViewItems(hListView, 5);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; ShowWindow(hWnd, nCmdShow);</div><div class="code_line">&nbsp;&nbsp; UpdateWindow(hWnd);</div><div class="code_line">&nbsp;&nbsp; if (!hListView) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; ShowWindow(hListView, SW_SHOW);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; UpdateWindow(hListView);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; return TRUE;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">//</div><div class="code_line">// &nbsp;ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)</div><div class="code_line">//</div><div class="code_line">// &nbsp;ЦЕЛЬ: Обрабатывает сообщения в главном окне.</div><div class="code_line">//</div><div class="code_line">// &nbsp;WM_COMMAND &nbsp;- обработать меню приложения</div><div class="code_line">// &nbsp;WM_PAINT &nbsp; &nbsp;- Отрисовка главного окна</div><div class="code_line">// &nbsp;WM_DESTROY &nbsp;- отправить сообщение о выходе и вернуться</div><div class="code_line">//</div><div class="code_line">//</div><div class="code_line">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch (message)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;case WM_COMMAND:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int wmId = 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;switch (wmId)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case IDM_ABOUT:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case IDM_EXIT:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DestroyWindow(hWnd);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;default:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return DefWindowProc(hWnd, message, wParam, lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;case WM_PAINT:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PAINTSTRUCT ps;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HDC hdc = BeginPaint(hWnd, &amp;ps);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// TODO: Добавьте сюда любой код прорисовки, использующий HDC...</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EndPaint(hWnd, &amp;ps);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;case WM_DESTROY:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;PostQuitMessage(0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// -----------------------</div><div class="code_line">&nbsp;&nbsp; &nbsp;case WM_NOTIFY:</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HandleWM_NOTIFY(lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// -----------------------</div><div class="code_line">&nbsp;&nbsp; &nbsp;default:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return DefWindowProc(hWnd, message, wParam, lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">// Обработчик сообщений для окна &quot;О программе&quot;.</div><div class="code_line">INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;UNREFERENCED_PARAMETER(lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch (message)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;case WM_INITDIALOG:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return (INT_PTR)TRUE;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;case WM_COMMAND:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EndDialog(hDlg, LOWORD(wParam));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return (INT_PTR)TRUE;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;return (INT_PTR)FALSE;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">// CreateListView: Creates a list-view control in report view.</div><div class="code_line">// Returns the handle to the new control</div><div class="code_line">// TO DO: &nbsp;The calling procedure should determine whether the handle is NULL, in case </div><div class="code_line">// of an error in creation.</div><div class="code_line">//</div><div class="code_line">// HINST hInst: The global handle to the application instance.</div><div class="code_line">// HWND &nbsp;hWndParent: The handle to the control&#39;s parent window. </div><div class="code_line">//</div><div class="code_line">HWND CreateListView(HINSTANCE hInstance, HWND hwndParent)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;INITCOMMONCONTROLSEX icex; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Structure for control initialization.</div><div class="code_line">&nbsp;&nbsp; &nbsp;icex.dwICC = ICC_LISTVIEW_CLASSES;</div><div class="code_line">&nbsp;&nbsp; &nbsp;InitCommonControlsEx(&amp;icex);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;RECT rcClient; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // The parent window&#39;s client area.</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;GetClientRect(hwndParent, &amp;rcClient);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Create the list-view window in report view with label editing enabled.</div><div class="code_line">&nbsp;&nbsp; &nbsp;HMENU hMenu = NULL; // &nbsp;(HMENU)IDM_CODE_SAMPLES</div><div class="code_line">&nbsp;&nbsp; &nbsp;HWND hWndListView = CreateWindow(WC_LISTVIEW,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;L&quot;&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;WS_CHILD | LVS_REPORT | LVS_EDITLABELS | WS_VISIBLE,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;0, 0,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rcClient.right - rcClient.left,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rcClient.bottom - rcClient.top,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;hwndParent,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;hMenu,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;hInstance,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NULL);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return (hWndListView);</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">// InsertListViewItems: Inserts items into a list view. </div><div class="code_line">// hWndListView: &nbsp; &nbsp; &nbsp; &nbsp;Handle to the list-view control.</div><div class="code_line">// cItems: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Number of items to insert.</div><div class="code_line">// Returns TRUE if successful, and FALSE otherwise.</div><div class="code_line">BOOL InsertListViewItems(HWND hWndListView, int cItems)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;LVITEM lvI = { 0 };</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Initialize LVITEM members that are common to all items.</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message.</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.mask = LVIF_TEXT | /*LVIF_IMAGE | */ LVIF_STATE;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.stateMask = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.iSubItem = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;lvI.state = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Initialize LVITEM members that are different for each item.</div><div class="code_line">&nbsp;&nbsp; &nbsp;for (int index = 0; index &#60; cItems; index++)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lvI.iItem = index;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lvI.iImage = index;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Insert items into the list.</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int ErrCode = ListView_InsertItem(hWndListView, &amp;lvI);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;assert(ErrCode == 0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//return FALSE;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int NewColWidth = LVSCW_AUTOSIZE;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;BOOL ok_set = ListView_SetColumnWidth(hWndListView, index, NewColWidth);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;assert(ok_set == TRUE);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return TRUE;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">// HandleWM_NOTIFY - Handles the LVN_GETDISPINFO notification code that is </div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp; sent in a WM_NOTIFY to the list view parent window. The function </div><div class="code_line">// &nbsp; &nbsp; &nbsp; &nbsp;provides display strings for list view items and subitems.</div><div class="code_line">//</div><div class="code_line">// lParam - The LPARAM parameter passed with the WM_NOTIFY message.</div><div class="code_line">// rgPetInfo - A global array of structures, defined as follows:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;struct PETINFO</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TCHAR szKind[10];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TCHAR szBreed[50];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TCHAR szPrice[20];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;PETINFO rgPetInfo[ ] = </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{TEXT(&quot;Dog&quot;), &nbsp;TEXT(&quot;Poodle&quot;), &nbsp; &nbsp; TEXT(&quot;0.00&quot;)},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{TEXT(&quot;Cat&quot;), &nbsp;TEXT(&quot;Siamese&quot;), &nbsp; &nbsp;TEXT(&quot;0.00&quot;)},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{TEXT(&quot;Fish&quot;), TEXT(&quot;Angel Fish&quot;), TEXT(&quot;.00&quot;)},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{TEXT(&quot;Bird&quot;), TEXT(&quot;Parakeet&quot;), &nbsp; TEXT(&quot;.00&quot;)},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{TEXT(&quot;Toad&quot;), TEXT(&quot;Woodhouse&quot;), &nbsp;TEXT(&quot;{text}.25&quot;)},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">void HandleWM_NOTIFY(LPARAM lParam)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;NMLVDISPINFO* plvdi;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch (((LPNMHDR)lParam)-&#62;code)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;case LVN_GETDISPINFO:</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;plvdi = (NMLVDISPINFO*)lParam;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;switch (plvdi-&#62;item.iSubItem)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case 0:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plvdi-&#62;item.pszText = rgPetInfo[plvdi-&#62;item.iItem].szKind;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case 1:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plvdi-&#62;item.pszText = rgPetInfo[plvdi-&#62;item.iItem].szBreed;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case 2:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plvdi-&#62;item.pszText = rgPetInfo[plvdi-&#62;item.iItem].szPrice;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;default:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;// NOTE: In addition to setting pszText to point to the item text, you could </div><div class="code_line">&nbsp;&nbsp; &nbsp;// copy the item text into pszText using StringCchCopy. For example:</div><div class="code_line">&nbsp;&nbsp; &nbsp;//</div><div class="code_line">&nbsp;&nbsp; &nbsp;// StringCchCopy(plvdi-&#62;item.pszText, </div><div class="code_line">&nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plvdi-&#62;item.cchTextMax, </div><div class="code_line">&nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rgPetInfo[plvdi-&#62;item.iItem].szKind);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return;</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>Lun2</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      </channel>
      </rss>
	