|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
disable Close button (X)I've seen a large number of posts about this subject, and one answer everyone seems to be happy with is the following: Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams Const CS_NOCLOSE As Integer = &H200 cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE Return cp End Get End Property However I must say, it does NOT work with my environement (Framework 2.0, IDE : VBExpress). What I get is a close button being offset to the right, so it is almost visible but not quite. I'm still able to click on a part of it and close the form. Am I the only one in this situation ? Thanks Using VS2005 and .NET 2.0, I disable the close button (Control Box)
with: MyForm.ControlBox = False Thanks for the reply. However I do not want to use this property, as I
want to keep the maximise and minimise button. Sorry I should have mention this in my first post.
Show quote
Hide quote
"Sam" <samuelberthe***@googlemail.com> schrieb: The code works just fine on .NET 2.0, VS 2005 Professional, Windows XP SP2, > I've seen a large number of posts about this subject, and one answer > everyone seems to be happy with is the following: > > Protected Overrides ReadOnly Property CreateParams() As CreateParams > Get > Dim cp As CreateParams = MyBase.CreateParams > Const CS_NOCLOSE As Integer = &H200 > cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE > Return cp > End Get > End Property > > However I must say, it does NOT work with my environement (Framework > 2.0, IDE : VBExpress). Visual Styles enabled. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
I believe you, but I swear, in my case, it does not work ;) see the picture: http://graphicsxp.free.fr/formclose.JPG I can still highlight the close button at the very right of the child form and click on it. Can you help ? "Sam" <samuelberthe***@googlemail.com> schrieb: Well, you forgot to say that you are talking about an MDI child form. > I believe you, but I swear, in my case, it does not work ;) > see the picture: Sorry, I do not know a solution for the problem. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Sam wrote:
> Sorry I forgot to mention that indeed :( I did this in VB6 using some API calls. The VB.NET equivalent is as follows:> anyone knows? \\\ Private Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" _ (ByVal hMenu As Integer, ByVal nPosition As Integer, _ ByVal wFlags As Integer, ByVal wIDNewItem As Integer, _ ByVal lpString As String) As Integer Private Declare Function GetMenuItemID Lib "user32" _ (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer Private Const MF_GRAYED As Integer = &H1 Private Const MF_BYCOMMAND As Integer = &H0 [...] Private Sub MDIChildForm_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Load 'Disable the Close button on load Dim hMenu As Integer Dim hItem As Integer hMenu = GetSystemMenu(Me.Handle.ToInt32, 0) hItem = GetMenuItemID(hMenu, 6) ModifyMenu(hMenu, hItem, MF_BYCOMMAND Or MF_GRAYED, -9, "&Close") End Sub /// There may be a better way to do this, but if so, I don't know what it is. -- (O)enone thanks but i must be damned... :(
it gives me the exact same behaviour as described above with the link to my screenshot... I really don't know why I get this.
AMD/Dual-Core/64 bit: influence on compiled files? - Clients?
Can I hide base class properties in a derived class? Application doesn't close on Shut Down - Please help! change IFRAME src Using pulldownlist in datagridview .. can it be done! Inserting text at the beginning of an existing text file .NET 2.0 question ? Update error Intern Strings - am I using them right? Please help! Marking a changed row |
|||||||||||||||||||||||