*grins* mal wieder ich. Wie man merkt, es ist Sonntag, Formel 1 ist vorbei und ich hab Zeit.
Also, kommt da ein Problem nach dem anderen
Und zwar im Moment ist es das Drucken. Ich benutze folgende geklaute Funktion (die auch nach einigen Anpassungen funktioniert):
Spoiler anzeigen
Func _Print()
Local $WM_PRINT = 0x317
Local $PRF_CHILDREN = 0x10; Draw all visible child windows.
Local $PRF_CLIENT = 0x4 ; Draw the window's client area.
Local $PRF_OWNED = 0x20 ; Draw all owned windows.
Local $PRF_NONCLIENT = 0x2 ; Draw the window's Title area.
Local $PRF_ERASEBKGND = 0x8 ; Erases the background before drawing the window
Local $hWnd = WinGetHandle("Pflanzen Datenbank") ;ControlGetHandle("Pflanzen Datenbank", "", $listview)
Local $pos = WinGetPos("Pflanzen Datenbank") ;ControlGetPos("Pflanzen Datenbank", "", $listview)
_GDIPlus_Startup()
Local $Width = $pos[2]
Local $Height = $pos[3]
Local $hDC = _WinAPI_GetDC($hWnd)
Local $memDC = _WinAPI_CreateCompatibleDC($hDC)
Local $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height)
_WinAPI_SelectObject($memDC, $memBmp)
Local $Ret = _SendMessage($hWnd, $WM_PAINT, $memDC, 0)
$Ret = _SendMessage($hWnd, $WM_PRINT, $memDC, BitOR($PRF_CHILDREN, $PRF_CLIENT, $PRF_OWNED, $PRF_NONCLIENT, $PRF_ERASEBKGND))
Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($memBmp)
[/autoit] [autoit][/autoit] [autoit];Get Default Printer
Local $s_PrinterName = _GetDefaultPrinter()
; Create a printer device context
Local $hPrintDc = _WinAPI_CreateDC("winspool", $s_PrinterName)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hPrintDc)
; get pixel and twips info
Local $PixelsPerInchY = _WinAPI_GetDeviceCaps($hPrintDc, $__WINAPICONSTANT_LOGPIXELSY); Get Pixels Per Inch Y
Local $TwipsPerPixelY = 1440 / $PixelsPerInchY
Local $PixelsPerInchX = _WinAPI_GetDeviceCaps($hPrintDc, $__WINAPICONSTANT_LOGPIXELSX); Get Pixels Per Inch X
Local $TwipsPerPixelX = 1440 / $PixelsPerInchX
; get page width and height
Local $PageWidth = _WinAPI_GetDeviceCaps($hPrintDc, $HORZRES); Get width, in millimeters, of the physical screen
Local $PageHeight = _WinAPI_GetDeviceCaps($hPrintDc, $VERTRES); Get height, in millimeters, of the physical screen.
; set docinfo
Local $s_DocName = "Printing from AutoIt with WinAPI"
Local $DocName = DllStructCreate("char DocName[" & StringLen($s_DocName & Chr(0)) & "]")
DllStructSetData($DocName, "DocName", $s_DocName & Chr(0)); Size of DOCINFO structure
Local $DOCINFO = DllStructCreate($tagDOCINFO); Structure for Print Document info
DllStructSetData($DOCINFO, "Size", 20); Size of DOCINFO structure
DllStructSetData($DOCINFO, "DocName", DllStructGetPtr($DocName)); Set name of print job (Optional)
; start new print doc
Local $result = _WinAPI_StartDoc($hPrintDc, $DOCINFO)
; start new page
$result = _WinAPI_StartPage($hPrintDc)
; Draw one image in another
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 50, 100, $Width, $Height)
; Draw a frame around the inserted image
_GDIPlus_GraphicsDrawRect($hGraphic, 50, 100, $Width, $Height)
; ------------------------ End of Story -----------------------
; End the page
$result = _WinAPI_EndPage($hPrintDc)
; End the print job
$result = _WinAPI_EndDoc($hPrintDc)
; Delete the printer device context
_WinAPI_DeleteDC($hPrintDc)
; End Rest of Resources
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_WinAPI_ReleaseDC($hWnd, $hDC)
_WinAPI_DeleteDC($memDC)
_WinAPI_DeleteObject($memBmp)
_GDIPlus_Shutdown()
EndFunc ;==>_Print
;------------------------------ Get Default printer --------------------------------
Func _GetDefaultPrinter()
Local $szDefPrinterName
Local $Size
Local $namesize = DllStructCreate("dword")
DllCall("winspool.drv", "int", "GetDefaultPrinter", "str", '', "ptr", DllStructGetPtr($namesize))
Local $pname = DllStructCreate("char[" & DllStructGetData($namesize, 1) & "]")
DllCall("winspool.drv", "int", "GetDefaultPrinter", "ptr", DllStructGetPtr($pname), "ptr", DllStructGetPtr($namesize))
Return DllStructGetData($pname, 1);
;~ msgbox(0,dllstructgetdata($namesize,1),DllStructGetData($pname,1))
EndFunc ;==>_GetDefaultPrinter
Hat einer eine Ahnung, wie man damit im Querformat drucken kann?
Eine Frage zur Funktion:
Original Text:
[autoit]
Local $PixelsPerInchY = _WinAPI_GetDeviceCaps($hPrintDc, $__WINAPCONSTANT_LOGPIXELSY); Get Pixels Per Inch Y
Local $PixelsPerInchX = _WinAPI_GetDeviceCaps($hPrintDc, $__WINAPCONSTANT_LOGPIXELSX); Get Pixels Per Inch X
Damit bekomme ich Fehlermeldungen von Scite. Gehe ich richtig in der Annahme, das __WINAPCONSTANT_LOGPIXELSY eigentlich __WINAPICONSTANT_LOGPIXELSY heisen sollte ? Die Funktion geistert durch einige Beiträge mit diesem Fehler (evtl.) aber keiner sagt was dazu.