动态添加图片控件例子
void addPicBox()
{
FormWindowControl c;
QueryRun qr;
DocuRef tmpDocuRef;
Image tmpImage;
int i = 1;
int j, maxControl;
container tmpBitmap,picCon;
nj_ItemPhotoTable nj_ItemPhotoTable,ItemPhotoTable;
DocuImgs curDocuimgs;
;
element.lock();
maxControl = groupPics.controlCount(); //获取groupPics的控件数量
picCon = connull();
Select FirstOnly ItemPhotoTable Where ItemPhotoTable.ItemId == Pictorical.ItemId
&& ItemPhotoTable.Color == Pictorical.Color;
qr = this.initQuery(ItemPhotoTable);
while (qr.next())
{
if(qr.changed(tableNum(Docuimgs)))
{
curDocuimgs = qr.get(tablenum(Docuimgs));
}
tmpDocuRef = qr.get(tablenum(DocuRef));
tmpBitmap = curDocuimgs.Image;
if (connull() == tmpBitmap)
continue;
tmpImage = new Image();
if (i > maxControl) //如果groupPics中已有windows控件
{
c = groupPics.addControl(FormControlType::Image, "RunTimeControl");
c.labelPosition(1);
c.labelAlignment(2);
c.imagemode(2);
controlCon += [c.id()];
}
else
c = this.control(conpeek(controlCon,i));//获取这个控件
c.visible(true);
c.label(strfmt('%1', tmpDocuRef.Nj_PhotoView));// 图片类型(角度、平面、侧面。。。)
tmpImage.setData(tmpBitmap);
c.image(tmpImage);
picCon += [c.id(), tmpDocuRef.RecId];
i++;
}
for (j = i; j<=maxControl; j++) //将多余的控件隐藏
{
c = this.control(conpeek(controlCon, j));
c.visible(false);
}
this.controlMethodOverload(true);
element.unLock();
element.redraw();
}