Display a bitmap on script's dialog box

RBA

Well-known member
How can I display a bitmap image on a script's dialog box? Not on a button, but on the actual dialog box.

I've gone this far, in other words, nowhere:

this.guideIcon = new Bitmap(pathToBitmap);

Thanks!
 
The easiest way to do this is with the onPaint event handler of a child Control object. Take a look at this example:

JavaScript:
function MyDialog()
{
   this.__base__ = Dialog;
   this.__base__();

   this.bitmap = new Bitmap( ":/appicon/pixinsight-icon.svg" );

   this.bitmapControl = new Control( this );
   this.bitmapControl.setScaledMinSize( 256, 256 );
   this.bitmapControl.onPaint = function()
   {
      let g = new Graphics( this );
      g.drawBitmap( 0, 0, this.dialog.bitmap.scaledTo( Math.min( this.width, this.height ) ) );
      g.end();
   };

   this.sizer = new HorizontalSizer( this );
   this.sizer.margin = 8;
   this.sizer.add( this.bitmapControl, 100 );
 
   this.adjustToContents();
}

MyDialog.prototype = new Dialog;

function main()
{
   (new MyDialog).execute();
}

main();

Let me know if this helps.
 
Back
Top