Attach a picture, from an image file, to a worksheet cell.
BOOL AttachPicture( int nRow, int nCol, LPCSTR lpcszFileName, DWORD dwEmbedInfo = 0 )
Note: new bit EMBEDGRAPH_MEDIA was added in Origin 2022 to allow inserting in new format that allow double-click to open in Image Window, while without this bit, the old way will insert as LeadBitmap and double-click will open to a Matrix Window
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
EX1
//Attach a picture, from an image file, to a worksheet cell. void Worksheet_AttachPicture_Ex1() { Worksheet wks = Project.ActiveLayer(); if(!wks) return; string strImage = GetOpenBox("*.bmp"); if(strImage.IsEmpty()) //user canceled return; wks.AttachPicture(0, 0, strImage, EMBEDGRAPH_KEEP_ASPECT_RATIO | EMBEDGRAPH_MEDIA); //new method //wks.AttachPicture(0, 0, strImage); //old method before Origin 2022 }
origin.h