eLabel and multiline

Discussions related to Visual Prolog
JuNeau
Posts: 17
Joined: 17 Dec 2007 9:45

eLabel and multiline

Unread post by JuNeau » 28 May 2008 10:27

Hi everybody !

I'm using Gildas Menier ebutton and elabel, it's wonderfull, but I wonder : does anybody know if it is possible to set an elabel as multiline ? I'd like to write a text (rather long) over a bmp file, and the elabel seems the simplest way to do so... unless you have a better idea ?

Thanks a lot

User avatar
Tonton Luc
VIP Member
Posts: 814
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 28 May 2008 12:02

Hi,
1) add a custom control named text_ctl with class = textControl and add your text in this control using this code :

Code: Select all

text_ctl:setText("Line 1\nLine 2\n etc..."), text_ctl:setForegroundColor(color_red),
2) or add your own draw control in your project + use vpi::drawText in the onPaint of this control...

JuNeau
Posts: 17
Joined: 17 Dec 2007 9:45

Unread post by JuNeau » 28 May 2008 14:18

Thanks Tonton :D ,

Your first proposal seems the simplest, I'll probably use it... Thanks again !

By the way, still concerning eLabel : do you know if it is possible to use a bmp using its resourceID rather than its file name ? I'd prefer that the bmp doesn't appear in the exe directory...

Gildas Menier
VIP Member
Posts: 78
Joined: 8 Jun 2004 23:01

Unread post by Gildas Menier » 28 May 2008 18:44

Hi Juneau !

You can use a resourceID of course (but outside the GUI builder). Have a look at setBackgroundPictureFromRes for instance (see the predicates ending with 'FromRes')
As for the multiline feature, I doubt it is possible using the published code.

regards

Gildas

JuNeau
Posts: 17
Joined: 17 Dec 2007 9:45

Unread post by JuNeau » 29 May 2008 13:22

Hi Gildas !

setBackgroundPictureFromRes works fine, thanks a lot !
Too bad for the multiline eLabel, I'll do as Tonton Luc suggested... It's not a big deal :D

Anyway good job for the ui_ext pack, it is really great ! Thanks again !

vjoer
VIP Member
Posts: 57
Joined: 7 Feb 2006 13:42

Unread post by vjoer » 26 Jan 2012 22:25

Hi

Multiline can be obtained for an ebutton (elabel) using drawTextInRect instead of drawText.

Basically replace the line

GDI:drawText(pnt(PositionX+TextOffsetX,PositionY+TextOffsetY+2), Txt)

with:

This:getSize(W, H),
GDI:drawTextInRect( rct(2,2,W-2,H-2), Txt, [dtext_Wordbreak])

regards
Viorel Farcas

Post Reply