f



Print using Drawtext() and tab stops

Hi folks!

I have an MLE in which I intercept the TAB key to paste in some tab stops _chr(9) and that works well.

I then use the textvalue of that MLE to DrawText() to a printer hDC but the tab stops don't come out right and therefore the text isn't printed exaclty as it appears in the MLE.

Any ideas on how to make that happen? Where should I start looking?

Thanks!

Steph

Trapping the TAB key in the MLE. Got this from the NG a while back. Works fine.

Method Dispatch(oEvent) CLASS MyMLE
	
	do case
      case oEvent:message=WM_GETDLGCODE
           if oEvent:wparam=VK_TAB 
              Return self:eventReturnValue:=DLGC_WANTTAB
           endif

      case oEvent:message=WM_KEYDOWN
           if oEvent:wparam=VK_TAB 
              self:paste(_CHR (9))
              return self:eventReturnValue:=1L
           endif
    endcase

Return super:dispatch ( oEvent )

Using Drawtext() to print textvalue of MLE:

Method _DrawNotes(cNotes as string) as void strict class MyFormPrint
   local rc      is _WINRECT
   local pszText as psz	

   rc.top:=self:yPos
   rc.left:=self:xPos
   rc.bottom:=self:yMax   
   rc.right:=self:xMax
   //Checked values of rect above and all is good

   pszText:=StringAlloc(cNotes)

//hDC below is handle to a printing device from PrintingDeice{}
//Mapping mode set to MM_TEXT
  DrawText(self:hDC,pszText,int(pszLen(pszText)),@rc,DT_CALCRECT+DT_WORDBREAK+DT_EXPANDTABS)
   DrawText(self:hDC,pszText,int(pszLen(pszText)),@rc,DT_WORDBREAK+DT_EXPANDTABS)  

Memfree(pszText)

Also here's how I set the font for the printingdevice

//Get default font
hFont:=GetStockObject(ANSI_VAR_FONT)   
GetObject(hFont,_sizeof(_WINLOGFONT),@lgfnt)

lgfnt.lfWeight:=FW_BOLD	  
lgfnt.lfHeight:= -MulDiv(10, GetDeviceCaps(self:hDC, LOGPIXELSY), 72)
lgfnt.lfWidth :=0
hFont:=CreateFontIndirect(@lgfnt)

SelectObject(self:hDC,hFont)

0
Steph
11/9/2016 8:51:24 PM
comp.clipper.visual-objects 12618 articles. 0 followers. Post Follow

2 Replies
244 Views

Similar Articles

[PageSpeed] 32

Steph,

Try using Courier New font.

HTH,
Jamal

"Steph H"  wrote in message 
news:c8d08e67-b27f-4eb7-9388-dbff95c8553d@googlegroups.com...

Hi folks!

I have an MLE in which I intercept the TAB key to paste in some tab stops 
_chr(9) and that works well.

I then use the textvalue of that MLE to DrawText() to a printer hDC but the 
tab stops don't come out right and therefore the text isn't printed exaclty 
as it appears in the MLE.

Any ideas on how to make that happen? Where should I start looking?

Thanks!

Steph

Trapping the TAB key in the MLE. Got this from the NG a while back. Works 
fine.

Method Dispatch(oEvent) CLASS MyMLE

do case
      case oEvent:message=WM_GETDLGCODE
           if oEvent:wparam=VK_TAB
              Return self:eventReturnValue:=DLGC_WANTTAB
           endif

      case oEvent:message=WM_KEYDOWN
           if oEvent:wparam=VK_TAB
              self:paste(_CHR (9))
              return self:eventReturnValue:=1L
           endif
    endcase

Return super:dispatch ( oEvent )

Using Drawtext() to print textvalue of MLE:

Method _DrawNotes(cNotes as string) as void strict class MyFormPrint
   local rc      is _WINRECT
   local pszText as psz

   rc.top:=self:yPos
   rc.left:=self:xPos
   rc.bottom:=self:yMax
   rc.right:=self:xMax
   //Checked values of rect above and all is good

   pszText:=StringAlloc(cNotes)

//hDC below is handle to a printing device from PrintingDeice{}
//Mapping mode set to MM_TEXT
  DrawText(self:hDC,pszText,int(pszLen(pszText)),@rc,DT_CALCRECT+DT_WORDBREAK+DT_EXPANDTABS)
   DrawText(self:hDC,pszText,int(pszLen(pszText)),@rc,DT_WORDBREAK+DT_EXPANDTABS)

Memfree(pszText)

Also here's how I set the font for the printingdevice

//Get default font
hFont:=GetStockObject(ANSI_VAR_FONT)
GetObject(hFont,_sizeof(_WINLOGFONT),@lgfnt)

lgfnt.lfWeight:=FW_BOLD
lgfnt.lfHeight:= -MulDiv(10, GetDeviceCaps(self:hDC, LOGPIXELSY), 72)
lgfnt.lfWidth :=0
hFont:=CreateFontIndirect(@lgfnt)

SelectObject(self:hDC,hFont) 

0
Jamal
11/9/2016 9:03:21 PM
Thanks Jamal, that did the trick.

Steph
0
Steph
11/21/2016 1:09:11 PM
Reply: