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


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

Print using Drawtext() and tab stops

Started bySteph H <stephn_33@hotmail.com>
First post2016-11-09 12:51 -0800
Last post2016-11-21 05:09 -0800
Articles 3 — 2 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  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

#9916 — Print using Drawtext() and tab stops

FromSteph H <stephn_33@hotmail.com>
Date2016-11-09 12:51 -0800
SubjectPrint using Drawtext() and tab stops
Message-ID<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)

[toc] | [next] | [standalone]


#9917

From"Jamal" <noooospam@example.com>
Date2016-11-09 16:03 -0500
Message-ID<o002um$f22$1@news.albasani.net>
In reply to#9916
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) 

[toc] | [prev] | [next] | [standalone]


#9991

FromSteph H <stephn_33@hotmail.com>
Date2016-11-21 05:09 -0800
Message-ID<36adbbce-c525-478a-acf5-b92a5822491a@googlegroups.com>
In reply to#9916
Thanks Jamal, that did the trick.

Steph

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web