GadgetPrint( )
Does not seem to do anything:
Import maxgui.drivers
Local window:Tgadget=CreateWindow("Test",0,0,256,64)
Local gadget:Tgadget=CreateTextArea(0,0,128,16,window)
SetGadgetText(gadget,"testing")
GadgetPrint(gadget)
Does anyone else have issues?
Hi,
all functionality in DoPrint method has been commented out (not sure why). If you want that functionality back, you have to make few modifications.
In 'maxgui.mod\win32maxguiex.mod\win32maxguiex.bmx' find line 4216, and add this inside Method DoPrint()
Local tmpTextSelLen = TextAreaSelLen(Self)
Local tmpPrintDialog:PRINTDLGW = New PRINTDLGW
tmpPrintDialog.flags = PD_RETURNDC | PD_HIDEPRINTTOFILE | PD_NOPAGENUMS
If Not tmpTextSelLen Then tmpPrintDialog.flags:|PD_NOSELECTION
tmpPrintDialog.hwndOwner = _hwnd
If Not PrintDlg( Byte Ptr tmpPrintDialog ) Then Return 0
Local hdcPrinter:Byte Ptr = tmpPrintDialog.hdc
Local tmpDoc:DOCINFOW = New DOCINFOW
Local tmpDocTitle:Short Ptr = AppTitle.ToWString()
tmpDoc.lpszDocName = tmpDocTitle
Local tmpSuccess = (StartDocW( hdcPrinter, Byte Ptr tmpDoc ) > 0)
If tmpSuccess Then
Local _cursor:Byte Ptr = TWindowsGUIDriver._cursor
SetPointer( POINTER_WAIT )
SetMapMode( hdcPrinter, MM_TEXT )
Local wPage = GetDeviceCaps( hdcPrinter, PHYSICALWIDTH )
Local hPage = GetDeviceCaps( hdcPrinter, PHYSICALHEIGHT )
Local xPPI = GetDeviceCaps( hdcPrinter, LOGPIXELSX )
Local yPPI = GetDeviceCaps( hdcPrinter, LOGPIXELSY )
Local tmpTextLengthStruct[] = [GTL_DEFAULT,1200]
Local tmpTextLength = SendMessageW (_hwnd, EM_GETTEXTLENGTHEX, WParam Byte Ptr tmpTextLengthStruct, 0)
Local tmpTextPrinted, tmpFormatRange:FORMATRANGE = New FORMATRANGE
tmpFormatRange.hdc = hdcPrinter
tmpFormatRange.hdcTarget = hdcPrinter
tmpFormatRange.rcPageRight = (wPage*1440:Long)/xPPI
tmpFormatRange.rcPageBottom = (hPage*1440:Long)/yPPI
tmpFormatRange.rcLeft = (1440*_pagemargin);tmpFormatRange.rcTop = (1440*_pagemargin)
tmpFormatRange.rcRight = tmpFormatRange.rcPageRight - (2880*_pagemargin)
tmpFormatRange.rcBottom = tmpFormatRange.rcPageBottom - (2880*_pagemargin)
If tmpPrintDialog.flags & PD_SELECTION Then
tmpTextPrinted = TextAreaCursor(Self)
tmpFormatRange.CHARRANGE_cpMax = tmpTextPrinted+tmpTextSelLen
Else
tmpFormatRange.CHARRANGE_cpMax = tmpTextLength
EndIf
SendMessageW (_hwnd, EM_FORMATRANGE, False, 0)
While tmpSuccess And ( tmpTextPrinted < tmpFormatRange.CHARRANGE_cpMax )
tmpFormatRange.CHARRANGE_cpMin = tmpTextPrinted
tmpSuccess = (StartPage(hdcPrinter) > 0)
If Not tmpSuccess Then Exit
tmpTextPrinted = SendMessageW( _hwnd, EM_FORMATRANGE, True, Int Byte Ptr tmpFormatRange )
tmpSuccess = (EndPage(hdcPrinter) > 0)
Wend
If tmpSuccess Then EndDoc( hdcPrinter ) Else AbortDoc( hdcPrinter )
SendMessageW (_hwnd, EM_FORMATRANGE, False, 0)
TWindowsGUIDriver._cursor = _cursor
SetCursor _cursor
EndIf
GlobalFree( tmpPrintDialog.hDevMode )
GlobalFree( tmpPrintDialog.hDevNames )
DeleteDC( hdcPrinter )
MemFree tmpDocTitle
Return tmpSuccess
In 'C:\BlitzMaxNG\mod\maxgui.mod\win32maxguiex.mod\common.bmx' add these definitions:
Const PD_NOSELECTION:Int = $4
Const PD_DISABLEPRINTTOFILE:Int = $80000
Const PD_PRINTTOFILE:Int = $20
Const PD_RETURNDC:Int = $100
Const PD_RETURNDEFAULT:Int = $400
Const PD_RETURNIC:Int = $200
Const PD_SELECTION:Int = $1
Const PD_SHOWHELP:Int = $800
Const PD_NOPAGENUMS:Int = $8
Const PD_PAGENUMS:Int = $2
Const PD_ALLPAGES:Int = $0
Const PD_COLLATE:Int = $10
Const PD_HIDEPRINTTOFILE:Int = $100000
Type PRINTDLGW
Field lStructSize:Int = SizeOf(Self)
Field hwndOwner:Byte Ptr, hDevMode:Byte Ptr, hDevNames:Byte Ptr, hdc:Byte Ptr
Field flags:Int, nFromPage:Short, nToPage:Short, nMinPage:Short, nMaxPage:Short, nCopies:Short
Field padding:Short, padding2:Short, padding3:Short, padding4:Short, padding5:Short, padding6:Short
Field padding7:Short, padding8:Short, padding9:Short, padding10:Short, padding11:Short, padding12:Short
Field padding13:Short, padding14:Short, padding15:Short, padding16:Short
EndType
Type DOCINFOW
Field cbSize:Int = SizeOf(Self)
Field lpszDocName:Short Ptr, lpszOutput:Short Ptr, lpszDatatype:Short Ptr
Field fwType:Int
EndType
Type FORMATRANGE
Field hdc:Byte Ptr, hdcTarget:Byte Ptr
Field rcLeft:Int, rcTop:Int, rcRight:Int, rcBottom:Int
Field rcPageLeft:Int, rcPageTop:Int, rcPageRight:Int, rcPageBottom:Int
Field CHARRANGE_cpMin:Int, CHARRANGE_cpMax:Int
EndType
-Henri
I came up with this :-X
SuperStrict
Import maxgui.drivers
Local window:Tgadget=CreateWindow("Test",0,0,256,256)
Local gadget:Tgadget=CreateTextArea(0,0,128,22,window)
SetGadgetLayout( gadget, 0, 0, 128, 16 )
ActivateGadget( gadget )
SetGadgetText(gadget,"testing")
While Not AppTerminate() And Not KeyDown(Key_Escape)
Wend