Loading images via URL

Images can also be loaded through an URL address now (not only via a file path). Currently only URLs starting with http and https are supported.

However, not all project types support loading images via URL, only PowerClient- and PowerServer-deployed applications support it.

And not all objects/controls can load images via URL; only the objects/controls listed below can (those not listed below can still load images via file paths):

Object/Control

Property/Function

Usage

DataWindow object > Button control

Filename property

In a painter: In the control's Properties view > General page > Picture File field, enter the URL of the picture file.

In scripts: dw_1.Object.b_1.filename = "http://172.16.5.175/button2.jpg"

DataWindow object > Column control

BitmapName property

In a painter: In the control's Properties view > General tab, select the Display As Picture option and then enter the URL of picture file in the rows provided below.

In scripts: dw_1.setitem(1,2,"http://172.16.5.175/button2.jpg")

DataWindow object > Computed Field control

Expression property

In a painter: In the control's Properties view > General page > Compute Expression field, enter the Bitmap expression function and the URL of the picture file, for example, Bitmap("http://172.16.5.175/computed2.jpg")

In scripts: dw_1.Object.compute_1.Expression = "bitmap('http://172.16.5.175/computed2.jpg')"

DataWindow object > Picture control

Filename property

In a painter: In the control's Properties view > General page > File Name field, enter the URL of the picture file.

In scripts: dw_1.Object.p_1.filename = "http://172.16.5.175/picture2.jpg"

Picture control

PictureName property

In a painter: In the control's Properties view > General page > PictureName field, enter the URL of the picture file.

In scripts: p_1.PictureName = "http://172.16.5.175/tang.jpg"

PictureButton control

PictureName property

In a painter: In the control's Properties view > General page > PictureName field, enter the URL of the picture file.

In scripts: pb_1.PictureName = "http://172.16.5.175/tang.jpg"

PictureHyperlink control

PictureName property

In a painter: In the control's Properties view > General page > PictureName field, enter the URL of the picture file.

In scripts: phl_1.PictureName = "http://172.16.5.175/tang.jpg"

PictureListBox control

AddPicture (picturename) function

In scripts: li_pic = plb_1.AddPicture("http://172.16.5.175/picturelistbox3.jpg")

PictureName[ ] property

In a painter: In the control's Properties view > Pictures tab > Picture Name field, enter the URL of the picture file.

DropdownPictureListBox control

AddPicture (picturename) function

In scripts: li_pic = ddplb_1.AddPicture("http://172.16.5.175/dropdownpicturelistbox2.jpg")

PictureName[ ] property

In a painter: In the control's Properties view > Pictures tab > Picture Name field, enter the URL of the picture file.

Tab control > TabPage

PictureName property

In a painter: In the user object's Properties view > TabPage page > PictureName field, enter the URL of the picture file.

In scripts: tab_1.tabpage_1.PictureName = "http://172.16.5.175/tabpage2.jpg"

Menu object > Submenu item

MenuImage property

In a painter: In the submenu item's Properties view > General page > MenuImage field, enter the URL of the picture file.

In scripts: m_webpicture.m_test.m_test1.MenuImage = "http://172.16.5.175/backgroud.bmp"

ToolbarItemName and ToolbarItemDownName properties

In a painter: In the submenu item's Properties view > Toolbar page > ToolbarItemName field and ToolbarItemDownName field, enter the URL of the picture file.

In scripts: m_webpicture.m_test.m_test1.ToolbarItemName = "http://172.16.5.175/backgroud.bmp"

ListView control

LargePictureName property

In a painter: In the ListView control's Properties view > Large Picture page > LargePictureName field, enter the URL of the picture file.

AddLargePicture (picturename) function

In scripts: lv_1.AddLargePicture("http://172.16.5.175/backgroud.bmp")

SmallPictureName property

In a painter: In the ListView control's Properties view > Small Picture page > SmallPictureName field, enter the URL of the picture file.

AddSmallPicture (picturename) function

In scripts: lv_1.AddSmallPicture("http://172.16.5.175/listview.jpg")

StatePictureName property

In a painter: In the ListView control's Properties view > State page > StatePictureName field, enter the URL of the picture file.

AddStatePicture (picturename) function

In scripts:

integer index

listviewitem lvi_1

lv_1.GetItem(lv_1.SelectedIndex (), lvi_1)

index = lv_1.AddStatePicture("http://172.16.5.175/listview.jpg")

lvi_1.StatePictureIndex = index

lv_1.SetItem(lv_1.SelectedIndex (), lvi_1)

TreeView control

PictureName[ ] property

In a painter: In the TreeView control's Properties view > Pictures page > PictureName field, enter the URL of the picture file.

AddPicture (picturename) function

In scripts:

long ll_tvi

integer li_pic

li_pic = tv_1.AddPicture("http://172.16.5.175/treeview.jpg")

ll_tvi = tv_1.FindItem(RootTreeItem!, 0)

tv_1.InsertItemFirst(ll_tvi, "New", li_pic)

StatePictureName property

In a painter: In the TreeView control's Properties view > State page > StatePictureName field, enter the URL of the picture file.

AddStatePicture (picturename) function

In scripts:

integer index

treeviewitem tv_item1

index = tv_1.AddStatePicture("http://172.16.5.175/treeview.jpg")

tv_item1.StatePictureIndex = index


You can get and set the following settings for pictures loaded via URL:

  • CloudAppSet -- Configures the following settings for pictures loaded via URL in PowerServer/PowerClient-deployed applications: 1) the picture cache directory, 2) whether to delete pictures from the cache when the application is closed, 3) whether to check picture for update. For more information, refer to CloudAppSet.

    CloudAppSet ("picturecachepath", "/picturecache");
    CloudAppSet ("clearpicturecacheonclose", "true");
    CloudAppSet ("checkpictureforupdate", "true");
  • CloudAppGet -- Gets the following settings for pictures loaded via URL in PowerServer/PowerClient-deployed applications, 1) the picture cache directory, 2) whether to delete pictures from the cache when the application is closed, 3) whether to check picture for update. For more information, refer to CloudAppGet.

    CloudAppGet ("picturecachepath", strValue1);
    CloudAppGet ("clearpicturecacheonclose", strValue2);
    CloudAppGet ("checkpictureforupdate", strValue3);
    

Note that

1) The retry interval for picture download is 30 seconds, and the retry times is 3.

2) If pictures cannot be downloaded successfully, a webpicture.log file will be generated in the "Log" folder of the current application directory.