|
-
Jan 7th, 2009, 10:47 PM
#41
Re: Disable Close Button and Prevent Form Being Moved
 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?
-
Jan 8th, 2009, 02:02 AM
#42
PowerPoster
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.
-
Jan 8th, 2009, 07:11 AM
#43
Re: Disable Close Button and Prevent Form Being Moved
 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.
-
Jan 8th, 2009, 06:49 PM
#44
PowerPoster
Re: Disable Close Button and Prevent Form Being Moved
Great it works now!
Thanks!
-
Jan 10th, 2009, 06:55 PM
#45
Hyperactive Member
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
-
Jan 11th, 2009, 04:39 AM
#46
Re: Disable Close Button and Prevent Form Being Moved
 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.
-
Jan 12th, 2009, 09:30 PM
#47
Re: Disable Close Button and Prevent Form Being Moved
 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?
-
Jan 22nd, 2009, 11:35 AM
#48
Frenzied Member
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 
-
Jan 25th, 2009, 07:52 AM
#49
Re: Disable Close Button and Prevent Form Being Moved
 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.
-
Apr 2nd, 2010, 03:32 PM
#50
Lively Member
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
-
Feb 8th, 2011, 09:07 PM
#51
New Member
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?
-
Jun 20th, 2011, 09:27 PM
#52
Addicted Member
Re: Disable Close Button and Prevent Form Being Moved
 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'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! 
-
Aug 17th, 2011, 09:21 AM
#53
Addicted Member
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
-
Aug 17th, 2011, 08:12 PM
#54
Re: Disable Close Button and Prevent Form Being Moved
 Originally Posted by medsont
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?
-
Aug 19th, 2011, 12:40 PM
#55
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 27th, 2011, 05:52 AM
#56
Addicted Member
Re: Disable Close Button and Prevent Form Being Moved
ok Thank you Mr.SuperModerator.....
-
Sep 30th, 2014, 04:14 AM
#57
New Member
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
-
Sep 30th, 2014, 04:31 AM
#58
Re: Disable Close Button and Prevent Form Being Moved
 Originally Posted by Zaxxan
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:
Public Property CanMove As Boolean Protected Overrides Sub WndProc(ByRef m As Message) If Not CanMove AndAlso 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
-
Sep 30th, 2014, 07:15 AM
#59
New Member
Re: Disable Close Button and Prevent Form Being Moved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|