Манипуляции с заголовком формы Delphi — среда быстрой разработки, где в качестве языка программирования используется Object Pascal. На сегодняшний день позволяет разрабатывать ПО для Microsoft Windows, Mac OS, iOS и Android и входит в состав Embarcadero RAD Studio https://delphi-hlp.ru/index.php/tform/manipulyatsii-s-zagolovkom-formy.feed 2022-09-13T04:47:38+07:00 Delphi help info@delphi-hlp.ru Joomla! - Open Source Content Management Добавляем дополнительную кнопку в заголовок формы 2017-08-10T16:43:07+07:00 2017-08-10T16:43:07+07:00 https://delphi-hlp.ru/index.php/tform/manipulyatsii-s-zagolovkom-formy/dobavlyaem-dopolnitelnuyu-knopku-v-zagolovok-formy.html Super User toto44@inbox.ru <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Автор: Vimil Saju </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Чтобы добавить дополнительную кнопку, нам прийдётся создать обработчики для следующих событий: </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCPAINT;//вызывается, когда перерисовывается не клиентская область формы </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCACTIVATE; вызывается, когда заголовок формы становится активныи </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCLBUTTONDOWN; вызывается, когда кнопка мыши нажимается на не клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCMOUSEMOVE; вызывается, когда курсор мыши передвигается по не клиентской области</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_MOUSEMOVE;вызывается, когда курсор мыши передвигается по клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_LBUTTONUP; вызывается, когда кнопка мыши отпушена в клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCLBUTTONUP; вызывается, когда кнопка мыши отпушена в не клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCLBUTTONDBLCLK; вызывается при двойном щелчке мышкой в не клиентской области </span></p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/dobavlyaem-dopolnitelnuyu-knopku-v-zagolovok-formy.html">Подробнее...</a></p> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Автор: Vimil Saju </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Чтобы добавить дополнительную кнопку, нам прийдётся создать обработчики для следующих событий: </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCPAINT;//вызывается, когда перерисовывается не клиентская область формы </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCACTIVATE; вызывается, когда заголовок формы становится активныи </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCLBUTTONDOWN; вызывается, когда кнопка мыши нажимается на не клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCMOUSEMOVE; вызывается, когда курсор мыши передвигается по не клиентской области</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_MOUSEMOVE;вызывается, когда курсор мыши передвигается по клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_LBUTTONUP; вызывается, когда кнопка мыши отпушена в клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCLBUTTONUP; вызывается, когда кнопка мыши отпушена в не клиентской области </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NCLBUTTONDBLCLK; вызывается при двойном щелчке мышкой в не клиентской области </span></p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/dobavlyaem-dopolnitelnuyu-knopku-v-zagolovok-formy.html">Подробнее...</a></p> Изменяем заголовок окна 2017-08-10T16:39:11+07:00 2017-08-10T16:39:11+07:00 https://delphi-hlp.ru/index.php/tform/manipulyatsii-s-zagolovkom-formy/izmenyaem-zagolovok-okna.html Super User toto44@inbox.ru <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Автор: Christian Cristofori</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">В примере показывается, как изменять заголовок окна (видимый в списке задач при переключении между приложениями) при минимизации окна в иконку.</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Сперва необходимо определить сообщение поумолчанию: </span></p> <div style="margin: 7px 0px; padding: 0px; text-align: justify; text-indent: 0px;"> <table style="border-width: 1px; border-style: solid; border-color: #000000 #c0c0c0 #c0c0c0 #000000; border-spacing: 0px; background-color: #ffffc4;" border="1" cellspacing="0" cellpadding="5" bgcolor="#ffffc4"> <tbody> <tr align="left" valign="top"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p style="text-align: justify;"><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">Code:</span></p> </td> </tr> <tr align="left"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">Const</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;"> DefMsgNorm = </span><span class="f_CodeExample" style="color: #ff0000;">'MyApp version 1.0'</span><span class="f_CodeExample" style="color: #000000;">; </span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;"> DefMsgIcon = </span><span class="f_CodeExample" style="color: #ff0000;">'MyApp. (Use F12 to turn of)'</span><span class="f_CodeExample" style="color: #000000;">; </span></span></p> </td> </tr> </tbody> </table> </div> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> <span style="color: #000000;"> </span></span></p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/izmenyaem-zagolovok-okna.html">Подробнее...</a></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Автор: Christian Cristofori</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">В примере показывается, как изменять заголовок окна (видимый в списке задач при переключении между приложениями) при минимизации окна в иконку.</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Сперва необходимо определить сообщение поумолчанию: </span></p> <div style="margin: 7px 0px; padding: 0px; text-align: justify; text-indent: 0px;"> <table style="border-width: 1px; border-style: solid; border-color: #000000 #c0c0c0 #c0c0c0 #000000; border-spacing: 0px; background-color: #ffffc4;" border="1" cellspacing="0" cellpadding="5" bgcolor="#ffffc4"> <tbody> <tr align="left" valign="top"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p style="text-align: justify;"><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">Code:</span></p> </td> </tr> <tr align="left"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">Const</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;"> DefMsgNorm = </span><span class="f_CodeExample" style="color: #ff0000;">'MyApp version 1.0'</span><span class="f_CodeExample" style="color: #000000;">; </span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;"> DefMsgIcon = </span><span class="f_CodeExample" style="color: #ff0000;">'MyApp. (Use F12 to turn of)'</span><span class="f_CodeExample" style="color: #000000;">; </span></span></p> </td> </tr> </tbody> </table> </div> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> <span style="color: #000000;"> </span></span></p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/izmenyaem-zagolovok-okna.html">Подробнее...</a></p> Как изменить шрифт и выравнивание в заголовке формы? 2017-08-10T16:46:29+07:00 2017-08-10T16:46:29+07:00 https://delphi-hlp.ru/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-izmenit-shrift-i-vyravnivanie-v-zagolovke-formy.html Super User toto44@inbox.ru <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Note: The formDeactivate never gets called so when the form isn't active, sometimes the FormPaint isn't called. If anything causes the form to be repainted while in inactive, it draws correctly.</span></p> <p>Примечание: formDeactivate никогда не вызывается, когда форма не активна, иногда FormPaint не называется. Если что-то вызывает форму, чтобы быть перекрашены в то время как в неактивном, он правильно рисует.</p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-izmenit-shrift-i-vyravnivanie-v-zagolovke-formy.html">Подробнее...</a></p> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Note: The formDeactivate never gets called so when the form isn't active, sometimes the FormPaint isn't called. If anything causes the form to be repainted while in inactive, it draws correctly.</span></p> <p>Примечание: formDeactivate никогда не вызывается, когда форма не активна, иногда FormPaint не называется. Если что-то вызывает форму, чтобы быть перекрашены в то время как в неактивном, он правильно рисует.</p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-izmenit-shrift-i-vyravnivanie-v-zagolovke-formy.html">Подробнее...</a></p> Как перехватить события в неклиентской области формы? 2017-08-10T16:44:27+07:00 2017-08-10T16:44:27+07:00 https://delphi-hlp.ru/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-perekhvatit-sobytiya-v-neklientskoj-oblasti-formy.html Super User toto44@inbox.ru <p><span style="font-family: 'MS Sans Serif'; font-size: 8pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Создайте обработчик одного из сообщений WM_NC (non client - не клиентских) (посмотрите</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NC в Windows API help). Пример показывает как перехватить вижение мыши во всей</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">неклиенстской области окна (рамка и заголовок).</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-perekhvatit-sobytiya-v-neklientskoj-oblasti-formy.html">Подробнее...</a></p> <p><span style="font-family: 'MS Sans Serif'; font-size: 8pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Создайте обработчик одного из сообщений WM_NC (non client - не клиентских) (посмотрите</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">WM_NC в Windows API help). Пример показывает как перехватить вижение мыши во всей</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">неклиенстской области окна (рамка и заголовок).</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p class="feed-readmore"><a target="_blank" href ="/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-perekhvatit-sobytiya-v-neklientskoj-oblasti-formy.html">Подробнее...</a></p> Как скрыть кнопку [х] в заголовке окна? 2017-08-10T16:38:06+07:00 2017-08-10T16:38:06+07:00 https://delphi-hlp.ru/index.php/tform/manipulyatsii-s-zagolovkom-formy/kak-skryt-knopku-kh-v-zagolovke-okna.html Super User toto44@inbox.ru <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Автор: Fernando Silva</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Пример показывает, как при инициализации формы происходит поиск нашего окна, а затем вычисление местоположения нужной нам кнопки в заголовке окна.</span></p> <div style="margin: 7px 0px; padding: 0px; text-align: justify; text-indent: 0px;"> <table style="border-width: 1px; border-style: solid; border-color: #000000 #c0c0c0 #c0c0c0 #000000; border-spacing: 0px; background-color: #ffffc4;" border="1" cellspacing="0" cellpadding="5" bgcolor="#ffffc4"> <tbody> <tr align="left" valign="top"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p style="text-align: justify;"><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">Code:</span></p> </td> </tr> <tr align="left"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">procedure</span><span class="f_CodeExample" style="color: #000000;"> TForm1.FormCreate(Sender: TObject);</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">var</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> hwndHandle: THANDLE;</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> hMenuHandle: HMENU;</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> iPos: Integer;</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">begin</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;"> hwndHandle := FindWindow(</span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">nil</span><span class="f_CodeExample" style="color: #000000;">, PChar(Caption));</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">if</span><span class="f_CodeExample" style="color: #000000;"> (hwndHandle &lt;&gt; </span><span class="f_CodeExample" style="color: #800000;">0</span><span class="f_CodeExample" style="color: #000000;">) </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">then</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">begin</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">    hMenuHandle := GetSystemMenu(hwndHandle, FALSE);</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">    </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">if</span><span class="f_CodeExample" style="color: #000000;"> (hMenuHandle &lt;&gt; </span><span class="f_CodeExample" style="color: #800000;">0</span><span class="f_CodeExample" style="color: #000000;">) </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">then</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">    </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">begin</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">      DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND);</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">      iPos := GetMenuItemCount(hMenuHandle);</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">      Dec(iPos);</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">        </span><span class="f_CodeExample" style="color: #000080;">{ Надо быть уверенным, что нет ошибки т.к. -1 указывает на ошибку }</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">      </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">if</span><span class="f_CodeExample" style="color: #000000;"> iPos &gt; -</span><span class="f_CodeExample" style="color: #800000;">1</span> <span class="f_CodeExample" style="color: #008000; font-weight: bold;">then</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">        DeleteMenu(hMenuHandle, iPos, MF_BYPOSITION);</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">    </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">end</span><span class="f_CodeExample" style="color: #000000;">;</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">end</span><span class="f_CodeExample" style="color: #000000;">;</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">end</span><span class="f_CodeExample" style="color: #000000;">;</span></span></p> </td> </tr> </tbody> </table> </div> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Автор: Fernando Silva</span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">Пример показывает, как при инициализации формы происходит поиск нашего окна, а затем вычисление местоположения нужной нам кнопки в заголовке окна.</span></p> <div style="margin: 7px 0px; padding: 0px; text-align: justify; text-indent: 0px;"> <table style="border-width: 1px; border-style: solid; border-color: #000000 #c0c0c0 #c0c0c0 #000000; border-spacing: 0px; background-color: #ffffc4;" border="1" cellspacing="0" cellpadding="5" bgcolor="#ffffc4"> <tbody> <tr align="left" valign="top"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p style="text-align: justify;"><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">Code:</span></p> </td> </tr> <tr align="left"> <td style="border-width: 1px; border-style: solid; border-color: #c0c0c0 #000000 #000000 #c0c0c0;"> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">procedure</span><span class="f_CodeExample" style="color: #000000;"> TForm1.FormCreate(Sender: TObject);</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">var</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> hwndHandle: THANDLE;</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> hMenuHandle: HMENU;</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> iPos: Integer;</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">begin</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;"> hwndHandle := FindWindow(</span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">nil</span><span class="f_CodeExample" style="color: #000000;">, PChar(Caption));</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">if</span><span class="f_CodeExample" style="color: #000000;"> (hwndHandle &lt;&gt; </span><span class="f_CodeExample" style="color: #800000;">0</span><span class="f_CodeExample" style="color: #000000;">) </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">then</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #008000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold;">begin</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">    hMenuHandle := GetSystemMenu(hwndHandle, FALSE);</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">    </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">if</span><span class="f_CodeExample" style="color: #000000;"> (hMenuHandle &lt;&gt; </span><span class="f_CodeExample" style="color: #800000;">0</span><span class="f_CodeExample" style="color: #000000;">) </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">then</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">    </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">begin</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">      DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND);</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">      iPos := GetMenuItemCount(hMenuHandle);</span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">      Dec(iPos);</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">        </span><span class="f_CodeExample" style="color: #000080;">{ Надо быть уверенным, что нет ошибки т.к. -1 указывает на ошибку }</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">      </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">if</span><span class="f_CodeExample" style="color: #000000;"> iPos &gt; -</span><span class="f_CodeExample" style="color: #800000;">1</span> <span class="f_CodeExample" style="color: #008000; font-weight: bold;">then</span></span></p> <p class="p_CodeExample"><span class="f_CodeExample" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;">        DeleteMenu(hMenuHandle, iPos, MF_BYPOSITION);</span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #000000;">    </span><span class="f_CodeExample" style="color: #008000; font-weight: bold;">end</span><span class="f_CodeExample" style="color: #000000;">;</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">end</span><span class="f_CodeExample" style="color: #000000;">;</span></span></p> <p class="p_CodeExample"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"><span class="f_CodeExample" style="color: #008000; font-weight: bold;">end</span><span class="f_CodeExample" style="color: #000000;">;</span></span></p> </td> </tr> </tbody> </table> </div> <p><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p> <p><span style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt;"> </span></p>