ProgAndy Posted December 24, 2008 Posted December 24, 2008 (edited) GDI UDFs - Alpha releaseThis is a collection of the GDI functions listed in MSDN. From time to time I will add new functions and add descriptions to the undocumented functions.Some of the functions already exist in WinAPI.au3, but I want to include all functions listed on MSDN as GDI.The functions are written by Greenhorn, me and some copied from WinAPI.au3 (Gary Frost, Paul Campbell (PaulIA), Zedna) or the forum.The donwload is located here:GDI UDFs Downloads:To inlcude the UDFs you have 2 possibilities:-just include GDI.au3 and all functions are accesible-or inlcude GDIBase.au3, the GDIConstants.au3, GDIStructures.au3 and the Scripts from the GDI-subfolder as you need them (less overhead).thanks to all helping me with these UDfs and merry x-mas Edited March 29, 2012 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Kip Posted December 24, 2008 Posted December 24, 2008 That are a lot of functions. I'm sure they'll be used a lot. Thanks MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Zedna Posted December 24, 2008 Posted December 24, 2008 Thanks ProgAndy. I will definitely look at it. Resources UDF ResourcesEx UDF AutoIt Forum Search
ProgAndy Posted December 25, 2008 Author Posted December 25, 2008 (edited) Here is an example to print a Textfile / text in a EditBox: expandcollapse popup#include<GDI\GDI.au3> #include<Memory.au3> #include<Misc.au3> ;------------------------------------- ; GUI to get text GUICreate("Your text to print",400,440) $Edit = GUICtrlCreateEdit("",0,0,400,400) $BTN = GUICtrlCreateButton("OK",10,405,80,30) $Select = GUICtrlCreateButton("... Choose File",100,405,80,30) GUISetState() While 1 $nMSG = GUIGetMsg() Switch $nMSG Case -3 ; $GUI_EVENT_CLOSE Exit ; exit Case $BTN ExitLoop ; Exit GUI loop and start to print Case $Select ; choose a textfile $Path = FileOpenDialog("Open Textfile",@MyDocumentsDir,"Text (*.txt)|All (*.*)","",3) If Not @error Then GUICtrlSetData($Edit,FileRead($Path)) EndSwitch WEnd GUISetState(@SW_HIDE) ; End GUI --------------------------------------- ; Get text to print Global Const $PRINTTEXT = GUICtrlRead($Edit) ; Printing SplashTextOn("Printing...","Printing text",200,50,10,10,16,"",12,1000) ; show Printer dialog $PrinterStruct = _GDI_PrintDlg() If @error Then ; on error free all memory possibly allocated by _GDI_PrintDlg If DllStructGetData($PrinterStruct, "hDC") Then _GDI_DeleteDC(DllStructGetData($PrinterStruct, "hDC")) _MemGlobalFree(DllStructGetData($PrinterStruct, 3)) _MemGlobalFree(DllStructGetData($PrinterStruct, 4)) Exit ; then Exit EndIf ; get the DC handle for Printer DC Local $pDC = DllStructGetData($PrinterStruct, "hDC") If $pDC Then ; If it is a valid DC then print $TotalHeight = _GDI_GetDeviceCaps($pDC, $PHYSICALHEIGHT) ; the total height of the page in pixels $TotalWidth = _GDI_GetDeviceCaps($pDC, $PHYSICALWIDTH) ; the total wodth in pixels $PrintOffsetX = _GDI_GetDeviceCaps($pDC, $PHYSICALOFFSETX) ; x-offset of printable area $PrintOffsetY = _GDI_GetDeviceCaps($pDC, $PHYSICALOFFSETY) ; y-offset of printable area $PrintableWidth = _GDI_GetDeviceCaps($pDC, $HORZRES) ; the printable width $PrintableHeight = _GDI_GetDeviceCaps($pDC, $VERTRES) ; the printable height If $PrintOffsetX = 0 Then ; at least 50 px border $PrintOffsetX = 50 $PrintableWidth -= 50 EndIf If $PrintOffsetY = 0 Then ; at least 50 px border $PrintOffsetY = 50 $PrintableHeight -= 50 EndIf ; set Info for Document (title shown in Print Spooler) $DocumentInfo = DllStructCreate($tagDOCINFO) DllStructSetData($DocumentInfo, 1, DllStructGetSize($DocumentInfo)) $DocName = _PrintUDF_CreateTextStruct("Test Doc") ; we need an extra struct for the text DllStructSetData($DocumentInfo, "lpszDocName", DllStructGetPtr($DocName)) ; set the text-pointer to the Infostruct ; Structure for printing of multiple pages $DRAWTEXTPARAMS = DllStructCreate($tagDRAWTEXTPARAMS) DllStructSetData($DRAWTEXTPARAMS,1,DllStructGetSize($DRAWTEXTPARAMS)) ; initialise ParamStruct DllStructSetData($DRAWTEXTPARAMS,2,4) ; set size of tabstob to 4 characters ; rectangel in wich to print text $RECT = DllStructCreate($tagRECT) DllStructSetData($RECT,1,$PrintOffsetX) ; left border: x-offset DllStructSetData($RECT,2,$PrintOffsetY) ; top border: y-offset DllStructSetData($RECT,3,$PrintableWidth) ; width: printable width DllStructSetData($RECT,4,$PrintableHeight); width: printable height ; start printing _GDI_StartDoc($pDC, $DocumentInfo) ; Choose a font $Font = _ChooseFont("Arial",12) ;If no font chosen (Cancel), set default values: If Not IsArray($Font) Then Dim $Font[8] = [7,0,"Arial",11,400,0,"000000","000000"] ; set font color _GDI_SetTextColor($pDC,$Font[5]) ; create font and set it as default in printer DC $hFont = _GDI_CreateFont(_FonSizePT($pDC,$Font[3]),0,0,0,$Font[4],BitAND($Font[1],2)=2,BitAND($Font[1],4)=4,BitAND($Font[1],8)=8,1, $OUT_TT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, $Font[2]) $hOldFont = _GDI_SelectObject($pDC,$hFont) ; Get Text to print $Text = $PRINTTEXT ; chack, if text is empty If $Text="" Then If MsgBox(36, 'Warning', "No text to print. Abort?")=6 Then ; if Printing should be aborted, abort it ;) _GDI_AbortDoc($pDC) Else $Text = " "; space, so it will print EndIf EndIf While $Text ; while text is not empty, print a new page _GDI_StartPage($pDC) ; draw the text on the page _GDI_DrawTextEx($pDC,$Text,$RECT,BitOR($DT_WORDBREAK,$DT_NOPREFIX,$DT_TABSTOP,$DT_EDITCONTROL),$DRAWTEXTPARAMS,StringLen($Text)) _GDI_EndPage($pDC) ; remove the drawn text from buffer $Text = StringTrimLeft($Text,DllStructGetData($DRAWTEXTPARAMS,"uiLengthDrawn")) WEnd ; delete font -> clean up resources _GDI_SelectObject($pDC,$hOldFont) _GDI_DeleteObject($hFont) ; end printing, printer can now print your Doc _GDI_EndDoc($pDC) EndIf ; free memory allocated by _GDI_PrintDlg _MemGlobalFree(DllStructGetData($PrinterStruct, 3)) _MemGlobalFree(DllStructGetData($PrinterStruct, 4)) ; calcualte font size for printer (from MSDN) ; by Prog@ndy Func _FonSizePT($pDC, $Pt) Return -_MulDiv($Pt, _GDI_GetDeviceCaps($pDC, $LOGPIXELSY), 72) EndFunc ;==>_FonSizePT ; Function to muliply and divide in ine step, from MSDN ; by Prog@ndy Func _MulDiv($nNumber, $nNumerator, $nDenominator) Local $res = DllCall("Kernel32.dll", "int", "MulDiv", "int", $nNumber, "int", $nNumerator, "int", $nDenominator) If @error Then Return SetError(1, 0, 0) Return $res[0] EndFunc ;==>_MulDiv Edited December 25, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Kip Posted December 25, 2008 Posted December 25, 2008 Not one of the easiest eaxmples MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
ProgAndy Posted December 25, 2008 Author Posted December 25, 2008 Well, i saw multiple posts asking for a way to print long text documents on multiple pages. But you are right is is a bit complicated, so i added some comments *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
ptrex Posted December 25, 2008 Posted December 25, 2008 @ProgAndy Very nice as usual !! But on line 84 of the example is an undefined function : _GDI_AbortDoc($pDC) Should it not be _GDI_EndDoc($pDC) ? Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
ProgAndy Posted December 25, 2008 Author Posted December 25, 2008 (edited) no, this should be abortdoc, but this func is new and not yet included in the download. Will update it in a few minutes. //Edit: updated. Edited December 25, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
FireFox Posted December 26, 2008 Posted December 26, 2008 @ProgAndy Nice UDF (Nice website too) Cheers, FireFox
jennico Posted December 27, 2008 Posted December 27, 2008 (edited) very nice, thank you. very good work.i'm still waiting for someone to write a gdi tutorial. i think progandy is one of the few qualified members here.another idea of mine is to make an UDF for easy creation of basic gdi structures. for example, a _GDI_GUICtrlCreateButton function that includes and combines all the necessary processes. of course, all parameters like text, color, font, background.... must be passed in one command (this might afford a completely new syntax, but why not ?).maybe anyone feels like starting something like that ?cheers j. Edited December 27, 2008 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
Kip Posted December 27, 2008 Posted December 27, 2008 Why would you wanna create a button with the GDI functions? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
WeMartiansAreFriendly Posted November 10, 2009 Posted November 10, 2009 I'm trying to download but I can only download 31 KB of 104.11 KB Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
ProgAndy Posted November 11, 2009 Author Posted November 11, 2009 I'm trying to download but I can only download 31 KB of 104.11 KB Thanks for information. I reuploaded it and now it works for me. Sorry for the corrupted file, I didn't check all downloads after the relaunch of my site. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
WeMartiansAreFriendly Posted November 11, 2009 Posted November 11, 2009 Thanks for information. I reuploaded it and now it works for me. Sorry for the corrupted file, I didn't check all downloads after the relaunch of my site.Thanks for all your hard work and speedy reply. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
stormbreaker Posted March 29, 2012 Posted March 29, 2012 ProgAndy, please re-upload the UDF. The page displays a 404 error. Thanx again ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
Zedna Posted March 29, 2012 Posted March 29, 2012 And on my computer ESET blocked that URL as it's web on list of webs with potentialy dangerous content. Resources UDF ResourcesEx UDF AutoIt Forum Search
ProgAndy Posted March 29, 2012 Author Posted March 29, 2012 AnotherProgAndy, please re-upload the UDF. The page displays a 404 error.Thanx againAnother link I forgot to update. I'll get my old domain back And on my computer ESET blocked that URL as it's web on list of webs with potentialy dangerous content.Strange, i don't know why. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
nicdev007 Posted November 28, 2018 Posted November 28, 2018 Hi there ProgAndy, I know this is an old thread, but I'm trying to print something to a label printer and wanted to use your GDI UDF. Your site seems down or may have changed. Is this UDF still available, useable? Thank you Nicdev Life is too short to worry about the things you don't have or cannot do ... So if you don't know how to do it - Learn it! Don't be afraid to ask for help ...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now