Problem:
In a PictureBix object in WinForms how can you set up the image at runtime from COBOL Code ?
Resolution:
You can do this by passing in a Bitmap object to the Picture Box.
Some example code that does this is:-
$set sourceformat(variable)
$set preservecase
class-id. frmPBox as "MDICOBOL.frmPBox" is partial
inherits class-form.
environment division.
configuration section.
repository.
class interface-icontainer as "System.ComponentModel.IContainer"
class class-form as "System.Windows.Forms.Form"
class class-string as "System.String"
class class-container as "System.ComponentModel.Container"
class class-size as "System.Drawing.Size"
class System-Windows-Forms-PictureBox as "System.Windows.Forms.PictureBox"
class S-C-ISupportInitialize as "System.ComponentModel.ISupportInitialize"
class System-Drawing-Point as "System.Drawing.Point"
class System-EventHandler as "System.EventHandler"
class System-Object as "System.Object"
class System-EventArgs as "System.EventArgs"
class cBitmap as "System.Drawing.Bitmap"
class cImage as "System.Drawing.Image"
class cPictureBoxSizeMode as "System.Windows.Forms.PictureBoxSizeMode"
.
object.
working-storage section.
method-id. NEW.
procedure division.
invoke self "InitializeComponent".
end method NEW.
method-id. "MDICOBOL_frmPBox_Load" final private.
linkage section.
01 sender System-Object.
01 e System-EventArgs.
procedure division using by value sender e.
set PictureBox1::"SizeMode" to cPictureBoxSizeMode::"StretchImage"
set PictureBox1::"Image" to cBitmap::"New"("..\\..\\mflogo.bmp") as cImage
end method "MDICOBOL_frmPBox_Load".
end object.
end class frmPBox.