Page 1 of 1

How can i add image from jpg file to small area window in my form .

Posted: 30 Oct 2011 4:18
by abdelrahman
My Dear friends , forgive me because i am novice in OOP and GUI Environment ,,
it was long time ago working with Borland's Turbo prolog ...
working via Visual prolog 7.2 PE Now ...
I Have a Main form that Holds Main patient Data .. like shown in picture (workboard_1) .
I wish if i Can add Image for the patient in the upper right corner at small window area .
like shown in picture workboard_2 ..
what the steps should i take to do this .. ??
and what is the type of control should i Use and how ??

thanks ...
abdelrahman

Posted: 31 Oct 2011 11:59
by Tonton Luc

My Dear Tonton , Thank you for your Directive Link ..

Posted: 2 Nov 2011 3:22
by abdelrahman
My Dear Tonton , Thanks for your Link ...
The following code has been worked for " *.bmp " images and that is well ..

predicates
onPaint : drawWindow::paintResponder.
clauses

onPaint(_Source, _Rectangle, GDI):-
Dir= directory::getCurrentDirectory(),
FileName=string::concat(Dir,"\\pt_pics\\bdc.bmp"),
Pic=vpi::pictLoad(fileName(FileName),100,100,0x0020),
GDI:pictdraw(Pic,pnt(650,5),rop_SrcCopy).

Thank you for your continuous Help...
abdelrahman

Posted: 2 Nov 2011 8:57
by Thomas Linder Puls
It may however be a bit too "expensive" to load the picture from the file on each paint event.

Posted: 2 Nov 2011 12:07
by Tonton Luc
:idea:

Code: Select all

facts mem_pic:picture:=erroneous.   predicates onPaint : drawWindow::paintResponder. clauses onPaint(_Source, _Rectangle, GDI):-     if isErroneous(mem_pic),         Dir= directory::getCurrentDirectory(),         FileName=string::concat(Dir,"\\pt_pics\\bdc.bmp"),         file::existFile(FileName) then             try                 mem_pic:=vpi::pictLoad(fileName(FileName),100,100,0x0020)             catch _ do                 succeed()             end try     end if,     if not(isErroneous(mem_pic)) then         GDI:pictdraw(mem_pic,pnt(650,5),rop_SrcCopy)     end if.

Posted: 5 Apr 2014 12:22
by hicham
this is only for background , but if we want to put a image on a buttom for example .. how to do it?

Posted: 5 Apr 2014 22:30
by Thomas Linder Puls
Actually, I would advise you not to put images on buttons. If you look around you will notice that buttons do not have images (except in web pages and games).

But if you insist then you should use button::setImageList:

Code: Select all

predicates     setImageList : (imageList ImageList).     setImageList : (imageList ImageList, integer LeftMargin, integer TopMargin, integer RightMargin, integer BottomMargin, imageAlign Align).     % @short Set an #ImageList for the button (margins default to 0, #Align defaults to alignLeft)     % @details #ImageList can either contain a single image,     % or it can contain images corresponding to the states PBS_NORMAL, PBS_HOT, PBS_PRESSED, PBS_DISABLED, PBS_DEFAULTED and PBS_STYLUSHOT.     % #LeftMargin, #TopMargin, #RightMargin and #BottomMargin specifies additional margins around the image.     % #Align specifies the placement of the image on the button.     % @end

Posted: 14 Apr 2014 11:30
by hicham
i tried to add 2 images instead of 1 but i have an error .
this is the program :

Code: Select all

predicates     onPaint : drawWindow::paintResponder.   clauses onPaint(_Source, _Rectangle, GDI):- Dir= directory::getCurrentDirectory(), FileName=string::concat(Dir,"\\pt_pics\\bdc.bmp"), Pic=vpi::pictLoad(fileName(FileName),900,900,0x0020), GDI:pictdraw(Pic,pnt(0,0),rop_SrcCopy), FileName=string::concat(Dir,"\\pt_pics\\chargeur.bmp"), Pic=vpi::pictLoad(fileName(FileName),20,20,0x0020), GDI:pictdraw(Pic,pnt(10,20),rop_SrcCopy).

Posted: 15 Apr 2014 7:22
by Tonton Luc
:idea:

Code: Select all

clauses onPaint(_Source, _Rectangle, GDI):- Dir= directory::getCurrentDirectory(), FileName1=string::concat(Dir,"\\pt_pics\\bdc.bmp"), Pic1=vpi::pictLoad(FileName1,900,900,0x0020), GDI:pictdraw(Pic1,pnt(0,0),rop_SrcCopy), FileName2=string::concat(Dir,"\\pt_pics\\chargeur.bmp"), Pic2=vpi::pictLoad(fileName(FileName2),20,20,0x0020), GDI:pictdraw(Pic2,pnt(10,20),rop_SrcCopy).