1. getTextExtent question

I've been using this code snippet to get the extent of characters, but I must
be doing something wrong. The MleText control below shows an X extent of cx*30 
which I want it to be enough space to allow 30 characters on each line. I can
get only 17 characters. Does anyone see anything wrong.

setFont(Screen, "Courier New", fs, Normal)
		charSize = getTextExtent(Screen,"abcdefghij")

		cx = charSize[1]/10
		cy = charSize[2]+3
		
		commentsId = create(MleText, "", invoiceParameters, cx*3, cy*3, cx*30, cy*4,0)
		setFont(commentsId,"Courier New", fs, Normal)
		tmp = sendMessage(commentsId,EM_LIMITTEXT,108,NULL)
		


new topic     » topic index » view message » categorize

2. Re: getTextExtent question

George Walters wrote:
> 
> 
> I've been using this code snippet to get the extent of characters, but I must
> be doing something wrong. The MleText control below shows an X extent of cx*30
>
> which I want it to be enough space to allow 30 characters on each line. I can
> get only 17 characters. Does anyone see anything wrong.
> 
> }}}
<eucode>
> 		setFont(Screen, "Courier New", fs, Normal)
> 		charSize = getTextExtent(Screen,"abcdefghij")
> 
> 		cx = charSize[1]/10
> 		cy = charSize[2]+3
> 		
> 		commentsId = create(MleText, "", invoiceParameters, cx*3, cy*3, cx*30,
> cy*4,0)
> 		setFont(commentsId,"Courier New", fs, Normal)
> 		tmp = sendMessage(commentsId,EM_LIMITTEXT,108,NULL)
> 		
> </eucode>
{{{


The 'create()' dimensions set the size of the *outside* edge of the control.
It doesn't make allowances for scrollbars or control borders.

May I suggest that after you have created the MLE, you call setClientRect()
to set the size of the inner space of the control.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

3. Re: getTextExtent question

Derek Parnell wrote:
> 
> George Walters wrote:
> > 
> > 
> > I've been using this code snippet to get the extent of characters, but I
> > must
> > be doing something wrong. The MleText control below shows an X extent of
> > cx*30
> > which I want it to be enough space to allow 30 characters on each line. I
> > can
> > get only 17 characters. Does anyone see anything wrong.
> > 
> > }}}
<eucode>
> > 		setFont(Screen, "Courier New", fs, Normal)
> > 		charSize = getTextExtent(Screen,"abcdefghij")
> > 
> > 		cx = charSize[1]/10
> > 		cy = charSize[2]+3
> > 		
> > 		commentsId = create(MleText, "", invoiceParameters, cx*3, cy*3, cx*30,
> > cy*4,0)
> > 		setFont(commentsId,"Courier New", fs, Normal)
> > 		tmp = sendMessage(commentsId,EM_LIMITTEXT,108,NULL)
> > 		
> > </eucode>
{{{

> 
> The 'create()' dimensions set the size of the *outside* edge of the control.
> It doesn't make allowances for scrollbars or control borders.
> 
> May I suggest that after you have created the MLE, you call setClientRect()
> to set the size of the inner space of the control.
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> 
Derek, this would be upside down for what I'm trying to do. I want to create
a MLE that is 30 chars wide and 4 lines deep. IT's an input box for the user
to construct a message that will go on all the invoices for the day..like this

**************************
*     THANK YOU FOR      *
*     YOUR BUSINESS      *
**************************

So I need an input box that would always be 30x4. How's the bestway to do that?

I could get it right for one computer but with a screen size change and char
size change it would be broken

new topic     » goto parent     » topic index » view message » categorize

4. Re: getTextExtent question

I guess what I'm trying to construct is a WYSIWYG input box, but don't know 
how. The getText result is one long string that I have to fold at 30 char
boundaries.

new topic     » goto parent     » topic index » view message » categorize

5. Re: getTextExtent question

George Walters wrote:
> 
> Derek Parnell wrote:
> > 
> > George Walters wrote:
> > > 
> > > 
> > > I've been using this code snippet to get the extent of characters, but I
> > > must
> > > be doing something wrong. The MleText control below shows an X extent of
> > > cx*30
> > > which I want it to be enough space to allow 30 characters on each line. I
> > > can
> > > get only 17 characters. Does anyone see anything wrong.
> > > 
> > > }}}
<eucode>
> > > 		setFont(Screen, "Courier New", fs, Normal)
> > > 		charSize = getTextExtent(Screen,"abcdefghij")
> > > 
> > > 		cx = charSize[1]/10
> > > 		cy = charSize[2]+3
> > > 		
> > > 		commentsId = create(MleText, "", invoiceParameters, cx*3, cy*3, cx*30,
> > > cy*4,0)
> > > 		setFont(commentsId,"Courier New", fs, Normal)
> > > 		tmp = sendMessage(commentsId,EM_LIMITTEXT,108,NULL)
> > > 		
> > > </eucode>
{{{

> > 
> > The 'create()' dimensions set the size of the *outside* edge of the control.
> > It doesn't make allowances for scrollbars or control borders.
> > 
> > May I suggest that after you have created the MLE, you call setClientRect()
> > to set the size of the inner space of the control.
> > 
> > -- 
> > Derek Parnell
> > Melbourne, Australia
> > 
> Derek, this would be upside down for what I'm trying to do. I want to create
> a MLE that is 30 chars wide and 4 lines deep. IT's an input box for the user
> to construct a message that will go on all the invoices for the day..like this
> 
> **************************
> *     THANK YOU FOR      *
> *     YOUR BUSINESS      *
> **************************
> 
> So I need an input box that would always be 30x4. How's the bestway to do
> that?
> 
> I could get it right for one computer but with a screen size change and char
> size change it would be broken

Maybe I don't understand, but I still say that my previous advice is okay. And
to repeat... After the MLE is created, set it's client area to the size you
want.  Here is a sample program that seems to work regardless of the font
size used. Notice that I create the MLE with zero width and height then
I set it's client size to 30x4 characters.

without warning
include win32lib.ew

integer vInvoiceParameters
integer vCommentsId

integer vCx
integer vCy
integer vFontSize

procedure Setup()
    sequence lCharSize

    vFontSize = 12
    setFont(Screen, "Courier New", vFontSize, Normal)
    lCharSize = getTextExtent(Screen,"W")
    vCx = lCharSize[1] + 1 -- each char has a pixel gap
    vCy = lCharSize[2] + 3 -- each line has a 3-pixel gap

    vInvoiceParameters = create(Window, "TEST", 0, 50, 50, 600, 400, 0)
    vCommentsId = create(MleText, "", vInvoiceParameters, vCx*3, vCy*3, 0, 0,0)
    setFont(vCommentsId,"Courier New", vFontSize, Normal)
    setClientRect(vCommentsId,  vCx * 30, vCy * 4)
    limitText( vCommentsId, 108)
    setText( vCommentsId, "abcdefghijklmnopqrstuvwxyzabcd\n2\n3\n4")
    setIndex( vCommentsId, 0)
    
end procedure

Setup()
WinMain(vInvoiceParameters, Maximize)
    


-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

6. Re: getTextExtent question

Derek, You did understand. I can't read... I overlooked the setClientRect and
read it as getClientRect...Your approach is perfect.

thanks

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu