in System Integration by

I am building my interface to handle external images and all is going well, except for handling NULL returns.

I am trying to trigger an action, such as load a local image to indicate the image has failed.

Is this possible?



1 Answer

0 votes

Hello Phil,

returning NULL by the function EwLoadExternBitmap() means 'there is no image data to display'. Consequently, all associated Image views are cleared automatically. The difficulty here, the loading operation as well as the update of the associated Image views is performed with some delay. What can you do?

Step 1. Just after loading a new image (or if the loading is failed) the Extern Bitmap object triggers a notification with itself as source of the notification. You can add a new slot method to your component and register it as observer for such notifications. For this purpose use the attachobserver statement as demonstrated below. Usually you perform this registration at the initialization time of the affected GUI component:

attachobserver SlotMethod, ExternBitmapObject;

Step 2: Within the sot method implement code to check whether the Extern Bitmap object has loaded some contents or not. For this purpose evaluate the property FrameSize. If this property is <0,0>, then there is no content. Following could be the implementation of the slot method to check the content of the Extern Bitmap object. Here you can handle the error case, and for example display some default icon:

// No content in the Extern Bitmap object? Then display some default icon in
// the associated Image view
if ( ExternBitmapObject.FrameSize == <0,0> )
  ImageView.Bitmap = Application::SomeDefaultIcon;

// Or display the content of the Extern Bitmap object
  ImageView.Bitmap = ExternBitmap;

Does it help you?

Best regards

Paul Banach

Thanks Paul, that helps a lot, it also deals with the next part of generating a warning if the image is too large for the frame.

It might be worth considering adding a recovery image to the Resources::ExternBitmap in the future, or a default icon similar to the one displayed when you add an Image view but have not assigned a Bitmap.

Embedded Wizard Website | Privacy Policy | Imprint