Discussions related to Visual Prolog
User avatar
abdelrahman
Posts: 14
Joined: 13 Sep 2009 6:23

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

Unread post 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
Attachments
workboard_2.JPG
workboard_2.JPG (115.66 KiB) Viewed 21070 times
workboard_1.JPG
workboard_1.JPG (111.98 KiB) Viewed 21070 times
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc »

User avatar
abdelrahman
Posts: 14
Joined: 13 Sep 2009 6:23

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

Unread post 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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

It may however be a bit too "expensive" to load the picture from the file on each paint event.
Regards Thomas Linder Puls
PDC
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post 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.
hicham
Active Member
Posts: 29
Joined: 3 Apr 2014 8:32

Unread post by hicham »

this is only for background , but if we want to put a image on a buttom for example .. how to do it?
ok
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post 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
Regards Thomas Linder Puls
PDC
hicham
Active Member
Posts: 29
Joined: 3 Apr 2014 8:32

Unread post 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).
ok
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post 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).
Post Reply