Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Using MouseMove in a PictureBox to enter i.e a signature on a touch screen.

$
0
0

Here is an example in a Windows Forms application:

       class-id savesignature.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
       01 prevLocation type Point value null.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id pictureBox1_MouseDown final private.
       procedure division using by value sender as object e as type System.Windows.Forms.MouseEventArgs.
          set prevLocation to e::Location
          invoke self::pictureBox1_MouseMove(sender, e)
          
       end method.

       method-id pictureBox1_MouseMove final private.
       01 bmp type Bitmap.
       procedure division using by value sender as object e as type System.Windows.Forms.MouseEventArgs.
       
           if (PrevLocation not = null)
              if (pictureBox1::Image = null)
                 set bmp to new Bitmap(pictureBox1::Width, pictureBox1::Height)
                    perform using g as type Graphics = type Graphics::FromImage(bmp)
                       invoke g::Clear(type Color::White)
                    end-perform
                 set pictureBox1::Image to bmp
               end-if
               perform using g as type Graphics = type Graphics::FromImage(pictureBox1::Image)
                  invoke g::DrawLine(type Pens::Black, prevLocation::X, prevLocation::Y, e::X, e::Y)
               end-perform
               invoke pictureBox1::Invalidate
               set PrevLocation to e::Location
            end-if

       end method.

       method-id pictureBox1_MouseUp final private.
       procedure division using by value sender as object e as type System.Windows.Forms.MouseEventArgs.
           set prevLocation to null.
       end method.

       method-id button1_Click final private.
       01 bmp type Bitmap.
       procedure division using by value sender as object e as type System.EventArgs.
       
           set bmp to new type Bitmap(PictureBox1::Width, PictureBox1::Height)
           invoke PictureBox1::DrawToBitmap(bmp, PictureBox1::ClientRectangle)
           invoke bmp::Save("c:\\temp\mysignature.jpg", type System.Drawing.Imaging.ImageFormat::Jpeg)
    
       end method.
      
       end class.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>