Page 2 of 2 FirstFirst 12
Results 41 to 59 of 59

Thread: Disable Close Button and Prevent Form Being Moved

  1. #41

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by Simply Me
    Hi jm!

    Your work is great it helps me alot and I implemented it in my apps.

    I have a main form (not MDI) a treeview menu when user clicked a certain menu it opens another form on top of the main form. Whenever i click the icon of the form found in the start bar the form will minimized but when I click it again I was expecting that it would display it back but it is not restoring. I even tried right click then maximize or restore and its not working. Is it possible that whenever I click the icon in the start bar it will not minimize?
    Are you saying that your second form is using my FormImmobiliser class and it won't restore after being minimised?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  2. #42
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Disable Close Button and Prevent Form Being Moved

    Yes. My second form uses your FormImmobiliser class. My second form BorderStyle is FixedToolWindow. Whenever I click the form's name in the task bar it automatically minimizes and when I right click and choose restore or maximize it is not restoring.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  3. #43

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by Simply Me
    Yes. My second form uses your FormImmobiliser class. My second form BorderStyle is FixedToolWindow. Whenever I click the form's name in the task bar it automatically minimizes and when I right click and choose restore or maximize it is not restoring.
    I've changed the code for the FormImmobiliser class. Download the new version from post #1 and see if that addresses the issue.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #44
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Disable Close Button and Prevent Form Being Moved

    Great it works now!

    Thanks!
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  5. #45
    Hyperactive Member Always_Confused's Avatar
    Join Date
    Jun 2006
    Location
    Alabama USA
    Posts
    417

    Re: Disable Close Button and Prevent Form Being Moved

    Hi JM

    I am using both of your classes after loading a form (frmSixQs) from a child form (frmProfiles). All runs as expected, except when I click off the form (frmSixQs), it closes.

    How do I make my form focused exclusively until the user closes it intentionally?
    If you find information helpful from any member, please take a second and rate their post. Its a nice gesture of your appreciation.

    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison

    Do illiterate people get the full effect of Alphabet Soup?

    ADO FAQ 2005-2008 Masked Textbox Patch FoxPro Date MZ Tools Great Free Tool

  6. #46

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by Always_Confused
    Hi JM

    I am using both of your classes after loading a form (frmSixQs) from a child form (frmProfiles). All runs as expected, except when I click off the form (frmSixQs), it closes.

    How do I make my form focused exclusively until the user closes it intentionally?
    That doesn't sound like anything that would be caused by my code but I'll run some tests just to make sure.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #47

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by Always_Confused
    Hi JM

    I am using both of your classes after loading a form (frmSixQs) from a child form (frmProfiles). All runs as expected, except when I click off the form (frmSixQs), it closes.

    How do I make my form focused exclusively until the user closes it intentionally?
    I tested my classes with all combinations of Show and ShowDialog with 1, 2 and 3 forms and saw no such behaviour, so I can only assume that it's something to do with your own code. What happens if you remove my classes? Do you still see that behaviour?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #48
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Disable Close Button and Prevent Form Being Moved

    The SystemMenuManager class doesn't seem to have any effect on the close button of a FixedToolWindow form. Problem encountered in Windows Vista SP1. I tried setting the SMM both to disable and to remove the close button, with absolutely no effect whatsoever. Here's the declaration:

    Code:
    Private smm As New SystemMenuManager(Me, SystemMenuManager.MenuItemState.Removed)
    For now, I've set the ControlBox property to False, however I'd also like to block the Alt + F4 key combination, which seems to work, albeit erratically. I will explore the problem further and attempt to narrow down the source of the problem. I'll keep you posted as best I can, given my poor internet connection.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  9. #49

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by obi1kenobi
    The SystemMenuManager class doesn't seem to have any effect on the close button of a FixedToolWindow form. Problem encountered in Windows Vista SP1. I tried setting the SMM both to disable and to remove the close button, with absolutely no effect whatsoever. Here's the declaration:

    Code:
    Private smm As New SystemMenuManager(Me, SystemMenuManager.MenuItemState.Removed)
    For now, I've set the ControlBox property to False, however I'd also like to block the Alt + F4 key combination, which seems to work, albeit erratically. I will explore the problem further and attempt to narrow down the source of the problem. I'll keep you posted as best I can, given my poor internet connection.
    I probably never tested that scenario. I'll have a look myself too, when I get the chance. Out of town visiting my dad for this Australia Day long weekend. Submitting this using his brand new Internet connection.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #50
    Lively Member
    Join Date
    Nov 2009
    Posts
    76

    Re: Disable Close Button and Prevent Form Being Moved

    What Is the value of the Size menu Item? I would like to disable form sizing but, I need to have it have a sizable border style? I hope I didn't pass over it while scanning the forum. I have tried Googleing it but, that results in "Set the border style to something with Fixed in it."

    Thanks!
    E

  11. #51
    New Member
    Join Date
    Oct 2010
    Posts
    14

    Unhappy Re: Disable Close Button and Prevent Form Being Moved

    Hi,

    I was using your formImmobiliser.vb class only since i use vb .net 2005.
    Then i declared Dim frmMove As New FormImmobilisre(Me) in 'declarations' region. That's it?
    but it doen't work properly. where to declare dim statement and anything else to do?
    form will move only upwards (no left, right, down).
    can you give code sample how to use your class?

  12. #52
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by obi1kenobi View Post
    The SystemMenuManager class doesn't seem to have any effect on the close button of a FixedToolWindow form. Problem encountered in Windows Vista SP1. I tried setting the SMM both to disable and to remove the close button, with absolutely no effect whatsoever. Here's the declaration:

    Code:
    Private smm As New SystemMenuManager(Me, SystemMenuManager.MenuItemState.Removed)
    For now, I've set the ControlBox property to False, however I'd also like to block the Alt + F4 key combination, which seems to work, albeit erratically. I will explore the problem further and attempt to narrow down the source of the problem. I'll keep you posted as best I can, given my poor internet connection.
    I'm having the same trouble on Windows XP. Everything works great! Thank you very much! I'll take a look at things and report if I find anything to make it work with fixed tool windows.

    VBNetDude - Thinking Programmatically
    By Silver Seal Software

    Don't forget to mark your thread as "Resolved" using the Thread Tools menu on top. And don't forget to rate the answers that help you the most!

  13. #53
    Addicted Member
    Join Date
    Nov 2010
    Location
    TamilNadu, India
    Posts
    249

    Re: Disable Close Button and Prevent Form Being Moved

    Code:
    myMenuManager = New SystemMenuManager(_handle, True, SystemMenuManager.MenuItemState.Enabled)
    oh my god i can't enabled my close button

  14. #54

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by medsont View Post
    Code:
    myMenuManager = New SystemMenuManager(_handle, True, SystemMenuManager.MenuItemState.Enabled)
    oh my god i can't enabled my close button
    Um, huh? The Close button is enabled by default, so you don't have to do anything to enable it. The whole point of this thread is to disable it. Are you saying, without actually saying, that you have already disabled it and then you want to re-enable it at some point?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  15. #55
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Disable Close Button and Prevent Form Being Moved

    Sounds like its being disabled but they are not able to re-enable it. Since its probably a coding issue not directly related I would suggest posting a new thread in the VB.NET forum and link/reference this codebank thread so all can assist you better.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #56
    Addicted Member
    Join Date
    Nov 2010
    Location
    TamilNadu, India
    Posts
    249

    Re: Disable Close Button and Prevent Form Being Moved

    ok Thank you Mr.SuperModerator.....

  17. #57
    New Member
    Join Date
    Sep 2014
    Posts
    2

    Re: Disable Close Button and Prevent Form Being Moved

    Hi, I know this is an old thread but I was hoping someone could help me. I am using the Form Immobilizer and it is working great. What I would like to know is if it is possible to enable/disable the feature during run time or by changing a setting in an ini file?

    Thanks

  18. #58

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close Button and Prevent Form Being Moved

    Quote Originally Posted by Zaxxan View Post
    Hi, I know this is an old thread but I was hoping someone could help me. I am using the Form Immobilizer and it is working great. What I would like to know is if it is possible to enable/disable the feature during run time or by changing a setting in an ini file?

    Thanks
    This is the part that actually stops the form moving:
    Code:
    Protected Overrides Sub WndProc(ByRef m As Message)
        If m.Msg = WM_MOVING Then
            Marshal.StructureToPtr(New RECT(Me.target.Bounds), _
                                   m.LParam, _
                                   False)
            m.Result = New IntPtr([TRUE])
        End If
    
        MyBase.WndProc(m)
    End Sub
    If you want to allow the form to move then all you need to do is not execute that bit of code. It's already in an If block so all you have to do is add a flag to that If statement that can be set from outside, e.g.
    vb.net Code:
    1. Public Property CanMove As Boolean
    2.  
    3. Protected Overrides Sub WndProc(ByRef m As Message)
    4.     If Not CanMove AndAlso m.Msg = WM_MOVING Then
    5.         Marshal.StructureToPtr(New RECT(Me.target.Bounds), _
    6.                                m.LParam, _
    7.                                False)
    8.         m.Result = New IntPtr([TRUE])
    9.     End If
    10.  
    11.     MyBase.WndProc(m)
    12. End Sub
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  19. #59
    New Member
    Join Date
    Sep 2014
    Posts
    2

    Re: Disable Close Button and Prevent Form Being Moved

    That's brilliant.

    Thanks

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width