Jump to content

Recommended Posts

Posted

Hello everybody, I have a problem here ... I need to generate a form of sale and print quality using the form I could do is not getting good, I created a window without borders with the fields I need, then use the function _ScreenCapture_CaptureWnd () to generate a print of this window and send the image to the printer using the UDF printMGv2.au3, the problem is that to get a good quality I would have to create a huge window to get the print, any suggestions to print this form with a good quality?
thank you...

example of the form it takes:

 

ImgTemp.jpg

Posted

Hi,

I can imagine when printing a form via PrtScr you are not going to get the best quality..

Is there a possibility to go a different route, like creating a PDF or using excel to create a form?

I personally use excel to build forms as it allows for simpler form filling automation ...

Bill

Posted (edited)

Thank you, to start the window was what I thought best, most had not considered the possibility of a PDF or Excel.

Still not getting good results with these methods mentioned, I think the best way would be to create the image (bmp or jpg) with GDI + however I'm picking up a lot ... maybe an experienced member in GDI + as the UEZ can shed some light.

Edited by mutleey
Posted (edited)

Your uploaded image has a dim. of 624 x 796 pixels (96 dpi) -> 16.5 x 21.0 cm; 6.48 x 8.28 inches. On a DIN A4 paper and portrait format it takes approx. 66% of the paper.

When you print that image from an ext. program such as IrfanView for example, how is the print out quality?

 

From https://www.prepressure.com/library/paper-size/din-a4:

Quote

At 300 ppi (pixels per inch) the image needs to be 2480 x 3508 pixels. This is the required resolution for quality offset printing that will be viewed from a short distance (such as books, brochures, magazines, calenders,…). For photo books it is also the optimum resolution but a somewhat lower pixel count (250 dpi) is acceptable for great looking photographs.

At 150 ppi the image needs to be 1240 x 1754 pixels. This is the minimum resolution for newspapers or posters viewed from a fairly short distance.

 

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Even using IrfanView printing is too bad, as I mentioned above I created a GUI with the fields needed and used the _ScreenCapture_CaptureWnd() function to generate the bmp image and then sent to the printer, to be good like you even mentioned I would have create a huge window more thought into creating bmp using GDI + for then would have set a large image 2480 x 3508 pixels perhaps ... the problem is that I could not add the rectangles in the image created.

thanks for the answer.

Edited by mutleey
Posted

kylomas,

Yes, as the UEZ comments the way I did the image is low resolution, and the way that I would have to create a huge GUI to get good results.

Posted

...it is not depending on printer settings...

THIS

example printer.jpg

is the "original" picture-quality sended to the printer. Which printer in the world makes gold from shi* ???

If you want a more "clearer" (printable) Screenshot, try to change your windows settings of the font/cleartype. What looks "good" onto screen (cleartype) is not implicitly a good printout.

Posted (edited)

UEZ yes I used the stretch to fill the entire sheet so the image lost the quality, the window that generated the printscreen has 624x796 pixels.

AndyG yes is not the printer to determine the quality and the image already has a low resolution.

 

I do not have much experience with GDI+ one more push already help, for example create this GUI with these rectangles and labels.

 

ex.jpg

Edited by mutleey
Posted (edited)

@Mutley, não é exatamente o que você queria, mas é disso que estou falando...

Criar uma imagem de fundo, e adicionar os controles necessários, esse exemplo é básico, mas pode ser o início de uma solução.

Após a composição da imagem, você pode imprimir normalmente.

A melhor ideia seria criar uma imagem pronta, com o formulário vazio, e imprimir na imagem apenas as informações, assim fica mais rápido também.

 

This example it is a toy, to create, move, resize, delete and set color to many Contols.

In this example, it work with GuiCtrlCreateLabel, but can be adapted to any control.

The Mod()'s function it's a attempt to move a Control to 8 to 8 pixels only, for example, not 1 to 1.

If you not want this way/recurse, only comment delete the lines have Mod() function.

If you want to improve this function, it's is welcome.

Use Secondary mouse button, to Add, Delete, Set Color and export to PNG.

Use Primary over the control to Move or Resize.

 

 

;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
;~ #Tidy_Parameters=/sf
; #FUNCTION# ====================================================================================================================
; Name ..........: No name
; Description ...: Allow create, move, resize, delete and set color a GuiCtrlCreateLabel and export to PNG image
; Syntax ........: 
; Parameters ....: 
; Return values .: 
; Author ........: Luigi
; Example .......: 
; ===============================================================================================================================
#include-once
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <GuiMenu.au3>
#include <WinAPIGdi.au3>
#include <Misc.au3>
#include <GDIPlus.au3>

OnAutoItExitRegister("OnExit")

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)


Global $aGuiSize[2] = [800, 600]
Global $sGuiTitle = "GuiTitle"
Global $hGui
Global $hUm, $hDois
Global $aCursor, $aMouse[5], $aMove[6], $arr, $size
Global $iLimit = 6
Global $aCursor2, $aMouse2[5]
Global $SUM, $DX, $DY
Global $hDummy, $hDummyContext, $hDummyContextMenu
Global $focus

_GDIPlus_Startup()
Global $hBitmap
Global $hContext
Global $hBrush = _GDIPlus_BrushCreateSolid()
Global $hFormat, $hFamily, $hFont, $tLayout, $aInfo


Global $hPen
$hPen = _GDIPlus_PenCreate()



Global Const $UP = 1, $RIGHT = 2, $DOWN = 4, $LEFT = 8
Global Const $UP_RIGHT = $UP + $RIGHT, $UP_LEFT = $UP + $LEFT, $DOWN_RIGHT = $DOWN + $RIGHT, $DOWN_LEFT = $DOWN + $LEFT

$hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetBkColor(0xFFFFFF, $hGui)

_CreateDummy($hDummy, $hDummyContext, $hDummyContextMenu, "Add=Context_Add;Del=Context_Del;Color=Context_Color;Image=Context_CreateImage")

Global $aNode[1] = [0]
Global $SID = IniRead("label.ini", "config", "id", 1)

Global $NODES = IniReadSection("label.ini", "objetos")
If IsArray($NODES) Then
    ReDim $NODES[UBound($NODES, 1)][3]
Else
    Global $NODES[1][3] = [[0]]
EndIf

If IsArray($NODES) Then
    For $ii = 1 To $NODES[0][0]
        NewObj($NODES[$ii][0], $NODES[$ii][1], $ii)
    Next
EndIf

Func NewObj($ID = 0, $input = 0, $ii = 0)
    If $ID Then
        $input = StringSplit($input, ",", 2)
        $NODES[$ii][2] = GUICtrlCreateLabel($ID, $input[0], $input[1], $input[2], $input[3], $SS_SUNKEN)
        GUICtrlSetBkColor($NODES[$ii][2], Number($input[4]))
    Else
        Local $color = NewColor()
        $aCursor = GUIGetCursorInfo($hGui)

        $aCursor[0] -= Mod($aCursor[0], 20) + 10
        $aCursor[1] -= Mod($aCursor[1], 20) + 10


        Local $new = GUICtrlCreateLabel($SID, $aCursor[0], $aCursor[1], 40, 40, $SS_SUNKEN)
        GUICtrlSetBkColor($new, $color)
        $SID += 1
        IniWrite("label.ini", "config", "id", $SID)
        IniWrite("label.ini", "objetos", $SID, ",,,," & $color)
        _ArrayAdd2d($NODES, $SID, "", $new)
    EndIf
EndFunc   ;==>NewObj

Func NewColor()
    Return "0x" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)
EndFunc   ;==>NewColor

Func _ArrayAdd2d(ByRef $arr, $mOpt0 = Default, $mOpt1 = Default, $mOpt2 = Default, $mOpt3 = Default, $mOpt4 = Default, $mOpt5 = Default, $mOpt6 = Default, $mOpt7 = Default)
    $arr[0][0] = UBound($arr, 1)
    Local $iCol = UBound($arr, 2)
    ReDim $arr[$arr[0][0] + 1][$iCol]
    If @NumParams - 1 < $iCol Then $iCol = @NumParams - 1
    For $ii = 0 To $iCol - 1
        $arr[$arr[0][0]][$ii] = Eval("mOpt" & $ii)
    Next
EndFunc   ;==>_ArrayAdd2d

GUICtrlSetState($hUm, $GUI_ONTOP)
;~ _WinAPI_BringWindowToTop(GUICtrlGetHandle($hUm))

GUICtrlSetBkColor($hUm, 0x336633)
GUICtrlSetBkColor($hDois, 0x996633)

GUISetState(@SW_SHOW, $hGui)


While Sleep(25)
    $aCursor = GUIGetCursorInfo($hGui)
    If IsArray($aCursor) Then
        If $aCursor[3] Then
            _GUICtrlMenu_TrackPopupMenu($hDummyContextMenu, $hGui)
        EndIf
        $focus = $aCursor[4] ? $aCursor[4] : 0
        If $aCursor[2] Then
            If $aCursor[4] Then
                $aMouse[4] = $aCursor[4]
                $arr = ControlGetPos($hGui, "", $aCursor[4])
                $aMove[0] = $arr[0] - $aCursor[0]
                ConsoleWrite("[" & $aMove[0] & "] [" & $arr[0] & "] [" & $aCursor[0] & "]" & @LF)
                $aMove[1] = $arr[1] - $aCursor[1]

                $aCursor2 = GUIGetCursorInfo($hGui)

                Switch $SUM
                    Case $DOWN
                        GUISetCursor(11, 1, $hGui)
                        $DX = $aCursor2[1] - $arr[3]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[1] <> $aMouse2[1]) Then
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX)
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $UP
                        GUISetCursor(11, 1, $hGui)
                        $aMouse2[1] = $aCursor2[1]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[1] <> $aMouse2[1]) Then
                                $size = $aMouse2[1] - $aCursor2[1]
                                $arr[1] -= $size
                                $arr[3] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $RIGHT
                        GUISetCursor(13, 1, $hGui)
                        $DY = $aCursor2[0] - $arr[2]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Then
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $aCursor2[0] - $DY, $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $LEFT
                        GUISetCursor(13, 1, $hGui)
                        $aMouse2[0] = $aCursor2[0]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Then
                                $size = $aMouse2[0] - $aCursor2[0]
                                $arr[0] -= $size
                                $arr[2] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $UP_RIGHT
                        GUISetCursor(10, 1, $hGui)
                        $aMouse2[1] = $aCursor2[1]
                        $DY = $aCursor2[0] - $arr[2]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[1] <> $aMouse2[1]) Or ($aCursor2[0] <> $aMouse2[0]) Then
                                $size = $aMouse2[1] - $aCursor2[1]
                                $arr[1] -= $size
                                $arr[3] += $size
                                $arr[2] = $aCursor2[0] - $DY
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $DOWN_RIGHT
                        GUISetCursor(12, 1, $hGui)
                        $DY = $aCursor2[0] - $arr[2]
                        $DX = $aCursor2[1] - $arr[3]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $arr[2] = $aCursor2[0] - $DY
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX)
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $UP_LEFT
                        GUISetCursor(12, 1, $hGui)
                        $aMouse2[0] = $aCursor2[0]
                        $aMouse2[1] = $aCursor2[1]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $size = $aMouse2[1] - $aCursor2[1]
                                $arr[1] -= $size
                                $arr[3] += $size
                                $size = $aMouse2[0] - $aCursor2[0]
                                $arr[0] -= $size
                                $arr[2] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3])
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case $DOWN_LEFT
                        GUISetCursor(10, 1, $hGui)
                        $aMouse2[0] = $aCursor2[0]
                        $DX = $aCursor2[1] - $arr[3]
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $size = $aMouse2[0] - $aCursor2[0]
                                $arr[0] -= $size
                                $arr[2] += $size
                                ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX)
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                    Case Else
                        GUISetCursor(9, 1, $hGui)
                        While IsArray($aCursor2) And $aCursor2[2]
                            $aCursor2 = GUIGetCursorInfo($hGui)
                            If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then
                                $aCursor2[0] = $aCursor2[0] - Mod($aCursor2[0], 20) ;+ $aMove[0]
                                ConsoleWrite("[" & $aCursor2[0] & "] [" & $aMove[0] & "] [" & $aCursor2[0] - Mod($aCursor2[0], 20) & "]" & @LF)
                                $aCursor2[1] = $aCursor2[1] - Mod($aCursor2[1], 20); + $aMove[1]
                                $aMouse2[0] = $aCursor2[0]
                                $aMouse2[1] = $aCursor2[1]

                                ControlMove($hGui, "", $aCursor[4], $aCursor2[0], $aCursor2[1], $arr[2], $arr[3])
                                _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE)
                            EndIf
                        WEnd
                EndSwitch

                GUISetCursor(6, 1, $hGui)
            Else

            EndIf
        Else
            If $aCursor[4] Then
                $arr = ControlGetPos($hGui, "", $aCursor[4])
                $aMove[0] = $arr[0] - $aCursor[0]
                $aMove[1] = $arr[1] - $aCursor[1]
                $SUM = 0

                If $aMove[0] <= 0 And $aMove[0] > -$iLimit Then $SUM += $LEFT
                If $aMove[0] <= -($arr[2] - $iLimit) And $aMove[0] >= -$arr[2] Then $SUM += $RIGHT
                If $aMove[1] <= 0 And $aMove[1] > -$iLimit Then $SUM += $UP
                If $aMove[1] <= -($arr[3] - $iLimit) And $aMove[1] >= -$arr[3] Then $SUM += $DOWN

                Switch $SUM
                    Case $UP
                        GUISetCursor(11, 1, $hGui)
                    Case $DOWN
                        GUISetCursor(11, 1, $hGui)
                    Case $RIGHT
                        GUISetCursor(13, 1, $hGui)
                    Case $UP_RIGHT
                        GUISetCursor(10, 1, $hGui)
                    Case $DOWN_RIGHT
                        GUISetCursor(12, 1, $hGui)
                    Case $LEFT
                        GUISetCursor(13, 1, $hGui)
                    Case $UP_LEFT
                        GUISetCursor(12, 1, $hGui)
                    Case $DOWN_LEFT
                        GUISetCursor(10, 1, $hGui)
                    Case Else
                        GUISetCursor(6, 1, $hGui)
                EndSwitch
            Else
                GUISetCursor(6, 1, $hGui)
            EndIf
        EndIf


    EndIf
WEnd

Func OnExit()
    For $ii = 1 To $NODES[0][0]
        IniWrite("label.ini", "objetos", $NODES[$ii][0], _ArrayToString(ControlGetPos($hGui, "", $NODES[$ii][2]), ",") & "," & GUICtrlGetBkColor($NODES[$ii][2]))
    Next
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)



    _GDIPlus_Shutdown()
    GUISetState($hGui, @SW_HIDE)
    GUIDelete($hGui)
EndFunc   ;==>OnExit

Func Quit()
    Exit
EndFunc   ;==>Quit


Func _CreateDummy(ByRef $dummy, ByRef $context, ByRef $menu, $cmd)
    Local $aDummy[1][3]
    _ArrayAdd($aDummy, $cmd, Default, "=", ";")
    $dummy = GUICtrlCreateDummy()
    $context = GUICtrlCreateContextMenu($dummy)
    $menu = GUICtrlGetHandle($context)
    For $ii = 1 To UBound($aDummy, 1) - 1
        $aDummy[$ii][2] = GUICtrlCreateMenuItem($aDummy[$ii][0], $context)
        If $aDummy[$ii][1] Then GUICtrlSetOnEvent($aDummy[$ii][2], $aDummy[$ii][1])
    Next
EndFunc   ;==>_CreateDummy

Func Context_Add()
    NewObj()
EndFunc   ;==>Context_Add

Func _box($hToGraphic, $iXX, $iYY, $iWW, $iHH, $iColor = 0, $bFill = False)
    ; _box3
    _GDIPlus_BrushSetSolidColor($hBrush, $iColor)
    If $iWW = 1 And $iHH = 1 Then
        If $iColor Then
            _GDIPlus_GraphicsFillRect($hToGraphic, $iXX, $iYY, $iWW, $iHH, $hBrush)
        Else
            _GDIPlus_GraphicsFillRect($hToGraphic, $iXX, $iYY, $iWW, $iHH)
        EndIf
    Else
        Local $aBox[5][2]
        $aBox[0][0] = 4
        $aBox[1][0] = $iXX
        $aBox[1][1] = $iYY
        $aBox[2][0] = $iXX + $iWW - 1
        $aBox[2][1] = $iYY
        $aBox[3][0] = $iXX + $iWW - 1
        $aBox[3][1] = $iYY + $iHH - 1
        $aBox[4][0] = $iXX
        $aBox[4][1] = $iYY + $iHH - 1
        If $iColor Then
            _GDIPlus_PenSetColor($hPen, $iColor)
            _GDIPlus_GraphicsFillPolygon($hToGraphic, $aBox, $hBrush)
            _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox, $hPen)
        Else
            _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox)
        EndIf
    EndIf
EndFunc   ;==>_box

Func _Text($hToGraphic, $sFont, $sText, $iSize, $iXX, $iYY, $iWW, $iHH, $iColor)
    _GDIPlus_BrushSetSolidColor($hBrush, $iColor)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    $hFont = _GDIPlus_FontCreate($hFamily, $iSize, 0)
    $tLayout = _GDIPlus_RectFCreate($iXX, $iYY, $iWW, $iHH)
    $aInfo = _GDIPlus_GraphicsMeasureString($hToGraphic, $sText, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hToGraphic, $sText, $hFont, $aInfo[0], $hFormat, $hBrush)

EndFunc   ;==>_Text

Func Context_CreateImage()
    ConsoleWrite("Context_CreateImage()" & @LF)
    Local $aControlGetPos, $iColor, $sText
    Local $iR, $iG, $iB
    $hBitmap = _GDIPlus_BitmapCreateFromScan0($aGuiSize[0], $aGuiSize[1])
    $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    _GDIPlus_GraphicsSetSmoothingMode($hContext, 0)
    _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF)

    For $ii = 1 To $NODES[0][0]
        $aControlGetPos = ControlGetPos($hGui, "", $NODES[$ii][2])
        $iColor = GUICtrlGetBkColor($NODES[$ii][2])
        $iR = _WinAPI_GetRValue($iColor)
        $iG = _WinAPI_GetGValue($iColor)
        $iB = _WinAPI_GetBValue($iColor)
        $iColor = "0x99" & Hex(_WinAPI_RGB($iR, $iG, $iB), 6)
        _box($hContext, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], $iColor, True)
        $sText = GUICtrlRead($NODES[$ii][2])
        _Text($hContext, "Courier New", $sText, 10, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], 0xFF000000)
    Next

    Local $sFile = @TempDir & "\Test.png"
    FileDelete($sFile)
    _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save bitmap to disk
    ShellExecute($sFile)
EndFunc   ;==>Context_CreateImage

Func Context_Del()
    Local $find = _ArraySearch($NODES, $focus, 1, Default, 0, 0, 0, 2)
    ConsoleWrite("$focus[" & $focus & "] $find[" & $find & "]" & @LF)
    If $find >= 0 Then
        GUICtrlDelete($focus)
        IniDelete("label.ini", "objetos", $NODES[$find][0])
        _ArrayDelete($NODES, $find)
        $aCursor = GUIGetCursorInfo($hGui)
    EndIf
    $NODES[0][0] = UBound($NODES, 1) - 1
EndFunc   ;==>Context_Del

Func Context_Color()
    If Not $focus Then Return
    Local $color = GUICtrlGetBkColor($focus)
    Local $NewColor = _ChooseColor(2, $color, 2, $hGui)
    If $NewColor = -1 Then Return
    GUICtrlSetBkColor($focus, $NewColor)
EndFunc   ;==>Context_Color

; #FUNCTION# ====================================================================================================================
; Name ..........: GUICtrlGetBkColor
; Description ...: Retrieves the RGB value of the control background.
; Syntax ........: GUICtrlGetBkColor($hWnd)
; Parameters ....: $hWnd                - Control ID/Handle to the control
; Return values .: Success - RGB value
;                  Failure - 0
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func GUICtrlGetBkColor($hWnd)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $iColor = _WinAPI_GetPixel($hDC, 0, 0)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return $iColor
EndFunc   ;==>GUICtrlGetBkColor

 

Edited by Luigi

Visit my repository

Posted
4 hours ago, UEZ said:

Can you post the test GUI code from post #1?

 

#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include 'printMGv2.au3'

ImprimePedido("Steve Jobs", "2350.20")

Func ImprimePedido($Str1, $Str2)
    Local $WS_POPUP = 0x80000000 ; Creates a pop-up window. This style cannot be used with the WS_CHILD style.
    Local $SS_CENTER = 0x01 ; Specifies a simple rectangle and centers the error value text in the rectangle. The control automatically wraps words that extend past the end of a line to the beginning of the next centered line.
    Local $Branco = 0xFFFFFF, $Cinza2 = 0xCCCCCC
    Local $rCli = FileReadToArray(@AppDataDir & "\GJA\Cli\" & $Str1)
    If @error Then Return

    Global $GuiPedido = GUICreate("Descrição de Pedidos", 624, 796, -1, -1, $WS_POPUP)
    GUISetBkColor($Branco)

    GUICtrlCreateLabel("Sales Description", 24, 34, 380, 34)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial Black")

    GUICtrlCreateGroup(" Date ", 512, 42, 89, 33)
    GUICtrlCreateLabel(@MDAY & "/" & @MON & "/" & @YEAR, 518, 56, 80, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Name ", 24, 82, 385, 33)
    GUICtrlCreateLabel($Str1, 30, 96, 372, 16)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" CPF/CNPJ ", 416, 82, 185, 33)
    If $rCli[29] = "none" Then $rCli[29] = ""
    GUICtrlCreateLabel($rCli[29], 422, 96, 172, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Adddress ", 24, 122, 297, 33)

    Local $EndNum
    Select
        Case $rCli[0] <> "none" And $rCli[1] <> "none"
            $EndNum = $rCli[0] & ", " & $rCli[1]
        Case $rCli[0] <> "none" And $rCli[1] = "none"
            $EndNum = $rCli[0] & ", SN"
        Case Else
            $EndNum = ""
    EndSelect
    GUICtrlCreateLabel($EndNum, 30, 136, 284, 16)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" District ", 328, 122, 169, 33)
    If $rCli[2] = "none" Then $rCli[2] = ""
    GUICtrlCreateLabel($rCli[2], 332, 136, 160, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Zip ", 504, 122, 97, 33)
    If $rCli[5] = "none" Then $rCli[5] = ""
    GUICtrlCreateLabel($rCli[5], 508, 136, 88, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" County ", 24, 162, 185, 33)
    If $rCli[3] = "none" Then $rCli[3] = ""
    GUICtrlCreateLabel($rCli[3], 30, 176, 174, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" UF ", 216, 162, 49, 33)
    If $rCli[4] = "none" Then $rCli[4] = ""
    GUICtrlCreateLabel($rCli[4], 220, 176, 40, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" Phone ", 272, 162, 129, 33)
    If $rCli[18] = "none" Then $rCli[18] = "    "
    If $rCli[19] = "none" Then $rCli[19] = "                  "
    GUICtrlCreateLabel("(" & $rCli[18] & ")" & "  " & $rCli[19], 276, 176, 120, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateGroup(" State Registration ", 408, 162, 193, 33)
    GUICtrlSetFont(-1, 10, 400, 2, "", 5)

    GUICtrlCreateLabel("Quantity", 24, 234, 72, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Weight", 102, 234, 55, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Unit", 163, 234, 55, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Description", 224, 234, 206, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Unitary Value", 436, 234, 81, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateLabel("Total", 522, 234, 78, 16, $SS_CENTER)
    GUICtrlSetFont(-1, 9, 400, 0, "Calibri", 5)
    GUICtrlSetbkColor(-1, $Cinza2)

    GUICtrlCreateGroup("", 24, 248, 73, 444)
    GUICtrlCreateGroup("", 102, 248, 56, 444)
    GUICtrlCreateGroup("", 163, 248, 56, 444)
    GUICtrlCreateGroup("", 224, 248, 207, 444)
    GUICtrlCreateGroup("", 436, 248, 81, 444)
    GUICtrlCreateGroup("", 522, 248, 79, 444)
    GUICtrlCreateGroup("", 456, 704, 125, 33)

    GUICtrlCreateLabel("Value", 370, 715, 80, 17)
    GUICtrlSetFont(-1, 10, 600, 0, "Calibri", 5)
    GUICtrlCreateLabel("R$ " & StringFormat("%.2f", $Str2), 460, 714, 116, 17, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 600, 0, "Calibri", 5)

    GUISetState(@SW_SHOW)
    Imprimir_Pedido()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc

; Captura o print da janela
Func Imprimir_Pedido()
    ; Variáveis usadas na impressão
    Local $hPrinter
    Local $Jpg = @ScriptDir & "\NotaIMG.jpg"
    Global $hDll = @ScriptDir & "\PrintMG.dll"; abre a DLL
    Local $pgwd = 2020; ; Largura da imagem
    Local $pght = 2880; Altura da imagem

    ; Capture window
    _ScreenCapture_CaptureWnd($Jpg, $GuiPedido, 0, 0, -1, -1, False)

    $hPrinter = _PrintDllStart($hDll); abre as funções da DLL em $hPrinter

    _PrintPageOrientation($hPrinter, 1) ; Define 0 horizontal ou 1 vertical
    _PrintStartPrint($hPrinter) ; Inicia a impressão
    _PrintImage($hPrinter, $Jpg, 0, 0, $pgwd, $pght) ; Imprime a imagem
    _PrintEndPrint($hPrinter) ; Finaliza a impressão
EndFunc

@Luigi Very good your example, it is basically what I do the same ... I will take a study in code. thank you.

 

@AndyG yes cleartype used in labels, did not know it was generating subpixels in the sources :(

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...