This is simple, but I thought it was kind of neat.
Public
Class Common
Private Const StartupRegistryFolder As String = "Software\Microsoft\Windows\CurrentVersion\Run"
Private Const StartupRegistryKey As String = "PSEDesktop"
Public Shared Property LaunchOnStartup() As Boolean
Get
Dim Key As RegistryKey = Registry.CurrentUser.OpenSubKey(StartupRegistryFolder)
If Not Key Is Nothing Then
Dim Value As String = DirectCast(Key.GetValue(StartupRegistryKey, String.Empty), String)
Key.Close()
Return Value <> ""
Else
Return False
End If
End Get
Set(ByVal Value As Boolean)
Dim Key As RegistryKey = Registry.CurrentUser.OpenSubKey(StartupRegistryFolder, True)
If Not Key Is Nothing Then
If Value Then
Key.SetValue(StartupRegistryKey, Application.ExecutablePath)
Else
Key.DeleteValue(StartupRegistryKey)
End If
Key.Close()
End If
End Set
End Property
End Class
Hopefully someone can find some use for it. Once you have this property in your application somewhere, you can link it to a CheckBox's Checked Property or something like that to let the user decide of they want your application to launch on startup or not.
Thanks to Cory Smith, I now have my gamertag on the left hand side of my blog...very cool...thanks, Cory! :)
Sure would be nice to have something to link it to like a profile page or something, Microsoft...*hint hint* ;)
I don't rant very often, but there are a couple things really getting on my nerves so I figured I'd blog about them and see if anybody knows of any workarounds or maybe feels my pain.
<rant>
- When setting the Focus of a Control in the Form's Load Event, it DOESN'T WORK! Instead I have to go put it in the Activated Event with a Boolean around it to make sure it only calls it once.
- Why is it that if I set the ControlBox Property of a Form to False AND set the FormBorderStyle Property to FixedDialog, I can still double click on the title bar of the form and it maximizes it?
- Why is it that if I change the Font of the Form to say....Verdana, the Title Bar's Font doesn't change? BTW, is there some Win32 API I can call to fix that?
- Why are there no good and easy to use Wizard Controls out there? ;)
</rant>
*Back to work in WindowsForms I go*
I'm sure many of you have already seen these, but those who haven't, check them out!
Tim Dawson made some pretty neato controls. I'm working on a little administration app and I thought it would be cool if it was laid out like Visual Studio .NET, so I went searching and found Tim's controls.
The two I used in particular were the Docking Suite and the Document Manager.
The Docking Suite is simple and awesome. Just use the excellent design time support to add some tabs, put in your own controls inside of them and you're done. Then you can do just about everything you can with ToolBars in VS.NET.
The Document Manager has great design time support as well. Unfortunately, IMHO, the object model for it is a bit lacking and doesn't allow you to do much past it without doing some “workaround” type stuff, but it looks and works great. An example of something I wanted to do was make it so only one instance of a document could be opened at a time per type of document. There isn't a Documents collection, out in the open which would've been nice. I did however, find a Documents collection under the TabStrip collection, but I guess by default there are technically no TabStrips, so I could never get to it. It was easy to get around though (make an ArrayList to hold the documents and check against it when trying to open a new one, etc).
Overall, fantastic controls! Within 20 minutes, I had a “VS.NET-like” WindowsForms app going. Thanks, Tim! :)