Hi Friends,
Today we are going to add a image to form below the grid to diplay the related image.
In class declaration of your form declare a FormWindowControl (variable name - itemImage) and add a method on form of to load the images,
the code for form is as follows
void loadImage()
{
Image img;
;
//where FormDataSource is the datasource holding image
public void init()
{
;
super();
itemImage = element.design().control(control::Window);
}
Today we are going to add a image to form below the grid to diplay the related image.
In class declaration of your form declare a FormWindowControl (variable name - itemImage) and add a method on form of to load the images,
the code for form is as follows
void loadImage()
{
Image img;
;
//where FormDataSource is the datasource holding image
if (FormDataSource.Image)
{
img = new Image();
img.setData(FormDataSource.Image);
itemImage.image(img);
}
else
{
itemImage.image(null);
}
}
overirde the init method of the form as shown below:-
{
;
super();
itemImage = element.design().control(control::Window);
}
Take a button under menuitem buton and name it as "save as"
to save the image which u have created take a new method on form and write the following code
to save the image which u have created take a new method on form and write the following code
void saveImage()
{
Image img;
Filename name;
str type;
#File
;
img = new Image();
type = '.'+strlwr(enum2value(img.saveType()));
name = WinAPI::getOpenFileName(element.hWnd(), [WinAPI::fileType(type),#AllFilesName+type], '', '');
if (name)
{
ttsbegin;
img.loadImage(name);
//where FormDataSource is the datasource holding image
FormDataSource.Image = img.getData();
FormDataSource.write();
ttscommit;
}
}
Now, override the active method of formdatasource and place the code as shown below:-
public int active()
{
int ret;
ret = super();
element.loadImage();
return ret;
}
Also, override the clicked method of "Save as" button created above and place the code as shown below:-
void clicked()
{
super();
element.saveImage();
}
Final step:- Add a window control on the tabpage\group or the place where u want to display the image.
Thanks.