Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

GDI UDFs


  • Please log in to reply
16 replies to this topic

#1 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 24 December 2008 - 02:10 PM

GDI UDFs - Alpha release
This 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:Posted Image

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 Posted Image

Edited by ProgAndy, 29 March 2012 - 04:51 PM.

*GERMAN* Posted Image [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







#2 Kip

Kip

    Into the JavaScript

  • Active Members
  • PipPipPipPipPipPip
  • 1,690 posts

Posted 24 December 2008 - 02:20 PM

That are a lot of functions. I'm sure they'll be used a lot. Thanks :)

#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,724 posts

Posted 24 December 2008 - 03:45 PM

Thanks ProgAndy.
I will definitely look at it.

#4 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 25 December 2008 - 02:18 PM

Here is an example to print a Textfile / text in a EditBox:
AutoIt         
#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 by ProgAndy, 25 December 2008 - 02:43 PM.

*GERMAN* Posted Image [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

#5 Kip

Kip

    Into the JavaScript

  • Active Members
  • PipPipPipPipPipPip
  • 1,690 posts

Posted 25 December 2008 - 02:24 PM

Not one of the easiest eaxmples :)

#6 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 25 December 2008 - 02:44 PM

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* Posted Image [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

#7 ptrex

ptrex

    Universalist

  • MVPs
  • 2,419 posts

Posted 25 December 2008 - 02:58 PM

@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

#8 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 25 December 2008 - 03:00 PM

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 by ProgAndy, 25 December 2008 - 03:02 PM.

*GERMAN* Posted Image [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

#9 FireFox

FireFox

    It slips through our fingers, like a fist full of sand.

  • MVPs
  • 5,376 posts

Posted 26 December 2008 - 12:28 PM

@ProgAndy
Nice UDF :) (Nice website too)

Cheers,
FireFox

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.

Hardware : Intel® Core™ i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !


#10 jennico

jennico

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 862 posts

Posted 27 December 2008 - 02:14 PM

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 by jennico, 27 December 2008 - 02:18 PM.

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Posted ImageDon't forget this IP: 213.251.145.96

#11 Kip

Kip

    Into the JavaScript

  • Active Members
  • PipPipPipPipPipPip
  • 1,690 posts

Posted 27 December 2008 - 03:56 PM

Why would you wanna create a button with the GDI functions?

#12 WeMartiansAreFriendly

WeMartiansAreFriendly

    Where's the kaboom?

  • Active Members
  • PipPipPipPipPipPip
  • 1,245 posts

Posted 10 November 2009 - 10:33 PM

I'm trying to download but I can only download 31 KB of 104.11 KB

:)
Posted ImageDon't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

#13 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 11 November 2009 - 01:13 PM

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* Posted Image [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

#14 WeMartiansAreFriendly

WeMartiansAreFriendly

    Where's the kaboom?

  • Active Members
  • PipPipPipPipPipPip
  • 1,245 posts

Posted 11 November 2009 - 06:52 PM

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.
Posted ImageDon't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

#15 stormbreaker

stormbreaker

    More wits this time...

  • Active Members
  • PipPipPipPipPipPip
  • 547 posts

Posted 29 March 2012 - 11:15 AM

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


#16 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,724 posts

Posted 29 March 2012 - 11:34 AM

And on my computer ESET blocked that URL as it's web on list of webs with potentialy dangerous content.

#17 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 29 March 2012 - 05:03 PM

Another

ProgAndy, please re-upload the UDF. The page displays a 404 error.

Thanx again

Another link I forgot to update. I'll get my old domain back :oops:

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* Posted Image [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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users