Home » Developer & Programmer » Forms » Initialise image item (Forms 6i.)
Initialise image item [message #336388] Sat, 26 July 2008 04:49 Go to next message
dillango
Messages: 145
Registered: January 2008
Senior Member
Dear All,

I have tabular form records. When I click particular record (say for example employee number), I should display the corresponding picture of that employee which already been stored in the local directory.

Some of the employee don't have picture.

Now the problem is, If there is no picture available for a employee, instead of showing blank, it still showing the previous picture. How to initialise the image item?

This is my code written in when-mouse-click trigger.


Declare
 bmp_image_dir varchar2(80) := 'D:\IMAGES\';
 photo_filename varchar2(80);
begin
  photo_filename := bmp_image_dir || lower(:pending.eno) || '.bmp';
	Read_Image_file(photo_filename,'BMP','MANAGER_VIEW.empphoto');
	if not form_success then
		 Message('This employee does not have a photo on file directory');message(' ');
	end if;
end;

Re: Initialise image item [message #336399 is a reply to message #336388] Sat, 26 July 2008 06:40 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I don't have Forms 6i, but I have tried to do the same using Forms 10g. My form is based on the DEPT table from Scott's schema. I have also created two BMP files named 10.bmp and 30.bmp (so departments 20 and 40 don't have images).

With the slight difference between block and item names, everything seems to be OK - departments 10 and 30 displayed images, 20 and 40 said that there was an error as no image exists.

/forum/fa/4693/0/

Now, do you have any other trigger which "copies" a previous image into an "empty" image item? If not, a reason might be different behaviour between 6i and 10g versions, but I don't know anything about it.
Re: Initialise image item [message #336401 is a reply to message #336399] Sat, 26 July 2008 08:01 Go to previous messageGo to next message
dillango
Messages: 145
Registered: January 2008
Senior Member
Mr.Littlefoot,

Thank you for your effort to explain with the examples. However, I have no other trigger except when-mouse-click to call this particular block.

I am also getting an error message but picture is not cleared.
Alternatively, If I know how to blank the image manually, I can use it after the message display.

ILANGO

Re: Initialise image item [message #336408 is a reply to message #336401] Sat, 26 July 2008 09:23 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I think I understand what's bothering you ...

Well, the fact is that you can't refer to an image item in PL/SQL code, such as
:block.image_item := null;
or something like that.

However, you might hide or display this item, depending on whether there is (or not) an image for an item.

So, your WHEN-MOUSE-CLICK trigger would look like this:
Declare
  bmp_image_dir varchar2(80) := 'D:\IMAGES\';
  photo_filename varchar2(80);
begin
  set_item_property('manager_view.empphoto', visible, property_true);
  photo_filename := bmp_image_dir || lower(:pending.eno) || '.bmp';
  Read_Image_file(photo_filename,'BMP','MANAGER_VIEW.empphoto');
end;

Furthermore, create the ON-ERROR trigger as
if error_type = 'FRM' and error_code = 47109 then
   set_item_property('manager_view.empphoto', visible, property_false);
end if;
(Include a message if you wish, but not displaying an image is just enough in my opinion; who'd want to acknowledge a message every time an employee doesn't have an image?)
Re: Initialise image item [message #336425 is a reply to message #336388] Sat, 26 July 2008 12:38 Go to previous message
dillango
Messages: 145
Registered: January 2008
Senior Member
Fantastic,

As you said, first option was throwing an error as bad bind variable. Second idea is working fine( visible false). This idea did not strike me.

Thank you very much
ILANGO
Previous Topic: Populate List
Next Topic: Cancel Query
Goto Forum:
  


Current Time: Mon Feb 03 09:54:43 CST 2025