Hi,
At run time, I'm trying to generate a simple popup form that displays an image. the image is stored as a Base64 string and converted to an Image object OK. I then generate a new form at run-time, which is also fine, but I can't get the syntax right to add the image to the form. I've not created a form at run time before, so it could be that I'm not adding controls to it properly...
Looking through the available methods on FormControls, I thought the FormImageControl or FormWindowControl classes would be fairly straight forward - but curiously, I can't seem to instantiate a FormImageControl or a FormWindowControl.
- When declaring a FormImageControl variable in my method, the compiler doesn't recognize the class type (error: "variable FormImageControl has not been declared").
- And while I can declare a FormWindowControl variable, I can't instantiate it in the normal way, as type 'Window' doesn't appear in the FormControlTypes Enum.
The MSDN documentation doesn't acknowledge any of these quirks, implying that these two children of FormControl behave the same as the others. Here's my code (various attempts are commented out but hopefully you get the picture:
void button_clicked(formButtonControl _formButtonControl)
{
Args args;
Form windowForm;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildControl formBuildControl;
str imageBase64;
BinData binData = new BinData();
container baseContainer;
Image image;
FormWindowControl windowControl;
FormImageControl imageControl; // variable FormImageControl has not been declared???
// Create container from base64
baseContainer = BinData::loadFromBase64("imageBase64String here");
// Create binData from container.
binData = new BinData();
binData.setData(baseContainer);
// lock element
element.lock();
// create Image from binData
image = new Image();
image.setData(binData.getData());
// Create the form to display the screenshot
windowForm = new Form();
// Create the form design.
formBuildDesign = windowForm.addDesign("Design");
formBuildDesign.caption("Caption here");
formBuildDesign.height(image.height());
formBuildDesign.width(image.width());
formBuildDesign.style(3);
//
// Problem Adding/Displaying the image!
// Obviously simple to do with embedded resources but not obvious from binData Image object
//
// Approach 1: FormImageControl
imageControl = windowForm.addControl(FormControlType::Image, "Image");
imageControl.image(image);
// Approach 2: FormWindowControl
windowControl = windowForm.addControl(FormControlType::Window, "Window"); // Enum element not found!
windowControl.image(image);
// Create the run-time form.
args = new Args();
args.object(windowForm);
formRun = classfactory.formRunClass(args);
formRun.run();
formRun.detach();
}