Disable close, minimize and maximize buttons on console application?<p align=left><font face=Arial size=2></font> </p> <p>Hi all!</p> <p align=left> </p> <p align=left>I´ve been looking for a way to disable the close, minimize and maximize button on any console application for some time now. A couple of days ago, I found the code to disable the close button in a MS KB-article (<a title="http://support.microsoft.com/kb/818361" href="http://support.microsoft.com/kb/818361">http://support.microsoft.com/kb/818361</a>)</p> <p align=left> </p> <p align=left>I modified the code somewhat so that the program accepts a command line argument, giving me the opportunity to disable the close button for any application currently running.</p> <p align=left> </p> <p align=left>The problem is that this code doesn´t work for disabling minimize and maximize buttons. </p> <p align=left>Sure, I can make the minimize/maximize options in the right-click context menu disappear for any application by doing </p> <p align=left> </p> <p align=left>DeleteMenu(hMenu, 6, 1024)</p> <p align=left>DeleteMenu(hMenu, 5, 1024)</p> <p align=left>DeleteMenu(hMenu, 4, 1024)</p> <p align=left>DeleteMenu(hMenu, 3, 1024)</p> <p align=left> </p> <p align=left>or putting the function inside a loop, but that still leaves the top-right window buttons activated.</p> <p align=left> </p> <p align=left>I´ve found a couple of suggestions on how to disable the top-right buttons aswell, but none of them seems to work for windows 2000/windows xp. </p> <p align=left> </p> <p align=left>Anyone know how to disable the minimize/maximize buttons for win200/winxp?</p> <p align=left> </p> <p align=left>Cheers</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Za28740c5-bd1f-4a93-a9e9-216b54e610b2http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a28740c5-bd1f-4a93-a9e9-216b54e610b2#a28740c5-bd1f-4a93-a9e9-216b54e610b2http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a28740c5-bd1f-4a93-a9e9-216b54e610b2#a28740c5-bd1f-4a93-a9e9-216b54e610b2Dallastowerhttp://social.msdn.microsoft.com/Profile/en-US/?user=DallastowerDisable close, minimize and maximize buttons on console application?<p align=left><font face=Arial size=2></font> </p> <p>Hi all!</p> <p align=left> </p> <p align=left>I´ve been looking for a way to disable the close, minimize and maximize button on any console application for some time now. A couple of days ago, I found the code to disable the close button in a MS KB-article (<a title="http://support.microsoft.com/kb/818361" href="http://support.microsoft.com/kb/818361">http://support.microsoft.com/kb/818361</a>)</p> <p align=left> </p> <p align=left>I modified the code somewhat so that the program accepts a command line argument, giving me the opportunity to disable the close button for any application currently running.</p> <p align=left> </p> <p align=left>The problem is that this code doesn´t work for disabling minimize and maximize buttons. </p> <p align=left>Sure, I can make the minimize/maximize options in the right-click context menu disappear for any application by doing </p> <p align=left> </p> <p align=left>DeleteMenu(hMenu, 6, 1024)</p> <p align=left>DeleteMenu(hMenu, 5, 1024)</p> <p align=left>DeleteMenu(hMenu, 4, 1024)</p> <p align=left>DeleteMenu(hMenu, 3, 1024)</p> <p align=left> </p> <p align=left>or putting the function inside a loop, but that still leaves the top-right window buttons activated.</p> <p align=left> </p> <p align=left>I´ve found a couple of suggestions on how to disable the top-right buttons aswell, but none of them seems to work for windows 2000/windows xp. </p> <p align=left> </p> <p align=left>Anyone know how to disable the minimize/maximize buttons for win200/winxp?</p> <p align=left> </p> <p align=left>Cheers</p>Fri, 07 Mar 2008 09:15:39 Z2008-03-11T18:49:34Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a28740c5-bd1f-4a93-a9e9-216b54e610b2#24169201-7c84-4dac-a52a-f0eb55bf6621http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a28740c5-bd1f-4a93-a9e9-216b54e610b2#24169201-7c84-4dac-a52a-f0eb55bf6621Bruno Yuhttp://social.msdn.microsoft.com/Profile/en-US/?user=Bruno%20YuDisable close, minimize and maximize buttons on console application?<p align=left><font face=Verdana>Dallastower,</font></p> <p align=left><font face=Verdana></font> </p> <p align=left><font face=Verdana>Based on your post, the KB 818361 uses PInvoke to call the related functions such as DeleteMenu, GetForegroundWindow, GetSystemMenu in user32.dll to disable the &quot;Close&quot; button of console application. </font></p> <p align=left><font face=Verdana></font> </p> <p align=left><font face=Verdana>I would like to provide you the following code snippet to disable the Maximize and Minimize button from this thread: <a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=789984&amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=789984&amp;SiteID=1">How do you disable Minimize, Maximize, Close buttons + remove app icon on a WPF window</a></font></p> <p align=left><font face=Verdana></font> </p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style=""> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span>&lt;DllImport(</span><span lang=EN-US style="font-size:10pt;color:#a31515;font-family:'Verdana','sans-serif'">&quot;user32.dll&quot;</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">)&gt; _</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Private</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Shared</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Function</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> SetWindowLong(</span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">ByVal</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> hWnd </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> IntPtr, </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">ByVal</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> nIndex </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Integer</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">, </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">ByVal</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> dwNewLong </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Integer</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">) </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Integer</span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">End</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Function</span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'"> </span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span>&lt;DllImport(</span><span lang=EN-US style="font-size:10pt;color:#a31515;font-family:'Verdana','sans-serif'">&quot;user32.dll&quot;</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">)&gt; _</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">     </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Private</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Shared</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Function</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> GetWindowLong(</span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">ByVal</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> hWnd </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> IntPtr, </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">ByVal</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> nIndex </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Integer</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">) </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Integer</span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">End</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Function</span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'"> </span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Private</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Const</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> GWL_STYLE </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Integer</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> = (-16)</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Private</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Sub</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> RemoveControlBoxes()</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">        </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Dim</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> hwnd </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> IntPtr = </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">New</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> Interop.WindowInteropHelper(</span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Me</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">).Handle</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">        </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Dim</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> windowLong </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">As</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Long</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> = GetWindowLong(hwnd, GWL_STYLE)</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">        </span>windowLong = windowLong </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">And</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> -131073 </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">And</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> -65537</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt;text-align:left" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">        </span>SetWindowLong(hwnd, GWL_STYLE, </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">CInt</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'">(windowLong))</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"></span></p> <p class=MsoNormal style="margin:0cm 0cm 0pt" align=left><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"><span style="">    </span></span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">End</span><span lang=EN-US style="font-size:10pt;font-family:'Verdana','sans-serif'"> </span><span lang=EN-US style="font-size:10pt;color:blue;font-family:'Verdana','sans-serif'">Sub</span></p> <p align=left> </p></div></div> <p align=left> </p></span></span> <p></p> <p align=left><font face=Verdana>The Interop.<a title="http://msdn2.microsoft.com/en-us/library/system.windows.interop.windowinterophelper.aspx" href="http://msdn2.microsoft.com/en-us/library/system.windows.interop.windowinterophelper.aspx">WindowInteropHelper </a>assists interoperation between Windows Presentation Foundation (WPF) and Win32 code and can only be applied on .NET Framework 3.0/3.5. </font></p> <p align=left><font face=Verdana></font> </p> <p align=left><font face=Verdana>In addition, please read the article <a title="http://support.microsoft.com/kb/130760" href="http://support.microsoft.com/kb/130760">PRB: Cannot Remove Minimize or Maximize Button from Caption Bar</a></font></p> <p align=left><font face=Verdana></font> </p> <p align=left><font face=Verdana>Under Windows 95, Windows 98, and Windows NT version 4.0 and later, applications can create a window (overlapped or popup) with just the Close button (the X button) by creating the window without specifying the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. Calling SetWindowLong(GWL_STYLE) to change or remove the minimize of the maxmize buttons dynamically still displays both buttons with one of them disabled. </font></p> <p align=left><font face=Verdana></font> </p> <p align=left><font face=Verdana>Hope that can help you to understand the disable issue.</font></p>Tue, 11 Mar 2008 05:53:55 Z2008-03-11T18:49:34Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a28740c5-bd1f-4a93-a9e9-216b54e610b2#682858e7-dd24-469c-933c-2edc726b3ef2http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/a28740c5-bd1f-4a93-a9e9-216b54e610b2#682858e7-dd24-469c-933c-2edc726b3ef2Dallastowerhttp://social.msdn.microsoft.com/Profile/en-US/?user=DallastowerDisable close, minimize and maximize buttons on console application?<p align=left><font face=Arial size=2>Bruno,</font></p> <p align=left> </p> <p align=left>Thanks for your reply.</p> <p align=left> </p> <p align=left>I acutally found a code snippet that is similar to your example:</p> <p align=left> </p><font size=2> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div><font size=2> <p align=left>&lt;DllImport(</font><font color="#a31515" size=2>&quot;user32.dll&quot;</font><font size=2>)&gt; _</p> <p align=left></font><font color="#0000ff" size=2>Public</font><font size=2> </font><font color="#0000ff" size=2>Shared</font><font size=2> </font><font color="#0000ff" size=2>Function</font><font size=2> GetWindowLong(</font><font color="#0000ff" size=2>ByVal</font><font size=2> hWnd </font><font color="#0000ff" size=2>As</font><font size=2> IntPtr, </font><font color="#0000ff" size=2>ByVal</font><font size=2> nIndex </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>) </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>End</font><font size=2> </font><font color="#0000ff" size=2>Function</p> <p align=left> </p> <p align=left></font><font size=2>&lt;DllImport(</font><font color="#a31515" size=2>&quot;user32.dll&quot;</font><font size=2>)&gt; _</p> <p align=left></font><font color="#0000ff" size=2>Public</font><font size=2> </font><font color="#0000ff" size=2>Shared</font><font size=2> </font><font color="#0000ff" size=2>Function</font><font size=2> SetWindowLong(</font><font color="#0000ff" size=2>ByVal</font><font size=2> hWnd </font><font color="#0000ff" size=2>As</font><font size=2> IntPtr, </font><font color="#0000ff" size=2>ByVal</font><font size=2> nIndex </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>, </font><font color="#0000ff" size=2>ByVal</font><font size=2> dwNewLong </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>) </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>End</font><font size=2> </font><font color="#0000ff" size=2>Function</p> <p align=left></font><font size=2> </p></font> <p align=left><font size=2>&lt;DllImport(</font><font color="#a31515" size=2>&quot;user32.dll&quot;</font><font size=2>)&gt; _</p> <p align=left></font><font color="#0000ff" size=2>Private</font><font size=2> </font><font color="#0000ff" size=2>Shared</font><font size=2> </font><font color="#0000ff" size=2>Function</font><font size=2> SetWindowPos(</font><font color="#0000ff" size=2>ByVal</font><font size=2> hWnd </font><font color="#0000ff" size=2>As</font><font size=2> IntPtr, </font><font color="#0000ff" size=2>ByVal</font><font size=2> hWndInsertAfter </font><font color="#0000ff" size=2>As</font><font size=2> IntPtr, </font><font color="#0000ff" size=2>ByVal</font><font size=2> X </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>, </font><font color="#0000ff" size=2>ByVal</font><font size=2> Y </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>, </font><font color="#0000ff" size=2>ByVal</font><font size=2> cx </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>, </font><font color="#0000ff" size=2>ByVal</font><font size=2> cy </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2>, _</p> <p align=left></font><font color="#0000ff" size=2>ByVal</font><font size=2> uFlags </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>UInteger</font><font size=2>) </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Boolean</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>End</font><font size=2> </font><font color="#0000ff" size=2>Function</font></p> <p align=left><font color="#0000ff"></font> </p><font size=2> <p align=left></font><font color="#0000ff" size=2>Const</font><font size=2> GWL_STYLE </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2> = -16</p> <p align=left></font><font color="#0000ff" size=2>Const</font><font size=2> WS_SYSMENU </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2> = 524288</p> <p align=left> </p><font size=2><font color="#0000ff" size=2> <p align=left>Public</font><font size=2> </font><font color="#0000ff" size=2>Shared</font><font size=2> </font><font color="#0000ff" size=2>Sub</font><font size=2> Main(</font><font color="#0000ff" size=2>ByVal</font><font size=2> args </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>String</font><font size=2>())</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left><font color="#0000ff" size=2><font color="#008000" size=2>' Ommited code for ObtainWindowHandle to same space</p></blockquote> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font>Dim</font><font size=2> hWnd </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2> = ObtainWindowHandle(args(0))</p></blockquote> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>Dim</font><font size=2> style </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>Integer</font><font size=2> = GetWindowLong(hWnd, GWL_STYLE)</p> <p align=left>SetWindowLong(hWnd, GWL_STYLE, (style </font><font color="#0000ff" size=2>And</font><font size=2> </font><font color="#0000ff" size=2>Not</font><font size=2> WS_SYSMENU))</font></p> <p align=left><font size=2>SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, 55)</font></p></blockquote></font></font></font> <p align=left></p><font size=2> <p align=left></font><font color="#0000ff" size=2>End</font><font size=2> </font><font color="#0000ff" size=2>Sub</font></p> <p align=left> </p></div></div> <p align=left> </p></font> <p></p> <p align=left><font color="#0000ff" size=2></p> <p><font color="#000000">This code removes the entire controlbox, that is minimize, maximize/restore and close for the application specified as argument. I tried it and it works fine with some applications, like windows calculator. However it does not for for the specific application that I need to disable the controlbox for...</font></p> <p align=left><font color="#000000"></font> </p> <p align=left><font color="#000000">I´m guessing it has something to do with the fact that the Calculator application is win 32 and I´m pretty sure that my target application is win 16 (it´s run in a command line window).</font></font></p>Tue, 11 Mar 2008 18:42:41 Z2008-03-11T18:42:41Z