Visual Cobol: Gradient Coloring a Tabpage

I want to color my tabpages using gradient colors. I got this example in Visual Basic:
Public Class Form1
    Dim a As Integer
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
    End Sub
    Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim formGraphics As Graphics = e.Graphics
        Dim GD As Drawing2D.LinearGradientBrush
        If a = 1 Then
            GD = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(Width, Height), Color.White, Color.FromArgb(0, 0, 222))
        ElseIf a = 2 Then
            GD = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(Width, 0), Color.White, Color.FromArgb(0, 222, 0))
        ElseIf a = 3 Then
            GD = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.White, Color.FromArgb(222, 0, 0))
        Else
            GD = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.White, Color.FromArgb(0, 0, 0))
            a = 1
        End If
        formGraphics.FillRectangle(GD, ClientRectangle)
        GD.Dispose()
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        a = a 1
        Refresh()
    End Sub
End Class 

the example colors the whole form; changes color when button1 is pushed. I am not aquainted to VB. Is there an example in Visual Cobol?

  • Verified Answer

    I have attached an example Visual COBOL solution that demonstrates this.

    The following is the COBOL equivalent to the VB code that you posted:

         $set ilusing"System.Drawing"
         $set ilusing"System.Drawing.Drawing2D"
          class-id testgradientcolor.Form1 is partial
                    inherits type System.Windows.Forms.Form.
          working-storage section.
          01 a binary-long.
          method-id NEW.
          procedure division.
              invoke self::InitializeComponent
              goback.
          end method.
          method-id Form1_Paint final private.
          01 formGraphics type Graphics.
          01 GD type System.Drawing.Drawing2D.LinearGradientBrush.
          procedure division using by value sender as object e as type System.Windows.Forms.PaintEventArgs.
             set formGraphics to e::Graphics
             if a = 1
               set GD to New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(self::Width, self::Height),
                  type Color::White, type Color::FromArgb(0, 0, 222))
             else
                if a = 2
                   set GD to New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(self::Width, 0),
                      type Color::White, type Color::FromArgb(0, 222, 0))
                else
                   if a = 3
                      set GD to New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, self::Height),
                         type Color::White, type Color::FromArgb(222, 0, 0))
                   else
                      set GD to New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, self::Height),
                         type Color::White, type Color::FromArgb(0, 0, 0))
                      set a to 1
                   end-if
                end-if
             end-if
             invoke formGraphics::FillRectangle(GD, self::ClientRectangle)
             invoke GD::Dispose
             exit method.
          end method.
          method-id button1_Click final private.
          procedure division using by value sender as object e as type System.EventArgs.
              set a to a 1
              invoke self::Refresh
              exit method.
          end method.
          method-id Form1_Load final private.
          procedure division using by value sender as object e as type System.EventArgs.
             invoke self::SetStyle(type ControlStyles::AllPaintingInWmPaint B-Or type ControlStyles::DoubleBuffer
                B-Or type ControlStyles::ResizeRedraw B-Or type ControlStyles::UserPaint, True)
             exit method.
          end method.
          end class.

    testgradientcolor.zip