5,427,813 members and growing! (17,932 online)
Email Password   helpLost your password?
Languages » VB.NET » Windows Forms     Intermediate License: The Common Public License Version 1.0 (CPL)

VDialog (Vista TaskDialog for Windows XP)

By Lukasz Swiatkowski

Vista-like TaskDialog control for .NET Framework 2.0, compatible with Windows XP
VB (VB 8.0, VB 9.0, VB), Windows (Windows, Win2K, WinXP, Win2003, Vista, TabletPC, Embedded), .NET (.NET, .NET 3.5, .NET 2.0, .NET 3.0), Dev

Posted: 7 Nov 2007
Updated: 8 Apr 2008
Views: 35,616
Bookmarked: 98 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
Prize winner in Competition "Best VB.NET article of November 2007"
45 votes for this Article.
Popularity: 7.68 Rating: 4.64 out of 5
0 votes, 0.0%
1
1 vote, 2.3%
2
2 votes, 4.7%
3
4 votes, 9.3%
4
36 votes, 83.7%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

VDialog using LockSystem feature.

Screenshot 1 — VDialog using LockSystem feature

Sample customized VDialog.

Screenshot 2 - Sample customized VDialog

Sample security VDialog.

Screenshot 3 - Sample security VDialog

Expandable VDialog with footer (RightToLeft property set to RightToLeft.Yes and RightToLeftLayout property set to True).

Screenshot 4 - Expandable VDialog with footer

Introduction

Many programmers would like to use Windows Vista TaskDialog on earlier systems like Windows 2000/XP. Unfortunately this is not possible.

There are some TaskDialog implementations on the Internet, but none of them is written in VB.NET. I decided to write my own version of a TaskDialog-like form with all the functionality of Vista TaskDialog. It is almost fully compatible with the MessageBox class. And there are some features of Vista TaskDialog implemented (the rest of them will be implemented later). Some features, which are not implemented, can be emulated using custom controls (like radio buttons or progress bar — see the first screenshot above).

Using the code

The VDialog class is compatible with the MessageBox class so it can be used in the same way, e.g.:

VDialog.Show(Me, "Text", "Caption", MessageBoxButtons.YesNo, MessageBoxIcon.Error)

To customize the appearance of VDialog one must create VDialog object, set its properties and then invoke the Show() method, e.g.:

Dim vd As New VDialog()
With vd
    .WindowTitle = "Windows Vista"
    .Owner = Me
    .MainInstruction = "You must click OK button to continue"
    .Buttons = New VDialogButton() _
              { New VDialogButton(VDialogResult.OK), _
                New VDialogButton(VDialogResult.Continue) }
    .MainIcon = VDialogIcon.SecurityShieldBlue
    .DefaultButton = VDialogDefaultButton.None
    .Content = "If you don't know what to do, click Cancel button."
    .LockSystem = True
    .CustomControl = New MyCustomControl()
    .Show()
End With

Features

Almost full compatibility with the MessageBox class

Existing code can be easily changed to one which uses the VDialog class instead of the MessageBox class by changing the MessageBox.Show(…) invocation to the VDialog.Show(…) invocation.

Supported methods:

Show(String) As DialogResult
Show(String, String) As DialogResult
Show(String, String, MessageBoxButtons) As DialogResult
Show(String, String, MessageBoxButtons, MessageBoxIcon) As DialogResult
Show(String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton) As DialogResult
Show(String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton, MessageBoxOptions) As DialogResult
Show(IWin32Window, String) As DialogResult
Show(IWin32Window, String, String) As DialogResult
Show(IWin32Window, String, String, MessageBoxButtons) As DialogResult
Show(IWin32Window, String, String, MessageBoxButtons, MessageBoxIcon) As DialogResult
Show(IWin32Window, String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton) As DialogResult

Advanced usage

The VDialog class can also be used in other way. One can create VDialog object and set its properties, such as:

  • Owner — determines the parent of the VDialog message window.
  • Content, ContentLinks, WindowTitle and MainInstruction — determines the content of the dialog window which will be displayed, the caption of the window, and the main instruction.
  • Buttons — determines what buttons will be displayed on the VDialog message window. VDialogButton is a class containing UseCustomText, Text and VDialogResult properties, and also a Click event which is raised when the associated button is clicked (but before closing the window).
  • MainIcon, CustomMainIcon — the image show at the left side of the window (or right side when right-to-left layout is used).
  • DefaultButton — determines which button is initially focused.
  • RightToLeft and RightToLeftLayout — determines whether the layout of the window should be "mirrored".
  • Result — indicates the return value of the VDialog window.
  • LockSystem — enables the UAC-like system locking behavior.
  • CustomControl — provides an easy way to extend the VDialog window. It can be used to emulate the features of TaskDialog which are not supported yet.
  • VerificationText and VerificationFlagChecked — manages the check box shown at the left side of the buttons. It can be used for "Don't show it again"-like check boxes.
  • Sound — played when the dialog window is shown.
  • FooterText, FooterLinks, FooterIcon and CustomFooterIcon — determines the text and the image of the footer.
  • ExpandedInformation, ExpandedInformationLinks, ExpandFooterArea, ExpandedByDefault, ExpandedControlText and CollapsedControlText — determines the look and behavior of the expando control and label with extra information.

Localization support

The captions of the standard buttons (e.g. OK, Yes, Ignore, etc…) can be easily localized by translating the resources file. The English versions of these captions are contained in the Resoureces.resx file.

Images

The VDialogIcon class contains twelve read-only fields which provide access to Vista-like images, such as:

  • InformationInformation
  • QuestionQuestion
  • WarningWarning
  • ErrorError
  • SecurityShieldSecurityShield, SecurityShieldBlue, SecurityShieldGray
  • SecuritySuccessSecuritySuccess
  • SecurityQuestionSecurityQuestion
  • SecurityWarningSecurityWarning
  • SecurityErrorSecurityError
  • There is also the None field.

Assigning the VDialogIcon.Security* field (except the SecurityShield) to the MainIcon property of the VDialog class causes that the appropriate gradient is drawn beneath the icon and main instruction.

Sounds

The VDialogSound class provides access to six sounds (Default, Information, Question, Warning, Error, Security) that can be assigned to the Sound property of the VDialog class. Custom sound can be provided by object which implements the ISound interface.

Command links

There is and animated CommandLink control which can be used to build a custom controls and then embed it in the VDialog.

Screenshot 5 - Command links

License

The code is licensed under the Common Public License Version 1.0 (CPL).

TODO

Although the VDialog class provides many useful properties, there are some features of TaskDialog that my VDialog does not implement yet, such as:

  • Full support for CommandLinks
  • RadioButtons
  • ProgressBar
  • Timer
These features can only be obtained by using custom controls.

History

  • 1.4 (02.01.2008)
    • Added support for Links.
    • Fixed some bugs.
  • 1.3 (12.12.2007)
    • Added partial support for CommandLinks.
    • Added support for elevation (shield) icon.
    • Fixed some bugs.
  • 1.2 (05.12.2007)
    • Added XML documentation.
    • Added Close method to the VDialog class.
    • Added license.
    • Minor bugs fixed.
  • 1.1 (18.11.2007)
    • Renamed some properties so they are compliant with TaskDialog.
    • Added sounds support.
    • Added footer support.
    • Added expandable information support.
    • Added support for security dialogs.
    • Minor bugs fixed.
  • 1.0
    • 11.11.2007 — Added Vista-like images.
    • 07.11.2007 — First version.

License

This article, along with any associated source code and files, is licensed under The Common Public License Version 1.0 (CPL)

About the Author

Lukasz Swiatkowski


Mvp
I'm studying computer science at Wroclaw University of Technology, Poland.

My interests: .NET, reading, programming, drawing, OBE and LD, Japan, yoga, tai-chi.
My favourite movie: "Star Trek: First Contact".

My website: www.lukesw.net
My email: lukasz.swiatkowski/*at-sign*/gmail.com.
Location: Poland Poland

Other popular VB.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 78 (Total in Forum: 78) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralBugmemberJulian-w9:17 19 May '08  
Generalvdialog usagememberMember 43475342:26 16 Apr '08  
GeneralRe: vdialog usagemvpLukasz Swiatkowski11:48 17 Apr '08  
GeneralRe: vdialog usagememberMember 43475342:13 4 May '08  
GeneralRe: vdialog usagemvpLukasz Swiatkowski7:49 4 May '08  
QuestionCan't run the sample button 'Show system-locking TaskDialog-like window'memberMember 37117032:10 15 Apr '08  
GeneralRe: Can't run the sample button 'Show system-locking TaskDialog-like window'mvpLukasz Swiatkowski11:44 17 Apr '08  
GeneralRe: Can't run the sample button 'Show system-locking TaskDialog-like window' [modified]memberMember 37117031:23 18 Apr '08  
GeneralRe: Can't run the sample button 'Show system-locking TaskDialog-like window'mvpLukasz Swiatkowski6:38 18 Apr '08  
GeneralScreen centermemberPndm1:20 11 Apr '08  
GeneralRe: Screen centermvpLukasz Swiatkowski11:39 17 Apr '08  
QuestionTimer for autoclose with default button [modified]memberPeni5:22 8 Apr '08  
GeneralRe: Timer for autoclose with default buttonmvpLukasz Swiatkowski4:14 9 Apr '08  
GeneralRe: Timer for autoclose with default buttonmemberPeni4:25 9 Apr '08  
GeneralRe: Timer for autoclose with default buttonmvpLukasz Swiatkowski4:33 9 Apr '08  
GeneralVista UImemberpranav9522:32 6 Apr '08  
GeneralRe: Vista UImvpLukasz Swiatkowski14:02 7 Apr '08  
QuestionLockSystem @ Mainform possible? (not the whole system)memberDaniël Trommel21:09 3 Mar '08  
GeneralRe: LockSystem @ Mainform possible? (not the whole system)mvpLukasz Swiatkowski17:04 11 Mar '08  
Generaljust for your informationmemberdwegmann13:05 21 Feb '08  
GeneralRe: just for your informationmvpLukasz Swiatkowski13:31 21 Feb '08  
Generaluse of your library in a commercial program.memberAngel T12:17 17 Feb '08  
GeneralRe: use of your library in a commercial program.mvpLukasz Swiatkowski13:16 21 Feb '08  
GeneralDialog resizes when displayedmemberBryanKinkel6:07 29 Jan '08  
GeneralRe: Dialog resizes when displayedmvpLukasz Swiatkowski13:20 21 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 8 Apr 2008
Editor:
Copyright 2007 by Lukasz Swiatkowski
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project