2 Attachment(s)
Re: Customizing My.Namespace
Perhaps you have some functionality which seems right for My.Computer such as returning a list of installed versions of the Microsoft Framework or simple return the current user’s My Document folder. Both of these are actually easy to write code when needed but at least for me are longer than I want to type. Any ways the attached demonstration project shows demos the following.
My.Computer.Printers
Returns a list of all known printers on the current computer
My.Computer.DefaultPrinterName
Returns the default printer for the current user
My.Computer.WindowsFolder
Install folder for MS-Windows
My.Computer.MyDocumentsFolder
Current user's My Document folder
My.Computer.RuntimeVersions
List of installed Frameworks
My.Computer.InternetExplorerInstalled
Is Microsoft Internet Explorer installed on the current computer
My.Computer.InternetExplorerExecutable
Path and executable to fire up IE perhaps with a file
There are a few other properties added and all the above are demo'd.
Any ways let's say this is food for thought.
Re: Customizing My.Namespace
this is really nice...framework versions is great
nice job...keep it up
1 Attachment(s)
Re: Customizing My.Namespace
There are times when a developer wants to change the button labels of a MsgBox or MessageBox regardless of whether this is not the best method to go since the better method is to create a form and adorn it with buttons which set the dialog result. The attached project has three functions callable under a custom My Namespace My.Dialogs. The code to change the button text is from another developer, his name and location of the original code is within the code.
Display an exceptions style dialog with Ooooops as the single button text
Code:
Try
DirectCast(sender, ListBox).SelectedIndex = 0
Catch ex As Exception
Dim Message As String = String.Format("Encountered the following{0}{1}", _
Environment.NewLine, ex.Message)
My.Dialogs.ExceptionDialog(Message, "Error", "Ooooops")
End Try
Setting button text on the fly for asking a question which returns a Boolean. The text for the buttons is obtained from two TextBoxs. In the function Question there is a check to see if the button text length is greater than 10 and if so truncated which can easily be taken out.
Code:
If My.Dialogs.Question("Your Question", "My Title", txtYes.Text, txtNo.Text) Then
ActiveControl = txtYes
Else
ActiveControl = txtNo
End If
Ask the user if they want to close a form, with a tad bit of humor.
Code:
Private Sub frmMainForm_FormClosing( _
ByVal sender As Object, _
ByVal e As System.Windows _
.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = Not _
My.Dialogs.RedNeckQuestion("Do ja wantta leave dis program", "Da Question")
End Sub