title: ColorDialog - How can I check if cancel or X has been pressed
body: <p>In this PowerShell code, the dialog opens but I cannot seem to find a way to know if the cancel or X button has been pressed.</p>
  <p>If the user presses cancel then there's a returned value from the <code>Color</code> property.</p>
  <p>How can I fix this so that it will return something different if the user presses cancel or X to close the dialog.</p>
  <pre><code>$colorDialog = new-object System.Windows.Forms.ColorDialog
  [void]$colorDialog.ShowDialog()
  
  # This will always return a value even when cancel is pressed.
  $colorDialog.Color
  </code></pre>
  <p>It always returns this if cancel or the X button has been pressed:</p>
  <pre><code>R             : 0
  G             : 0
  B             : 0
  A             : 255
  IsKnownColor  : True
  IsEmpty       : False
  IsNamedColor  : True
  IsSystemColor : False
  Name          : Black
  </code></pre>