Re: getTextExtent question
- Posted by Derek Parnell <ddparnell at bigpond.com> Dec 15, 2004
- 490 views
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