Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #9916

Print using Drawtext() and tab stops

Newsgroups comp.lang.clipper.visual-objects
Date 2016-11-09 12:51 -0800
Message-ID <c8d08e67-b27f-4eb7-9388-dbff95c8553d@googlegroups.com> (permalink)
Subject Print using Drawtext() and tab stops
From Steph H <stephn_33@hotmail.com>

Show all headers | View raw


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)

Back to comp.lang.clipper.visual-objects | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Print using Drawtext() and tab stops Steph H <stephn_33@hotmail.com> - 2016-11-09 12:51 -0800
  Re: Print using Drawtext() and tab stops "Jamal" <noooospam@example.com> - 2016-11-09 16:03 -0500
  Re: Print using Drawtext() and tab stops Steph H <stephn_33@hotmail.com> - 2016-11-21 05:09 -0800

csiph-web