Tuesday, September 21, 2004

 

ToolTip in Windows

Well if you have been doing Web development for a long time in .Net now, if
you switch to windows it would pretty much possible for you to search for
the standard ToolTip property for all the controls and guess what you won't
find it... :-)
Windows UI is much more richer than web and so the windows controls try to
leverage that... For this reason there is a special ToolTip control which is
provided to you in the windows environment which you can associate with any
of your controls...
Now what are some of its advantages the code below will tell you:

ToolTip mvmTip = new ToolTip();
mvmTip.InitialDelay = 1500;
mvmTip.ReshowDelay = 1000;
mvmTip.SetToolTip(this.txtZipCode, "You need to provide a zip code only
if you are in US or Canada");

Similarly you also have GetToolTip() method... Well so go ahead and try
explore more on the ToolTip control...


With Best Regards,
Mitesh Mehta
Email : miteshvmehta@gmail.com
http://cc.1asphost.com/miteshvmehta/

 

System.IO.FileSystemInfo

This is nothing new, but I felt the need to share since so many miss it.
Many a times I see stuff like this being done (even I also did for sometime):

string FolderPath = FilePath.Substring(0, FilePath.LastIndexOf(@"\"));

Obviously they are trying to get the full path to a file. Next time your thinking about doing something like that consider:

System.IO.FileInfo fi = new System.IO.FileInfo(FilePath);
string FolderPath = fi.DirectoryName;

Much easier.

Take a look at all the other goodies in the System.IO.FileInfo class:

fi.Extension
fi.FullName
fi.Name
fi.Length
fi.Directory.FullName
fi.Directory.Name
fi.Directory.Root.FullName
fi.DirectoryName

Not to mention these methods:

fi.Open();
fi.OpenRead();
fi.OpenText();
fi.OpenWrite();

More: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemIOFileInfoClassTopic.asp



With Best Regards,
Mitesh Mehta
Email : miteshvmehta@gmail.com
http://cc.1asphost.com/miteshvmehta/

Wednesday, September 01, 2004

 

Add shortcut for uninstall in the Programs menu.

Your query is incomplete! We need more info to be able to help you.
What exactly is your query? Is it
a. You have added the path to your application as a shortcut under Start->Programs menu and now you want another shortcut named "uninstall application" which will delete all related files for this application?
b. Or you already have an installer project built for your app but when you run the installer, it doesn't add a menu entry for Uninstall ?
c. Or do you want to add your application's uninstall shortcut specifically under the Programs' menu for VS.NET 2003

Now some possible solutions:
For question (a) above, you don't need to write C# code. It can be accomplished using VBScript. Try this sample code :
'--------- code begin-------------
Set WshShell = CreateObject("WScript.Shell")
strProgramsPath = WshShell.SpecialFolders("Programs")

Set objShortcutLnk = WshShell.CreateShortcut(strProgramsPath & "\Uninstall Application.lnk")
objShortcutLnk.TargetPath = "my uninstaller.exe"
objShortcutLnk.Save
'---------code end ------------------
Save the above code to some file with vbs extension. Change "my uninstaller.exe" to refer to the uninstaller which you have created.
The above snippet creates a shortcut only for the current user. For All users, replace "Programs" above with "AllUsersPrograms"

b. In case you are not satisfied with VS.NET's inbuilt installer, you might want to try out one of the installers listed here:
http://www.sciencedaily.com/directory/Computers/Software/System_Management/Installers

c. Are you sure you want to do this? :)


With Best Regards,
Mitesh Mehta
Email : miteshvmehta@gmail.com
http://cc.1asphost.com/miteshvmehta/

This page is powered by Blogger. Isn't yours?