Jump to content

WideBoyDixon

Active Members
  • Posts

    379
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by WideBoyDixon

  1. Hi all, Other commitments have taken me away from this forum but today I had an itch that I needed to scratch and AutoIt came to my rescue. I wanted a quick script to arrange windows on my screen so I wrote the one here. It's probably flawed in many ways but I'll throw it here anyways ... The idea of the script is that you can use [Win]+[Ctrl]+[Numeric Keypad] to position the active window on your screen. Should be self explanatory as the window is positioned in the same place as the numeric keypad key that you use. Opt("MustDeclareVars", 1) Global $hDesktop = WinGetHandle("Program Manager") Global $hDLL = DllOpen("user32.dll") Global $gMonitorInfo = DllStructCreate("int;int[4];int[4];int;char[32]") DllStructSetData($gMonitorInfo, 1, DllStructGetSize($gMonitorInfo)) _SetHotKeys() While 1 Sleep(100) WEnd Func _SetHotKeys() Local $i For $i = 1 To 9 HotKeySet("#^{NUMPAD" & $i & "}", "_MoveWindow") Next HotKeySet("#^{NUMPAD0}", "_Quit") EndFunc ;==>_SetHotKeys Func _MoveWindow() Local $hWnd = WinGetHandle("[ACTIVE]") If $hWnd = $hDesktop Then Return If WinGetTitle($hWnd) = "" Then Return Local $winState = WinGetState($hWnd) If BitAND($winState, 7) <> 7 Then Return If BitAND($winState, 48) <> 0 Then Return Local $rWindow = WinGetPos($hWnd) Local $hMonitor = _GetMonitorFromPoint($rWindow[0], $rWindow[1]) If $hMonitor = 0 Then Return Local $rMonitor = _GetMonitorRect($hMonitor) Local $sKeyPressed = StringMid(@HotKeyPressed, 10, 1) If StringInStr("134679", $sKeyPressed) > 0 Then $rMonitor[2] /= 2 If StringInStr("123789", $sKeyPressed) > 0 Then $rMonitor[3] /= 2 If StringInStr("369", $sKeyPressed) > 0 Then $rMonitor[0] += $rMonitor[2] If StringInStr("123", $sKeyPressed) > 0 Then $rMonitor[1] += $rMonitor[3] WinMove($hWnd, "", $rMonitor[0], $rMonitor[1], $rMonitor[2], $rMonitor[3]) EndFunc ;==>_MoveWindow Func _GetMonitorFromPoint($iX, $iY) Local $aRet = DllCall($hDLL, "hwnd", "MonitorFromPoint", "int", $iX, "int", $iY, "int", 0) Return $aRet[0] EndFunc ;==>_GetMonitorFromPoint Func _GetMonitorRect($hMonitor) Local $aRet = DllCall($hDLL, "int", "GetMonitorInfo", "hwnd", $hMonitor, "ptr", DllStructGetPtr($gMonitorInfo)) Local $aRect[4] For $i = 1 To 4 $aRect[$i - 1] = DllStructGetData($gMonitorInfo, 3, $i) Next $aRect[2] -= $aRect[0] $aRect[3] -= $aRect[1] Return $aRect EndFunc ;==>_GetMonitorRect Func _Quit() DllClose($hDLL) Exit EndFunc ;==>_Quit Have fun. WBD
  2. If might be more useful to compare the strings for how similar they are e.g. "stationary" and "stationery". See my original post here: http://www.autoitscript.com/forum/index.php?showtopic=40843&view=findpost&p=642358 for an implementation of Levenshtein. WBD
  3. Been away from the forums for a while and I'm just looking through some posts when I came across this. Just wanted to say excellent work! WBD
  4. Hi there. Nice work. Although not as comprehensive as your application, you might be able to pick up some other ideas from my "Hot Folders" script which you should be find by searching the forum. Regards, WBD
  5. Nice one! Makes my stock tracker look better without me having to do anything >_< WBD
  6. Sorry! Just found a couple more which I use in order to provide support for translation of my applications: ; =============================================================================================================================== ; _WinAPI_GetLocaleInfo() ; =============================================================================================================================== Global Const $LOCALE_NOUSEROVERRIDE = 0x80000000 ;// do not use user overrides Global Const $LOCALE_USE_CP_ACP = 0x40000000 ;// use the system ACP Global Const $LOCALE_RETURN_NUMBER = 0x20000000 ;// return number instead of string ; The following LCTypes are mutually exclusive in that they may NOT be used in combination with each other. Global Const $LOCALE_ILANGUAGE = 0x00000001 ;// language id Global Const $LOCALE_SLANGUAGE = 0x00000002 ;// localized name of language Global Const $LOCALE_SENGLANGUAGE = 0x00001001 ;// English name of language Global Const $LOCALE_SABBREVLANGNAME = 0x00000003 ;// abbreviated language name Global Const $LOCALE_SNATIVELANGNAME = 0x00000004 ;// native name of language Global Const $LOCALE_ICOUNTRY = 0x00000005 ;// country code Global Const $LOCALE_SCOUNTRY = 0x00000006 ;// localized name of country Global Const $LOCALE_SENGCOUNTRY = 0x00001002 ;// English name of country Global Const $LOCALE_SABBREVCTRYNAME = 0x00000007 ;// abbreviated country name Global Const $LOCALE_SNATIVECTRYNAME = 0x00000008 ;// native name of country Global Const $LOCALE_IDEFAULTLANGUAGE = 0x00000009 ;// default language id Global Const $LOCALE_IDEFAULTCOUNTRY = 0x0000000A ;// default country code Global Const $LOCALE_IDEFAULTCODEPAGE = 0x0000000B ;// default oem code page Global Const $LOCALE_IDEFAULTANSICODEPAGE = 0x00001004 ;// default ansi code page Global Const $LOCALE_IDEFAULTMACCODEPAGE = 0x00001011 ;// default mac code page Global Const $LOCALE_SLIST = 0x0000000C ;// list item separator Global Const $LOCALE_IMEASURE = 0x0000000D ;// 0 = metric, 1 = US Global Const $LOCALE_SDECIMAL = 0x0000000E ;// decimal separator Global Const $LOCALE_STHOUSAND = 0x0000000F ;// thousand separator Global Const $LOCALE_SGROUPING = 0x00000010 ;// digit grouping Global Const $LOCALE_IDIGITS = 0x00000011 ;// number of fractional digits Global Const $LOCALE_ILZERO = 0x00000012 ;// leading zeros for decimal Global Const $LOCALE_INEGNUMBER = 0x00001010 ;// negative number mode Global Const $LOCALE_SNATIVEDIGITS = 0x00000013 ;// native ascii 0-9 Global Const $LOCALE_SCURRENCY = 0x00000014 ;// local monetary symbol Global Const $LOCALE_SINTLSYMBOL = 0x00000015 ;// intl monetary symbol Global Const $LOCALE_SMONDECIMALSEP = 0x00000016 ;// monetary decimal separator Global Const $LOCALE_SMONTHOUSANDSEP = 0x00000017 ;// monetary thousand separator Global Const $LOCALE_SMONGROUPING = 0x00000018 ;// monetary grouping Global Const $LOCALE_ICURRDIGITS = 0x00000019 ;// # local monetary digits Global Const $LOCALE_IINTLCURRDIGITS = 0x0000001A ;// # intl monetary digits Global Const $LOCALE_ICURRENCY = 0x0000001B ;// positive currency mode Global Const $LOCALE_INEGCURR = 0x0000001C ;// negative currency mode Global Const $LOCALE_SDATE = 0x0000001D ;// date separator Global Const $LOCALE_STIME = 0x0000001E ;// time separator Global Const $LOCALE_SSHORTDATE = 0x0000001F ;// short date format string Global Const $LOCALE_SLONGDATE = 0x00000020 ;// long date format string Global Const $LOCALE_STIMEFORMAT = 0x00001003 ;// time format string Global Const $LOCALE_IDATE = 0x00000021 ;// short date format ordering Global Const $LOCALE_ILDATE = 0x00000022 ;// long date format ordering Global Const $LOCALE_ITIME = 0x00000023 ;// time format specifier Global Const $LOCALE_ITIMEMARKPOSN = 0x00001005 ;// time marker position Global Const $LOCALE_ICENTURY = 0x00000024 ;// century format specifier (short date) Global Const $LOCALE_ITLZERO = 0x00000025 ;// leading zeros in time field Global Const $LOCALE_IDAYLZERO = 0x00000026 ;// leading zeros in day field (short date) Global Const $LOCALE_IMONLZERO = 0x00000027 ;// leading zeros in month field (short date) Global Const $LOCALE_S1159 = 0x00000028 ;// AM designator Global Const $LOCALE_S2359 = 0x00000029 ;// PM designator Global Const $LOCALE_ICALENDARTYPE = 0x00001009 ;// type of calendar specifier Global Const $LOCALE_IOPTIONALCALENDAR = 0x0000100B ;// additional calendar types specifier Global Const $LOCALE_IFIRSTDAYOFWEEK = 0x0000100C ;// first day of week specifier Global Const $LOCALE_IFIRSTWEEKOFYEAR = 0x0000100D ;// first week of year specifier Global Const $LOCALE_SDAYNAME1 = 0x0000002A ;// long name for Monday Global Const $LOCALE_SDAYNAME2 = 0x0000002B ;// long name for Tuesday Global Const $LOCALE_SDAYNAME3 = 0x0000002C ;// long name for Wednesday Global Const $LOCALE_SDAYNAME4 = 0x0000002D ;// long name for Thursday Global Const $LOCALE_SDAYNAME5 = 0x0000002E ;// long name for Friday Global Const $LOCALE_SDAYNAME6 = 0x0000002F ;// long name for Saturday Global Const $LOCALE_SDAYNAME7 = 0x00000030 ;// long name for Sunday Global Const $LOCALE_SABBREVDAYNAME1 = 0x00000031 ;// abbreviated name for Monday Global Const $LOCALE_SABBREVDAYNAME2 = 0x00000032 ;// abbreviated name for Tuesday Global Const $LOCALE_SABBREVDAYNAME3 = 0x00000033 ;// abbreviated name for Wednesday Global Const $LOCALE_SABBREVDAYNAME4 = 0x00000034 ;// abbreviated name for Thursday Global Const $LOCALE_SABBREVDAYNAME5 = 0x00000035 ;// abbreviated name for Friday Global Const $LOCALE_SABBREVDAYNAME6 = 0x00000036 ;// abbreviated name for Saturday Global Const $LOCALE_SABBREVDAYNAME7 = 0x00000037 ;// abbreviated name for Sunday Global Const $LOCALE_SMONTHNAME1 = 0x00000038 ;// long name for January Global Const $LOCALE_SMONTHNAME2 = 0x00000039 ;// long name for February Global Const $LOCALE_SMONTHNAME3 = 0x0000003A ;// long name for March Global Const $LOCALE_SMONTHNAME4 = 0x0000003B ;// long name for April Global Const $LOCALE_SMONTHNAME5 = 0x0000003C ;// long name for May Global Const $LOCALE_SMONTHNAME6 = 0x0000003D ;// long name for June Global Const $LOCALE_SMONTHNAME7 = 0x0000003E ;// long name for July Global Const $LOCALE_SMONTHNAME8 = 0x0000003F ;// long name for August Global Const $LOCALE_SMONTHNAME9 = 0x00000040 ;// long name for September Global Const $LOCALE_SMONTHNAME10 = 0x00000041 ;// long name for October Global Const $LOCALE_SMONTHNAME11 = 0x00000042 ;// long name for November Global Const $LOCALE_SMONTHNAME12 = 0x00000043 ;// long name for December Global Const $LOCALE_SMONTHNAME13 = 0x0000100E ;// long name for 13th month (if exists) Global Const $LOCALE_SABBREVMONTHNAME1 = 0x00000044 ;// abbreviated name for January Global Const $LOCALE_SABBREVMONTHNAME2 = 0x00000045 ;// abbreviated name for February Global Const $LOCALE_SABBREVMONTHNAME3 = 0x00000046 ;// abbreviated name for March Global Const $LOCALE_SABBREVMONTHNAME4 = 0x00000047 ;// abbreviated name for April Global Const $LOCALE_SABBREVMONTHNAME5 = 0x00000048 ;// abbreviated name for May Global Const $LOCALE_SABBREVMONTHNAME6 = 0x00000049 ;// abbreviated name for June Global Const $LOCALE_SABBREVMONTHNAME7 = 0x0000004A ;// abbreviated name for July Global Const $LOCALE_SABBREVMONTHNAME8 = 0x0000004B ;// abbreviated name for August Global Const $LOCALE_SABBREVMONTHNAME9 = 0x0000004C ;// abbreviated name for September Global Const $LOCALE_SABBREVMONTHNAME10 = 0x0000004D ;// abbreviated name for October Global Const $LOCALE_SABBREVMONTHNAME11 = 0x0000004E ;// abbreviated name for November Global Const $LOCALE_SABBREVMONTHNAME12 = 0x0000004F ;// abbreviated name for December Global Const $LOCALE_SABBREVMONTHNAME13 = 0x0000100F ;// abbreviated name for 13th month (if exists) Global Const $LOCALE_SPOSITIVESIGN = 0x00000050 ;// positive sign Global Const $LOCALE_SNEGATIVESIGN = 0x00000051 ;// negative sign Global Const $LOCALE_IPOSSIGNPOSN = 0x00000052 ;// positive sign position Global Const $LOCALE_INEGSIGNPOSN = 0x00000053 ;// negative sign position Global Const $LOCALE_IPOSSYMPRECEDES = 0x00000054 ;// mon sym precedes pos amt Global Const $LOCALE_IPOSSEPBYSPACE = 0x00000055 ;// mon sym sep by space from pos amt Global Const $LOCALE_INEGSYMPRECEDES = 0x00000056 ;// mon sym precedes neg amt Global Const $LOCALE_INEGSEPBYSPACE = 0x00000057 ;// mon sym sep by space from neg amt Global Const $LOCALE_FONTSIGNATURE = 0x00000058 ;// font signature Global Const $LOCALE_SISO639LANGNAME = 0x00000059 ;// ISO abbreviated language name Global Const $LOCALE_SISO3166CTRYNAME = 0x0000005A ;// ISO abbreviated country name Global Const $LOCALE_IDEFAULTEBCDICCODEPAGE = 0x00001012 ;// default ebcdic code page Global Const $LOCALE_IPAPERSIZE = 0x0000100A ;// 0 = letter, 1 = a4, 2 = legal, 3 = a3 Global Const $LOCALE_SENGCURRNAME = 0x00001007 ;// english name of currency Global Const $LOCALE_SNATIVECURRNAME = 0x00001008 ;// native name of currency Global Const $LOCALE_SYEARMONTH = 0x00001006 ;// year month format string Global Const $LOCALE_SSORTNAME = 0x00001013 ;// sort name Global Const $LOCALE_IDIGITSUBSTITUTION = 0x00001014 ;// 0 = none, 1 = context, 2 = native digit ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetLocaleInfo ; Description ...: Gets local specific info ; Syntax.........: _WinAPI_GetLocaleInfo($iLocale, $iLCType) ; Parameters ....: $iLocale - Identifies a valid Windows locale ; $iLCType - Identifies the information to be retrieved ; Return values .: Success - String containing the requested information ; Failure - Empty string with @error set to 1 ; Author ........: WideBoyDixon ; Modified.......: ; Remarks .......: ; Related .......: _WinAPI_GetUserDefaultLCID ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _WinAPI_GetLocaleInfo($iLocale, $iLCType) Local $aResult = DllCall("kernel32.dll", "long", "GetLocaleInfo", "long", $Locale, "long", $LCType, "ptr", 0, "long", 0) If @error Then Return SetError(1, 0, "") Local $lpBuffer = DllStructCreate("char[" & $aResult[0] & "]") $aResult = DllCall("kernel32.dll", "long", "GetLocaleInfo", "long", $Locale, "long", $LCType, "ptr", DllStructGetPtr($lpBuffer), "long", $aResult[0]) If @error Or ($aResult[0] = 0) Then Return SetError(1, 0, "") Return SetError(0, 0, DllStructGetData($lpBuffer, 1)) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetUserDefaultLCID ; Description ...: Gets local specific info ; Syntax.........: _WinAPI_GetUserDefaultLCID() ; Parameters ....: ; Return values .: Success - The default LCID for the user ; Failure - Zero with @error set to 1 ; Author ........: WideBoyDixon ; Modified.......: ; Remarks .......: ; Related .......: _WinAPI_GetLocaleInfo ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _WinAPI_GetUserDefaultLCID() Local $aResult = DllCall("kernel32.dll", "long", "GetUserDefaultLCID") ; Get the default LCID for this user If @error Then Return SetError(1, 0, 0) Return SetError(0, 0, $aResult[0]) EndFunc Would be great to have those in there too WBD
  7. This is fantastic! Can't remember which ones I'm getting credit for but that's old age for you. A couple of possible additions: ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetLocalTime ; Description ...: Gets the local time ; Syntax.........: _WinAPI_GetLocalTime() ; Parameters ....: ; Return values .: Success - Array with eight values ; 0 - Year ; 1 - Month ; 2 - Day of week ; 3 - Day ; 4 - Hour ; 5 - Minute ; 6 - Second ; 7 - Milliseconds ; Author ........: WideBoyDixon ; Modified.......: ; Remarks .......: ; Related .......: _WinAPI_GetSystemTime ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _WinAPI_GetLocalTime() Local $aRet[8], $SystemTime = DllStructCreate("ushort[8]") DllCall("kernel32.dll", "none", "GetLocalTime", "ptr", DllStructGetPtr($SystemTime)) For $i = 1 To 8 $aRet[$i - 1] = DllStructGetData($SystemTime, 1, $i) Next Return $aRet EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetSystemTime ; Description ...: Gets the system time ; Syntax.........: _WinAPI_GetSystemTime() ; Parameters ....: ; Return values .: Success - Array with eight values ; 0 - Year ; 1 - Month ; 2 - Day of week ; 3 - Day ; 4 - Hour ; 5 - Minute ; 6 - Second ; 7 - Milliseconds ; Author ........: WideBoyDixon ; Modified.......: ; Remarks .......: ; Related .......: _WinAPI_GetLocalTime ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _WinAPI_GetSystemTime() Local $aRet[8], $SystemTime = DllStructCreate("ushort[8]") DllCall("kernel32.dll", "none", "GetSystemTime", "ptr", DllStructGetPtr($SystemTime)) For $i = 1 To 8 $aRet[$i - 1] = DllStructGetData($SystemTime, 1, $i) Next Return $aRet EndFunc WBD
  8. I'm being kept busy on other projects so I don't have time to polish this in to a releasable state. As such, I'm making the source code available. See the first post for the link to a ZIP which contains the code. It would be great if someone can think of a better way to add stock symbols in to the application. WBD
  9. I think you're missing this line from the script. Global Const $Anim_Hide = 0x00010000 WBD
  10. I didn't draw them. I took them from the original code that I converted. That would kinda delete the purpose of using GDI+ to rotate the hands of the clock. WBD
  11. [2] and [4] have been done. The link in the first post has been updated. WBD
  12. Thanks for all the feedback. I'll be working on improving this over the coming weeks. I'm looking to do the following: [1] Make it easier to add stock symbols hopefully something like http://www.google.com/finance [2] Clean up the memory leaks that I found today! [3] Consider some global resizing (as per picea892's suggestion) [4] Allow configuration of the refresh interval (currently 5 minutes) In addition, I'll be looking at incorporating some kind of software protection (possibly home grown) but I'm not certain how to do this just yet. As for the API, I'm just downloading a CSV with the appropriate information based on documentation that I found through Google. See, for example, here: http://www.gummy-stuff.org/Yahoo-data.htm Regards, WBD
  13. Whoooops!! Totally forgot to mention that I owe a big thanks to Yashied for using his excellent ColorPicker UDF library. WBD
  14. Hi all, I've been working on this for a while now so I thought I'd put it out there. I've now put the source code here for those who'd be interested. Anyway, the application is a stock tracker written in AutoIt3 using GDI+ to display the stock information. It uses the Yahoo! finance API to retrieve the stock prices etc. and it updates the stocks every five minutes. The coding that took the most time was making the UI completely customizable. The size of the UI and all the fonts and colours can be changed in the options dialog. Feel free to pass comments as you see fit. It would be great to get some feedback but I know some people just won't run it The application can be downloaded from here WBD
  15. It's working with the new example. I have no idea why it wasn't working before. As I said, the function was returning @error = 0. WBD
  16. I tried it at work also. No changes. Both are running XP SP2. The function returns zero (success?) but the buttons look the same. WBD
  17. I'm not sure what I'm doing wrong. I definitely have gdiplus.dll installed. However, both your examples make no change to the button controls :-/ WBD
  18. I had a quick look around and couldn't find this anywhere so I'm posting up some code. This allows you to drag-and-drop the items in the listbox in order to reorder them. A nice UI touch when you want users to have the ability to do this. I'm writing something right now that will use this but thought I'd put this code here in case someone wants to use it. #include <Constants.au3> #include <GUIListBox.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $gnDRAGLISTMSGSTRING = _WinAPI_RegisterWindowMessage("commctrl_DragListMsg") Global $DL_BEGINDRAG = $WM_USER + 133 Global $DL_DRAGGING = $WM_USER + 134 Global $DL_DROPPED = $WM_USER + 135 Global $DL_CANCELDRAG = $WM_USER + 136 Global Enum $DL_STOPCURSOR = 1, $DL_COPYCURSOR, $DL_MOVECURSOR Global $gtDRAGLISTINFO = "long uNotification;long hWnd;long x;long y" Global $gfItemAdded = False Global $hMain = GUICreate("DragList", 200, 400) Global $cListbox = GUICtrlCreateList("", 16, 16, 168, 368, $WS_BORDER + $WS_VSCROLL) GUICtrlSetFont($cListbox, 10, Default, Default, "Tahoma") Global $hListbox = GUICtrlGetHandle($cListbox) GUICtrlSetData($cListbox, "Apples|Oranges|Bananas|Pears|Grapefruits|Limes|Lemons|Strawberries|Plums|Melons|Grapes|") GUISetState() _ComCtl32_MakeDragList($hListbox) Global $wProcNew = DllCallbackRegister("_MyWndProc", "int", "hwnd;int;wparam;lparam") Global $wProcOld = _WinAPI_SetWindowLong($hMain, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew)) While GUIGetMsg() <> -3 Sleep(10) Wend Exit Func _MyWndProc($hWnd, $nMsg, $wParam, $lParam) Local $aRet, $nOldIndex, $sItemText If $nMsg = $gnDRAGLISTMSGSTRING Then Local $tDRAGLISTINFO = DllStructCreate($gtDRAGLISTINFO, $lParam) Local $uNotification = DllStructGetData($tDRAGLISTINFO, "uNotification") Local $x = DllStructGetData($tDRAGLISTINFO, "x"), $y = DllStructGetData($tDRAGLISTINFO, "y") Local $nItem = _ComCtl32_LBItemFromPt($hListbox, $x, $y) Switch $uNotification Case $DL_BEGINDRAG If $nItem < (_GUICtrlListBox_GetCount($hListbox) - 1) Then _GUICtrlListBox_AddString($hListbox, "") $gfItemAdded = True EndIf Return 1 Case $DL_DRAGGING _ComCtl32_DrawInsert($hMain, $hListbox, $nItem) If $nItem = _GUICtrlListBox_GetCurSel($hListbox) Then Return $DL_STOPCURSOR Return $DL_MOVECURSOR Case $DL_DROPPED If $nItem > -1 Then $nOldIndex = _GUICtrlListBox_GetCurSel($hListbox) If $nItem <> $nOldIndex Then $sItemText = _GUICtrlListBox_GetText($hListbox, $nOldIndex) If $nItem < $nOldIndex Then $nOldIndex += 1 _GUICtrlListBox_InsertString($hListbox, $sItemText, $nItem) _GUICtrlListBox_DeleteString($hListbox, $nOldIndex) If $nItem > $nOldIndex Then $nItem -= 1 _GUICtrlListBox_SetCurSel($hListbox, $nItem) EndIf EndIf If $gfItemAdded Then _GUICtrlListBox_DeleteString($hListbox, _GUICtrlListBox_GetCount($hListbox) - 1) $gfItemAdded = False EndIF _ComCtl32_DrawInsert($hMain, $hListbox, -1) Return 0 Case $DL_CANCELDRAG If $gfItemAdded Then _GUICtrlListBox_DeleteString($hListbox, _GUICtrlListBox_GetCount($hListbox) - 1) $gfItemAdded = False EndIF _ComCtl32_DrawInsert($hMain, $hListbox, -1) Return 0 EndSwitch EndIf Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $nMsg, $wParam, $lParam) EndFunc Func _ComCtl32_MakeDragList($hWnd) Local $aRet = DllCall("comctl32.dll", "int", "MakeDragList", "hwnd", $hWnd) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _ComCtl32_LBItemFromPt($hWnd, $x, $y) Local $aRet = DllCall("comctl32.dll", "long", "LBItemFromPt", "hwnd", $hWnd, "long", $x, "long", $y, "long", 1) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _ComCtl32_DrawInsert($hWndParent, $hWnd, $nItem) DllCall("comctl32.dll", "none", "DrawInsert", "hwnd", $hWndParent, "hwnd", $hWnd, "long", $nItem) If @error Then Return SetError(@error, @extended, 0) Return EndFunc Enjoy. WBD
  19. Another excellent piece of work! Any chance that you could add the ability to filter the fonts. For example, sometimes I'm looking for a script font so I'd like to see only those that contain the word "script". Anyways, 5* from me for a really professional looking script. WBD
  20. Thanks for all the comments. See the original post for a new version which does proper GDI+ drawing of the pie pieces instead of "cheating". There's also the possibility to display a 2D "donut" chart with a configurable hole size WBD
  21. I was toying around with owner-drawn buttons and I wanted a GDI+ function to draw a rectangle with rounded corners. Once I got over the shock of realising that one didn't exist, I wrote my own. #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hWndMain = GUICreate("Rounded Rectangles", 400, 400) GUISetState() Global $hDC = _WinAPI_GetDC($hWndMain) Global $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Global $hBrush = _GDIPlus_BrushCreateSolid(0xffffc080) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4) GUIRegisterMsg($WM_PAINT, "_OnPaint") _OnPaint($hwndMain, 0, 0, 0) While GUIGetMsg() <> -3 Sleep(10) WEnd _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_ReleaseDC($hWndMain, $hDC) _GDIPlus_Shutdown() Func _OnPaint($hWnd, $nMsg, $wParam, $lParam) If $hWnd = $hWndMain Then _GDIPlus_GraphicsClear($hGraphics, 0xffffffff) _GDIPlus_GraphicsDrawRoundRect($hGraphics, 8, 8, 384, 100, 16, $hBrush) _GDIPlus_GraphicsDrawRoundRect($hGraphics, 8, 116, 384, 80, 20) _GDIPlus_GraphicsDrawRoundRect($hGraphics, 8, 204, 188, 188, 20, $hBrush) _GDIPlus_GraphicsDrawRoundRect($hGraphics, 204, 204, 188, 188, 60) EndIf EndFunc Func _GDIPlus_GraphicsDrawRoundRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius, $hBrush = 0, $hPen = 0) _GDIPlus_PenDefCreate($hPen) Local $hPath = _GDIPlus_GraphicsPathCreate() _GDIPlus_GraphicsPathAddLine($hPath, $iX + $iRadius, $iY, $iX + $iWidth - ($iRadius * 2), $iY) _GDIPlus_GraphicsPathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_GraphicsPathAddLine($hPath, $iX + $iWidth, $iY + $iRadius, $iX + $iWidth, $iY + $iHeight - ($iRadius * 2)) _GDIPlus_GraphicsPathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_GraphicsPathAddLine($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight, $iX + $iRadius, $iY + $iHeight) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_GraphicsPathAddLine($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iX, $iY + $iRadius) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_GraphicsPathCloseFigure($hPath) If $hBrush <> 0 Then _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hPath) _GDIPlus_GraphicsPathDispose($hPath) _GDIPlus_PenDefDispose() EndFunc Func _GDIPlus_GraphicsPathCreate($iFillMode = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $iFillMode, "int*", 0); If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[2]) EndFunc Func _GDIPlus_GraphicsPathAddLine($hGraphicsPath, $iX1, $iY1, $iX2, $iY2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine", "hwnd", $hGraphicsPath, "float", $iX1, "float", $iY1, _ "float", $iX2, "float", $iY2) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc Func _GDIPlus_GraphicsPathAddArc($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _ "float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc Func _GDIPlus_GraphicsPathCloseFigure($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc Func _GDIPlus_GraphicsPathDispose($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc Func _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphics, "hwnd", $hPen, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc Func _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphics, "hwnd", $hBrush, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc
  22. I just tidied up the code a bit. Modified code now in the first post. No significant changes except I'm a bit happier with this version. WBD
  23. tobase ($decimal, $base, $pad) $decimal = number to convert $base = base to convert to $pad = minimum number of characters in the output E.g. If tobase(255, 16, 4) = "00FF" Then MsgBox(64, "Test", "Working!") frombase($number, $base) $number = string representation of the number in base form (e.g. "00ff") $base = base that the number is encoded in E.g. If frombase("00FF", 16) = 255 Then MsgBox(64, "Test", "Working again!") HTH. WBD.
  24. I've revamped this so that it doesn't "cheat" any more but instead creates a fills paths properly. This should be a bit quicker to draw and the result looks a bit nicer I think. In addition, I've added the capability to display the pie as a 2D donut with a configurable hole size in the middle. The sliders at the bottom can be used to rotate the pie chart and also to change the aspect (but not for a donut). The third slider changes the hole size. #include <GDIPlus.au3> #include <WinAPI.au3> #include <GUISlider.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> ; Let's be strict here Opt("MustDeclareVars", 1) ; Controls the size of the pie and also the depth Global Const $PIE_DIAMETER = 400 Global Const $PIE_MARGIN = $PIE_DIAMETER * 0.025 Global Const $PIE_DEPTH = $PIE_DIAMETER * 0.2 Global Const $PIE_AREA = $PIE_DIAMETER + 2 * $PIE_MARGIN ; Random data for values and colours Global Const $NUM_VALUES = 8 Global $aChartValue[$NUM_VALUES] Global $aChartColour[$NUM_VALUES] For $i = 0 To $NUM_VALUES - 1 $aChartValue[$i] = Random(5, 25, 1) $aChartColour[$i] = (Random(0, 255, 1) * 0x10000) + (Random(0, 255, 1) * 0x100) + Random(0, 255, 1) Next ; The value of PI Global Const $PI = ATan(1) * 4 ; Start GDI+ _GDIPlus_Startup() ; Create the brushes and pens Global $ahBrush[$NUM_VALUES][2], $ahPen[$NUM_VALUES] For $i = 0 To $NUM_VALUES - 1 $ahBrush[$i][0] = _GDIPlus_BrushCreateSolid(BitOR(0xff000000, $aChartColour[$i])) $ahBrush[$i][1] = _GDIPlus_BrushCreateSolid(BitOR(0xff000000, _GetDarkerColour($aChartColour[$i]))) $ahPen[$i] = _GDIPlus_PenCreate(BitOR(0xff000000, _GetDarkerColour(_GetDarkerColour($aChartColour[$i])))) Next ; Create the GUI with sliders to control the aspect, rotation, style and hole size (for donuts) Global $hWnd = GUICreate("Pie Chart", $PIE_AREA, $PIE_AREA + 100, Default, Default) Global $hSlideAspect = _GUICtrlSlider_Create($hWnd, $PIE_MARGIN, $PIE_AREA + 10, $PIE_DIAMETER, 20) _GUICtrlSlider_SetRange($hSlideAspect, 10, 100) _GUICtrlSlider_SetPos($hSlideAspect, 50) Global $hSlideRotation = _GUICtrlSlider_Create($hWnd, $PIE_MARGIN, $PIE_AREA + 40, $PIE_DIAMETER, 20) _GUICtrlSlider_SetRange($hSlideRotation, 0, 360) Global $cStyle = GUICtrlCreateCheckbox("Donut", $PIE_MARGIN, $PIE_AREA + 70, $PIE_DIAMETER / 2 - $PIE_MARGIN, 20) Global $hStyle = GUICtrlGetHandle($cStyle) Global $hHoleSize = _GUICtrlSlider_Create($hWnd, $PIE_MARGIN + $PIE_DIAMETER / 2, $PIE_AREA + 70, $PIE_DIAMETER / 2, 20) _GUICtrlSlider_SetRange($hHoleSize, 2, $PIE_DIAMETER - 4 * $PIE_MARGIN) _GUICtrlSlider_SetPos($hHoleSize, $PIE_DIAMETER / 2) GUISetState() ; Set up GDI+ Global $hDC = _WinAPI_GetDC($hWnd) Global $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($PIE_AREA, $PIE_AREA, $hGraphics) Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2) ; Draw the initial pie chart _DrawPie($aChartValue, _GUICtrlSlider_GetPos($hSlideAspect) / 100, _ _GUICtrlSlider_GetPos($hSlideRotation), _ (GUICtrlRead($cStyle) = $GUI_CHECKED), _ _GUICtrlSlider_GetPos($hHoleSize)) ; The sliders will send WM_NOTIFY messages GUIRegisterMsg($WM_NOTIFY, "_OnNotify") ; Wait until the user quits While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd ; Release the resources For $i = 0 To UBound($aChartColour) - 1 _GDIPlus_PenDispose($ahPen[$i]) _GDIPlus_BrushDispose($ahBrush[$i][0]) _GDIPlus_BrushDispose($ahBrush[$i][1]) Next _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_ReleaseDC($hWnd, $hDC) ; Shut down GDI+ _GDIPlus_Shutdown() ; Done Exit ; Get a darker version of a colour by extracting the RGB components Func _GetDarkerColour($Colour) Local $Red, $Green, $Blue $Red = (BitAND($Colour, 0xff0000) / 0x10000) - 40 $Green = (BitAND($Colour, 0x00ff00) / 0x100) - 40 $Blue = (BitAND($Colour, 0x0000ff)) - 40 If $Red < 0 Then $Red = 0 If $Green < 0 Then $Green = 0 If $Blue < 0 Then $Blue = 0 Return ($Red * 0x10000) + ($Green * 0x100) + $Blue EndFunc ;==>_GetDarkerColour ; Draw the pie chart Func _DrawPie($Percentage, $Aspect, $rotation, $style = 0, $holesize = 100) If $style <> 0 Then $Aspect = 1 Local $nCount, $nTotal = 0, $angleStart, $angleSweep, $X, $Y Local $pieLeft = $PIE_MARGIN, $pieTop = $PIE_AREA / 2 - ($PIE_DIAMETER / 2) * $Aspect Local $pieWidth = $PIE_DIAMETER, $pieHeight = $PIE_DIAMETER * $Aspect, $hPath ; Total up the values For $nCount = 0 To UBound($Percentage) - 1 $nTotal += $Percentage[$nCount] Next ; Set the fractional values For $nCount = 0 To UBound($Percentage) - 1 $Percentage[$nCount] /= $nTotal Next ; Make sure we don't over-rotate $rotation = Mod($rotation, 360) ; Clear the graphics buffer _GDIPlus_GraphicsClear($hBuffer, 0xffc0c0c0) ; Set the initial angles based on the fractional values Local $Angles[UBound($Percentage) + 1] For $nCount = 0 To UBound($Percentage) If $nCount = 0 Then $Angles[$nCount] = $rotation Else $Angles[$nCount] = $Angles[$nCount - 1] + ($Percentage[$nCount - 1] * 360) EndIf Next Switch $style Case 0 ; Adjust the angles based on the aspect For $nCount = 0 To UBound($Percentage) $X = $PIE_DIAMETER * Cos($Angles[$nCount] * $PI / 180) $Y = $PIE_DIAMETER * Sin($Angles[$nCount] * $PI / 180) $Y -= ($PIE_DIAMETER - $pieHeight) * Sin($Angles[$nCount] * $PI / 180) If $X = 0 Then $Angles[$nCount] = 90 + ($Y < 0) * 180 Else $Angles[$nCount] = ATan($Y / $X) * 180 / $PI EndIf If $X < 0 Then $Angles[$nCount] += 180 If $X >= 0 And $Y < 0 Then $Angles[$nCount] += 360 $X = $PIE_DIAMETER * Cos($Angles[$nCount] * $PI / 180) $Y = $pieHeight * Sin($Angles[$nCount] * $PI / 180) Next ; Decide which pieces to draw first and last Local $nStart = -1, $nEnd = -1 For $nCount = 0 To UBound($Percentage) - 1 $angleStart = Mod($Angles[$nCount], 360) $angleSweep = Mod($Angles[$nCount + 1] - $Angles[$nCount] + 360, 360) If $angleStart <= 270 And ($angleStart + $angleSweep) >= 270 Then $nStart = $nCount EndIf If ($angleStart <= 90 And ($angleStart + $angleSweep) >= 90) _ Or ($angleStart <= 450 And ($angleStart + $angleSweep) >= 450) Then $nEnd = $nCount EndIf If $nEnd >= 0 And $nStart >= 0 Then ExitLoop Next ; Draw the first piece _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nStart, $Angles) ; Draw pieces "to the right" $nCount = Mod($nStart + 1, UBound($Percentage)) While $nCount <> $nEnd _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nCount, $Angles) $nCount = Mod($nCount + 1, UBound($Percentage)) WEnd ; Draw pieces "to the left" $nCount = Mod($nStart + UBound($Percentage) - 1, UBound($Percentage)) While $nCount <> $nEnd _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nCount, $Angles) $nCount = Mod($nCount + UBound($Percentage) - 1, UBound($Percentage)) WEnd ; Draw the last piece _DrawPiePiece($hBuffer, $pieLeft, $pieTop, $pieWidth, $pieHeight, $PIE_DEPTH * (1 - $Aspect), $nEnd, $Angles) Case 1 ; Draw the donut pieces For $nCount = 0 To UBound($Percentage) - 1 $angleStart = Mod($Angles[$nCount], 360) $angleSweep = Mod($Angles[$nCount + 1] - $Angles[$nCount] + 360, 360) ; Draw the outer arc in a darker colour $hPath = _GDIPlus_GraphicsPathCreate() _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft, $pieTop, $pieWidth, $pieHeight, $angleStart, $angleSweep) _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft + $PIE_MARGIN, $pieTop + $PIE_MARGIN, $pieWidth - $PIE_MARGIN * 2, _ $pieHeight - $PIE_MARGIN * 2, $angleStart + $angleSweep, -$angleSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hBuffer, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hBuffer, $ahPen[$nCount], $hPath) _GDIPlus_GraphicsPathDispose($hPath) ; Draw the inner piece in a lighter colour - leave room for the hole $hPath = _GDIPlus_GraphicsPathCreate() _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft + $PIE_MARGIN, $pieTop + $PIE_MARGIN, $pieWidth - $PIE_MARGIN * 2, _ $pieHeight - $PIE_MARGIN * 2, $angleStart, $angleSweep) _GDIPlus_GraphicsPathAddArc($hPath, $pieLeft + ($PIE_DIAMETER - $holesize) / 2, $pieTop + ($PIE_DIAMETER - $holesize) / 2, _ $holesize, $holesize, $angleStart + $angleSweep, -$angleSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hBuffer, $ahBrush[$nCount][0], $hPath) _GDIPlus_GraphicsDrawPath($hBuffer, $ahPen[$nCount], $hPath) _GDIPlus_GraphicsPathDispose($hPath) Next EndSwitch ; Now draw the bitmap on to the device context of the window _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) EndFunc ;==>_DrawPie Func _OnNotify($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Switch $hWndFrom Case $hSlideAspect, $hSlideRotation, $hStyle, $hHoleSize ; Update the pie chart _DrawPie($aChartValue, _GUICtrlSlider_GetPos($hSlideAspect) / 100, _ _GUICtrlSlider_GetPos($hSlideRotation), _ (GUICtrlRead($cStyle) = $GUI_CHECKED), _ _GUICtrlSlider_GetPos($hHoleSize)) EndSwitch EndFunc ;==>_OnNotify Func _DrawPiePiece($hGraphics, $iX, $iY, $iWidth, $iHeight, $iDepth, $nCount, $Angles) Local $hPath, $cX = $iX + ($iWidth / 2), $cY = $iY + ($iHeight / 2), $fDrawn = False Local $iStart = Mod($Angles[$nCount], 360), $iSweep = Mod($Angles[$nCount + 1] - $Angles[$nCount] + 360, 360) ; Draw side ConsoleWrite(_Now() & @CRLF) $hPath = _GDIPlus_GraphicsPathCreate() If $iStart < 180 And ($iStart + $iSweep > 180) Then _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, $iStart, 180 - $iStart) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, 180, $iStart - 180) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $ahPen[$nCount], $hPath) $fDrawn = True EndIf If $iStart + $iSweep > 360 Then _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, 0, $iStart + $iSweep - 360) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, $iStart + $iSweep - 360, 360 - $iStart - $iSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $ahPen[$nCount], $hPath) $fDrawn = True EndIf If $iStart < 180 And (Not $fDrawn) Then _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iDepth, $iWidth, $iHeight, $iStart + $iSweep, -$iSweep) _GDIPlus_GraphicsPathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGraphics, $ahBrush[$nCount][1], $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $ahPen[$nCount], $hPath) EndIf _GDIPlus_GraphicsPathDispose($hPath) ; Draw top _GDIPlus_GraphicsFillPie($hGraphics, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep, $ahBrush[$nCount][0]) _GDIPlus_GraphicsDrawPie($hGraphics, $iX, $iY, $iWidth, $iHeight, $iStart, $iSweep, $ahPen[$nCount]) EndFunc ;==>_DrawPiePiece Func _GDIPlus_GraphicsPathCreate($iFillMode = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $iFillMode, "int*", 0); If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>_GDIPlus_GraphicsPathCreate Func _GDIPlus_GraphicsPathAddLine($hGraphicsPath, $iX1, $iY1, $iX2, $iY2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine", "hwnd", $hGraphicsPath, "float", $iX1, "float", $iY1, _ "float", $iX2, "float", $iY2) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddLine Func _GDIPlus_GraphicsPathAddArc($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _ "float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddArc Func _GDIPlus_GraphicsPathAddPie($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathPie", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _ "float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddPie Func _GDIPlus_GraphicsPathCloseFigure($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathCloseFigure Func _GDIPlus_GraphicsPathDispose($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathDispose Func _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphics, "hwnd", $hPen, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsDrawPath Func _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphics, "hwnd", $hBrush, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsFillPath
  25. No no no! The parameter is a *pointer* to a DWORD. You're asking the function call to look at the contents of memory address 0x10000. The code as it stands is dangerous. I don't know the full inner workings of DllCall but I don't like the idea of not properly allocating the memory and passing in pointers to random memory addresses. WBD
×
×
  • Create New...