Page 1 of 1

Tooltip back and fore color won't set

Posted: Thu Jun 25, 2020 6:17 am
by DarusDP
Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.175
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.17134.0

The Tooltip control properties BackColor and ForeColor have no affect on the GUI tooltips.

Re: Tooltip back and fore color won't set

Posted: Thu Jun 25, 2020 7:45 am
by brittneyr
The tooltip control requires that the coloring be handled manually in the control's Draw event. For this event to be triggered, the property OwnerDraw must be set to true and IsBallon must be set to false.

Here is an example of the Draw event setting the ForeColor and BackColor:
  1. $tooltip1_Draw=[System.Windows.Forms.DrawToolTipEventHandler]{
  2. #Event Argument: $_ = [System.Windows.Forms.DrawToolTipEventArgs]
  3.     $font = New-Object System.Drawing.Font("Segoe UI", 9.75)
  4.     $tooltip1.BackColor = [System.Drawing.Color]::Black
  5.     $_.DrawBackground()
  6.     $_.Graphics.DrawString($_.ToolTipText, $font, [System.Drawing.Brushes]::GreenYellow, $_.Bounds.X, $_.Bounds.Y)
  7. }