|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionIn Visual Basic 6, a form had a BackgroundMy personal, and potentially controversial, reason for needing this feature is that I like most applications on my PC to fill the screen. Unfortunately, too often the developer has coded the application to remember its size and position but not whether it was last maximized or not. As such I have developed the habit of resizing a window to fill the screen without maximizing it. This, maybe bad, habit has found its way into some of the software I have developed. I often size the main window of an application to fill the screen working area but unlike a maximized window, an accidental click and drag can move the window out of place and putting back is a hassle. I use a .NET class library that I have developed with a class that inherits from Using the codeWhether you inherit from an extended form or you paste the code directly into a form with the rest of your code, it is very easy to use. Simply set the Friend Class Form1
Inherits ImmoveableForm
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
'This disables the user's ability to move this form
Me.Moveable = False
End Sub
'usual Visual Studio designer code here
End Class
Points of InterestThe resulting code for the Disabling dragging the window caption was quite straightforward, as was ignoring selection of the Move item on the system menu. Actually preventing a selection of the Move menu item in the first place was interesting. My first thought was to delete the Move menu item from the system menu but the Windows standard tends to be greying and disabling menu items. Deleting also makes it difficult to restore the menu when the There were some problems with setting the Move menu item to disabled from within History
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||