Leaderboard
Popular Content
Showing content with the highest reputation on 06/20/2014 in all areas
-
Today, in the end as well, worked out using the Acrobat Reader ActiveX COM Object "AcroPDF.PDF.1" #include-once #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <MenuConstants.au3> #include <WinAPI.au3> ;~ Thanks to BrewManNH ;~ http://www.autoitscript.com/forum/topic/134878-guiregistermsg-replacement-for-guictrlsetonevent-and-guigetmsg/ ;~ Thanks to mikell ;~ http://www.autoitscript.com/forum/topic/161985-how-to-close-gui-with-guiregistermsg/ ; Install a custom error handler Global $oMyError = ObjEvent("AutoIt.Error", "_ComErrFunc") Global $__hExampleGUI Global $__idOPEN Global $_fExit Global $__hACROBAT_GUI = '' Global $__idACROBAT_GUI_CTRL_AX = '' Global $__oACROBAT_READER = '' #include <GUIConstantsEx.au3> ;~ GUIRegisterMsg($WM_ERASEBKGND, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_PAINT, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_ACTIVATE, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_CAPTURECHANGED, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_DEVICECHANGE, "_WM_EXTRACTOR") GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXTRACTOR") GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR") _ExampleProgram_Gui() While 1 Sleep(10) If $_fExit Then _ACROBAT_GUI_DELETE() DeleteGui() Exit EndIf WEnd Func DeleteGui() GUIDelete($__hExampleGUI) EndFunc ;==>DeleteGui Func _ExampleProgram_Gui() ; Create a GUI with various controls. $__hExampleGUI = GUICreate("Example") $__idOPEN = GUICtrlCreateButton("&Open", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $__hExampleGUI) EndFunc ;==>_ExampleProgram_Gui #Region ACROBAT FUNCTION Func _AcrobatInit() $__oACROBAT_READER = ObjCreate("AcroPDF.PDF.1"); Return $__oACROBAT_READER.GetVersions EndFunc ;==>_AcrobatInit Func _Acrobat_Events(ByRef $aMSG) If $aMSG[1] = $__hACROBAT_GUI Then Switch $aMSG[0] Case $GUI_EVENT_CLOSE _ACROBAT_GUI_DELETE() EndSwitch EndIf EndFunc ;==>_Acrobat_Events Func _ACROBAT_Destroy() $__oACROBAT_READER = "" ;~ MsgBox(1,'test','destroyed') EndFunc ;==>_ACROBAT_Destroy Func _AcrobatShow($sFile, $sTitle = "PDF ", $iLeft = 50, $iTop = 0, $iWidth = 1000, $iHeight = 700) If FileExists($sFile) Then _AcrobatInit() ; Set option $__oACROBAT_READER.src = $sFile $__oACROBAT_READER.SetLayoutMode(4) $__oACROBAT_READER.SetPageMode(1) $__oACROBAT_READER.SetShowToolbar(0) $__oACROBAT_READER.SetView(1) ; Create GUI $__hACROBAT_GUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iWidth - 20, $iHeight - 10) GUICtrlSetStyle($__idACROBAT_GUI_CTRL_AX, $WS_VISIBLE) GUISetState() EndIf EndFunc ;==>_AcrobatShow Func _ACROBAT_Refresh() If IsObj($__oACROBAT_READER) Then Local $hPreviouslyGui = GUISwitch($__hACROBAT_GUI) GUISetState(@SW_LOCK) Local $iGUI_PDFWidth = WinGetPos($__hACROBAT_GUI)[2] - 20 Local $iGUI_PDFHeight = WinGetPos($__hACROBAT_GUI)[3] - 40 Local $sFile = $__oACROBAT_READER.src ; this below line do not works with Acro Reader ; Local $iCurrentPage = $__oACROBAT_READER.GetNumber Local $iCurrentPage = 0 _ACROBAT_Destroy() GUICtrlDelete($__idACROBAT_GUI_CTRL_AX) _AcrobatInit() $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iGUI_PDFWidth, $iGUI_PDFHeight) $__oACROBAT_READER.src = $sFile ;~ $__oACROBAT_READER.SetCurrentPage($iCurrentPage) GUISetState(@SW_UNLOCK) GUISwitch($hPreviouslyGui) EndIf EndFunc ;==>_ACROBAT_Refresh Func _ACROBAT_GUI_DELETE() _ACROBAT_Destroy() if IsHWnd($__hACROBAT_GUI) then GUIDelete($__hACROBAT_GUI) EndFunc ;==>_ACROBAT_GUI_DELETE #EndRegion ACROBAT FUNCTION #Region MSG and ERROR HANDLER Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam) ;~ ConsoleWrite('! $hWnd = ' & $hWnd & ' $iMsg = ' & $iMsg & '('&HEX($iMsg)&')'& ' $wParam = ' & $wParam & ' $lParam = ' & $lParam & @CRLF) If $hWnd = ControlGetHandle($__hACROBAT_GUI, '', $__idACROBAT_GUI_CTRL_AX) Then ConsoleWrite('! -------------- $hWnd = ' & $hWnd & ' $iMsg = ' & $iMsg & '(' & Hex($iMsg) & ')' & ' $wParam = ' & $wParam & ' $lParam = ' & $lParam & @CRLF) EndIf If $hWnd = $__hACROBAT_GUI Then Switch $iMsg Case $WM_COMMAND #cs Case $WM_ACTIVATE Local $test = BitAND($wParam, 0x00000004) if $test <> 0 then MsgBox(1,'$WM_ACTIVATE','test') _ACROBAT_Refresh() EndIf Case $WM_ERASEBKGND WinGetHandle("[ACTIVE]") if $__hACROBAT_GUI <> _WinAPI_GetWindow ( $__hACROBAT_GUI, $GW_HWNDPREV ) then ConsoleWrite('! Case $WM_ERASEBKGND' & @CRLF) _ACROBAT_Refresh() _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE) EndIf Case $WM_PAINT _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE) Case $WM_CAPTURECHANGED _ACROBAT_Refresh() Case $WM_DEVICECHANGE _ACROBAT_Refresh() #ce Case $WM_EXITSIZEMOVE _ACROBAT_Refresh() Case $WM_SYSCOMMAND ;~ Local $test = BitAND($wParam, 0xFFF0) Local $test = BitAND($wParam, 0x0000FFFF) Switch $test Case $SC_CLOSE _ACROBAT_GUI_DELETE() Case $SC_CONTEXTHELP Case $SC_DEFAULT Case $SC_HOTKEY Case $SC_HSCROLL Case $SC_KEYMENU Case $SC_MAXIMIZE _ACROBAT_Refresh() Case $SC_MINIMIZE Case $SC_MONITORPOWER Case $SC_MOUSEMENU Case $SC_MOVE ;~ _ACROBAT_Refresh() Case $SC_NEXTWINDOW ;~ _ACROBAT_Refresh() Case $SC_PREVWINDOW ;~ _ACROBAT_Refresh() Case $SC_RESTORE _ACROBAT_Refresh() Case $SC_SCREENSAVE Case $SC_SIZE Case $SC_TASKLIST Case $SC_VSCROLL EndSwitch EndSwitch EndIf If $hWnd = $__hExampleGUI Then Switch $iMsg Case $WM_COMMAND Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam Switch $nID Case $__idOPEN if not IsObj($__oACROBAT_READER) then _AcrobatShow(FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)) ; put your own start folder here) EndIf EndSwitch Case $WM_SYSCOMMAND Local $test = BitAND($wParam, 0xFFF0) Switch $test Case $SC_CLOSE $_fExit = True Case $SC_CONTEXTHELP Case $SC_DEFAULT Case $SC_HOTKEY Case $SC_HSCROLL Case $SC_KEYMENU Case $SC_MAXIMIZE Case $SC_MINIMIZE Case $SC_MONITORPOWER Case $SC_MOUSEMENU Case $SC_MOVE Case $SC_NEXTWINDOW Case $SC_PREVWINDOW Case $SC_RESTORE Case $SC_SCREENSAVE Case $SC_SIZE Case $SC_TASKLIST Case $SC_VSCROLL EndSwitch EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_EXTRACTOR Func _ComErrFunc() Local $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "AutoItCOM Test", _ "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) EndFunc ;==>_ComErrFunc #EndRegion MSG and ERROR HANDLER Any comments are welcome. Cheers mLipok1 point
-
_UskinLibrary.au3 (UDF) - Skin with DLL free (no ads) and fully functional!
abberration reacted to JScript for a topic
Hello everyone! Use skins for free is not an easy task and not very elegant, so I developed this UDF that I had been using in some programs that I did but that was not in the way of UDF! Are just two files: 1 - _USkinDLL.au3 2 - _UskinLibrary.au3 And only these three lines to add to your scripts: ; #include "_UskinLibrary.au3" _Uskin_LoadDLL() _USkin_Init(@ScriptDir & "SkinsOldSkool.msstyles"); <-- Put here your favorite skin... ;Run or compile the script and enjoy! Note: You can use the FileInstall() to attach the skin you want in your executable, or use the program ?do=embed' frameborder='0' data-embedContent> to embed the skin you want, there you will have to use this case as follows: ; #include "_UskinLibrary.au3" #include ".SkinsOldSkool.au3"; <-- This is an skin ".msstyles" embedded _Uskin_LoadDLL() _USkin_Init(_OldSkool(True)); <-- Put here your favorite Skin!!! ;See the program documentation ?do=embed' frameborder='0' data-embedContent> for more information about how to call files embedded! Note: Some skins have problems if the program is compiled using UPX compression, to circumvent this problem compile your program with the following options added to the top of the source code: #AutoIt3Wrapper_Compression=0 ;Compression parameter 0-4 0=Low 2=normal 4=High. Default=2 #AutoIt3Wrapper_UseUpx=n ;(Y/N) Compress output program. Default=YExample image Download (Updated 14/07/2012) Source with 57 Skins (.msstyles) and embedded (.au3): Example_UskinLibrary_(RedirectLink).html 17.8k (Previous downloads: 588) More Skins downloads http://www.skinbase.org/Skins/msstyles/135 http://www.lotsofskins.com/?num=41&page=browse_category Note: Only files are supported is "msstyles", but it is not a bother, since there are many sites with free downloads of these skins! The use of this DLL is free, ad-free and fully functional! About dll: http://www.neemedia.com João Carlos.1 point -
Android UDF
DiscGolferPro reacted to Moriba for a topic
Hello, I created this UDF last year for my Orient Myanmar Language System. This UDF can control any Android devices. So used it wisely. ; #CURRENT# ===================================================================================================================== ; _Android_Call ; _Android_CommandExists ; _Android_Connect ; _Android_Dial ; _Android_FileExists ; _Android_Flash ; _Android_ForceStopPackage ; _Android_GetBatteryHealth ; _Android_GetBatteryLevel ; _Android_GetBatteryPlugType ; _Android_GetBatteryStatus ; _Android_GetBatteryTechnology ; _Android_GetBatteryTemperature ; _Android_GetBatteryVoltage ; _Android_GetDeviceID ; _Android_GetExternalStorageDirectory ; _Android_GetLegacyExternalStorageDirectory ; _Android_GetNetworkClass ; _Android_GetNetworkCountryISO ; _Android_GetNetworkOperator ; _Android_GetNetworkOperatorName ; _Android_GetNetworkType ; _Android_GetNetworkTypeName ; _Android_GetPackageInfo ; _Android_GetPhoneType ; _Android_GetProperty ; _Android_GetSerialNumber ; _Android_GetSIMCountryISO ; _Android_GetSIMOperator ; _Android_GetSIMOperatorName ; _Android_GetSIMState ; _Android_GetState ; _Android_HasBusyBox ; _Android_HasRootAccess ; _Android_Install ; _Android_IsAirplaneModeOn ; _Android_IsBatteryCharged ; _Android_IsBatteryLow ; _Android_IsBatteryPresent ; _Android_IsBootloader ; _Android_IsNetworkRoaming ; _Android_IsOffline ; _Android_IsOnline ; _Android_IsScreenOn ; _Android_Pull ; _Android_Push ; _Android_Reboot ; _Android_Remount ; _Android_Send ; _Android_SendSMS ; _Android_Shell ; _Android_StartActivity ; _Android_TakeSnapshot ; _Android_Uninstall ; _Android_WaitForDevice ; _Android_Wake ; _Android_WipeDataCache ; =============================================================================================================================== Download Android UDF (11.22.2014) Download ADB, Fastboot & AAPT Here I will accept whatever your suggestion. Can improve my UDF. I love AutoIt. It's so easy and powerful.1 point -
Table UDF
jvds reacted to andybiochem for a topic
Hi, A few weeks ago I was involved in a project where I needed to display some statistical data in a program. I used ListView controls, but was unhappy with the way they looked...header buttons, scroll bars etc. So I hacked away at the ListView using different style constants etc but was unable to find a nice simple way of displaying the data. So I put together this UDF. A 'table' in the sense of this UDF is simply a grid of label controls that can be manipulated by the user to achieve whatever aesthetics fits the requirement, different colors, borders, fonts, sizes, etc. This is not supposed to be any sort of replacement or equal to ListView controls. This is intended to be a very simple way of creating a very simple table of data. FUNCTIONS: _GUICtrlTable_Create - create the table _GUICtrlTable_Delete - delete the table _GUICtrlTable_Move - move to new position _GUICtrlTable_CellGetID - get the label control ID for a cell _GUICtrlTable_CellGetPos - get the cell position _GUICtrlTable_Set_ColumnWidth - set the width of a column _GUICtrlTable_Set_RowHeight - set the height of a row _GUICtrlTable_Set_Text_Row - change the text in a row _GUICtrlTable_Set_Text_Column - "" "" column _GUICtrlTable_Set_Text_Cell - "" "" Cell _GUICtrlTable_Set_Text_FromArray - fill table with data from a 2D array ([rows][columns]) _GUICtrlTable_Get_Text_Row - retrieve text from a row _GUICtrlTable_Get_Text_Column - "" "" column _GUICtrlTable_Get_Text_Cell - "" "" Cell _GUICtrlTable_Get_Text_All - get all table data in an array _GUICtrlTable_Set_TextColor_Row - set color of text in a row _GUICtrlTable_Set_TextColor_Column - "" "" column _GUICtrlTable_Set_TextColor_Cell - "" "" cell _GUICtrlTable_Set_TextColor_All - "" "" all cells _GUICtrlTable_Set_TextFont_Row - Set text font for a row _GUICtrlTable_Set_TextFont_Column - "" "" column _GUICtrlTable_Set_TextFont_Cell - "" "" cell _GUICtrlTable_Set_TextFont_All - "" "" all cells _GUICtrlTable_Set_CellColor_Row - set cell background color for row _GUICtrlTable_Set_CellColor_Column - "" "" column _GUICtrlTable_Set_CellColor_Cell - "" "" cell _GUICtrlTable_Set_CellColor_All - "" "" all cells _GUICtrlTable_Set_Justify_Row - justify text in cells for row _GUICtrlTable_Set_Justify_Column - "" "" column _GUICtrlTable_Set_Justify_Cell - "" "" cell _GUICtrlTable_Set_Justify_All - "" "" all cells _GUICtrlTable_Set_Border_Row - draw a border (combination of left,top,right,bottom) for all cells in row _GUICtrlTable_Set_Border_Column - "" "" column _GUICtrlTable_Set_Border_Cell - "" "" cell _GUICtrlTable_Set_Border_All - "" "" all cells _GUICtrlTable_Set_Border_Table - draw a border around the whole table NOTES: - If you are going to rapidly update data in the table, make sure you double buffer the GUI (as in the example) UPDATES: - 2009/11/22 - Added function "_GUICtrlTable_Set_Text_FromArray" - Added option to ingore blank elements when overwrtiting cells. E.g. _GUICtrlTable_Set_Text_Row($Table,1,"1||3","|",0)... will NOT over-write the data in column 2 (because 1|<blank>|3) TO DO: - add proper error checking returns ?? Any suggestions ?? EXAMPLE USE #include "Table.au3" ;----- GUI (Double Buffered) ----- $GUI = GUICreate("", 450, 450, -1, -1, -1, 0x2000000) ;----- Make sure GUI exists BEFORE creating Tables ----- GUISetState() ;----- Lock GUI until tables drawn ----- GUISetState(@SW_LOCK) ;----- Table Example 1 ----- GUICtrlCreateLabel(" Example 1 ", 25, 7, 100, 13) $Table1 = _GUICtrlTable_Create(25, 27, 55, 13, 4, 4, 1) _GUICtrlTable_Set_ColumnWidth($Table1, 2, 20) _GUICtrlTable_Set_Justify_All($Table1, 1, 1) _GUICtrlTable_Set_TextFont_Row($Table1, 1, 8.5, 800) _GUICtrlTable_Set_CellColor_Row($Table1, 1, 0xEEEEEE) _GUICtrlTable_Set_Text_Row($Table1, 1, "Control|ID|Window|Staus") _GUICtrlTable_Set_Text_Row($Table1, 2, "CheckBox|2|Main|disabled") _GUICtrlTable_Set_Text_Row($Table1, 3, "ListView|3|Child|active") _GUICtrlTable_Set_Text_Row($Table1, 4, "UpDown|4|Child|disabled") ;----- Table Example 2 ----- GUICtrlCreateLabel(" Example 2 ", 260, 7, 100, 13) $Table2 = _GUICtrlTable_Create(260, 27, 80, 18, 7, 2, 0) _GUICtrlTable_Set_Justify_All($Table2, 1, 1) _GUICtrlTable_Set_TextFont_All($Table2, 8.5, 400, 2, "Century Gothic") _GUICtrlTable_Set_TextFont_Column($Table2, 1, 8.5, 800, 0, "Century Gothic") _GUICtrlTable_Set_CellColor_Column($Table2, 1, 0xffd700) _GUICtrlTable_Set_Text_Row($Table2, 1, "Surname|Biochem") _GUICtrlTable_Set_Text_Row($Table2, 2, "Forename|Andy") _GUICtrlTable_Set_Text_Row($Table2, 3, "Age|30") _GUICtrlTable_Set_Text_Row($Table2, 4, "Height|5'8''") _GUICtrlTable_Set_Text_Row($Table2, 5, "Weight|75kg") _GUICtrlTable_Set_Text_Row($Table2, 6, "Eyes|Brown") _GUICtrlTable_Set_Text_Row($Table2, 7, "M/F|M") _GUICtrlTable_Set_Border_Table($Table2) ;----- Table Example 3 ----- GUICtrlCreateLabel(" Example 3 ", 25, 100, 100, 13) $Table3 = _GUICtrlTable_Create(25, 120, 62, 18, 6, 3, 0) _GUICtrlTable_Set_ColumnWidth($Table3, 1, 70) _GUICtrlTable_Set_Justify_Column($Table3, 1, 1, 1) _GUICtrlTable_Set_Justify_Column($Table3, 2, 2, 1) _GUICtrlTable_Set_Justify_Column($Table3, 3, 1, 1) _GUICtrlTable_Set_Justify_Row($Table3, 1, 1, 1) _GUICtrlTable_Set_Border_Row($Table3, 1, 8) _GUICtrlTable_Set_Border_Row($Table3, 5, 8) _GUICtrlTable_Set_Text_Row($Table3, 1, "Transaction|In|Out") _GUICtrlTable_Set_Text_Row($Table3, 6, "Total|£51.01 |-£157.30 ") _GUICtrlTable_Set_Text_Row($Table3, 2, "Petrol||-£35.00 ") _GUICtrlTable_Set_Text_Row($Table3, 3, "Groceries||-£42.30 ") _GUICtrlTable_Set_Text_Row($Table3, 4, "Interest|£51.01 ") _GUICtrlTable_Set_Text_Row($Table3, 5, "Section 5||-£80.00 ") For $row = 2 To 6 For $col = 2 To 3 _GUICtrlTable_Set_TextFont_Cell($Table3, $row, $col, 9, 400, 2) Next Next _GUICtrlTable_Set_TextFont_All($Table3, 8.5, 400, 2, "Tahoma") _GUICtrlTable_Set_TextFont_Row($Table3, 1, 8.5, 600, 0, "Tahoma") ;----- Table Example 4 ----- GUICtrlCreateLabel(" Example 4 ", 25, 250, 100, 13) $Table4 = _GUICtrlTable_Create(35, 268, 62, 18, 8, 6, 0) _GUICtrlTable_Set_RowHeight($Table4, 1, 35) _GUICtrlTable_Set_Justify_All($Table4, 1, 1) _GUICtrlTable_Set_TextFont_All($Table4, 8.5, 800, 0, "Tahoma") _GUICtrlTable_Set_CellColor_Row($Table4, 1, 0x555555) _GUICtrlTable_Set_TextColor_All($Table4, 0x555555) _GUICtrlTable_Set_TextColor_Row($Table4, 1, 0xFFFFFF) For $row = 3 To 10 Step 2 _GUICtrlTable_Set_CellColor_Row($Table4, $row, 0xDDDDDD) Next _GUICtrlTable_Set_Text_Row($Table4, 1, "Fixing|Size|Weight|Net|Gross|Order") _GUICtrlTable_Set_Text_Row($Table4, 2, "Block|20.0|0.01|300|340|No") _GUICtrlTable_Set_Text_Row($Table4, 3, "Screw|8.5|0.3|50|100|No") _GUICtrlTable_Set_Text_Row($Table4, 4, "Rivet|0.1|0.4|10|11|Yes") _GUICtrlTable_Set_Text_Row($Table4, 5, "Rope|300.0|100.0|2|10|No") _GUICtrlTable_Set_Text_Row($Table4, 6, "Tack|10.6|0.3|1000|1011|Yes") _GUICtrlTable_Set_Text_Row($Table4, 7, "Nail|30.3|0.4|400|600|No") _GUICtrlTable_Set_Text_Row($Table4, 8, "Staple|0.3|0.05|10000|12000|No") _GUICtrlTable_Set_Border_Table($Table4, 0x555555) ;----- Table Example 5 ----- GUICtrlCreateLabel(" Example 5 ", 260, 165, 100, 13) $Table5 = _GUICtrlTable_Create(260, 182, 30, 20, 3, 3, 0) _GUICtrlTable_Set_ColumnWidth($Table5, 1, 200) _GUICtrlTable_Set_Text_Row($Table5, 1, "Attribute|x|y") _GUICtrlTable_Set_CellColor_Row($Table5, 1, 0xEEEEEE) _GUICtrlTable_Set_Justify_All($Table5, 1, 1) _GUICtrlTable_Set_TextFont_All($Table5, 8.5, 200) _GUICtrlTable_Set_TextFont_Row($Table5, 1, 9, 800) _GUICtrlTable_Set_Border_Column($Table5, 2, 1, 0xEEEEEE) _GUICtrlTable_Set_Border_Column($Table5, 3, 1, 0xEEEEEE) _GUICtrlTable_Set_Border_Row($Table5, 1, 11) _GUICtrlTable_Set_Border_Table($Table5) _GUICtrlTable_Set_ColumnWidth($Table5, 1, 100) ;----- Unlock GUI to show tables ----- GUISetState(@SW_UNLOCK) ;----- Loop ----- Do Sleep(10) $m = MouseGetPos() _GUICtrlTable_Set_Text_Row($Table5, 2, "Mouse Position|" & $m[0] & "|" & $m[1]) $w = WinGetPos("") _GUICtrlTable_Set_Text_Row($Table5, 3, "Window Position|" & $w[0] & "|" & $w[1]) Until GUIGetMsg() = -3 UDF: Table.au3 ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# =================================================================================== ; Title .........: Table ; AutoIt Version: 3.3.0.0+ ; Language: English ; Description ...: A simple Table control using an array of labels. ; This is an attempt at a cleaner, simpler, way of displaying data without using ListViews. ; Notes .........: GUI must exist BEFORE table is constructed/manipulated, ; i.e. GUISetState() must be called before _GUICtrlTable_Create ; =========================================================================================== ; #VARIABLES# =============================================================================== Global $_aGUICtrlTableBordersINTERNALSTORE[1][2] ; =========================================================================================== ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Create ; Description ...: Creates a 'table' of label controls, and preps the 'border array' ; Syntax.........: _GUICtrlTable_Create($iLeft, $iTop, $iWidth, $iHeight, $iRows, $iColumns[, $iGapWidth = 1]) ; Parameters ....: $iLeft - Horisontal position of first cell ; $iTop - Vertical position of first cell ; $iWidth - Initial width of each cell ; $iHeight - Initial height of each cell ; $iRows - Number of rows in table ; $iColumns - Number of columns in table ; $iGapWidth - Size (pixels) of gap between each cell (can be zero = no gaps) ; Return values .: Success - Returns array of label IDs for other functions ($ReturnedArray[ROW][COLUMN]) ; Failure - (under construction) ; Notes .........: Rows/Columns are NOT zero-indexed. The first row IS row 1, the first column IS col 1 etc ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Create($iLeft, $iTop, $iWidth, $iHeight, $iRows, $iColumns, $iGapWidth = 1) Local $i, $j, $iCurrBoxLeft = 0, $iCurrBoxTop = 0, $aTemp Local $array[$iRows + 1][$iColumns + 1] If $iGapWidth < 0 Then $iGapWidth = 0 $iGapWidth = Round($iGapWidth) For $i = 1 To $iRows For $j = 1 To $iColumns $array[$i][$j] = GUICtrlCreateLabel("", $iLeft + $iCurrBoxLeft, $iTop + $iCurrBoxTop, $iWidth, $iHeight) GUICtrlSetBkColor(-1, 0xFFFFFF) $iCurrBoxLeft += $iWidth + $iGapWidth Next $iCurrBoxLeft = 0 $iCurrBoxTop += $iHeight + $iGapWidth Next ReDim $_aGUICtrlTableBordersINTERNALSTORE[UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) + 1][2] Dim $aTemp[$iRows + 1][$iColumns + 1][5] $_aGUICtrlTableBordersINTERNALSTORE[UBound($_aGUICtrlTableBordersINTERNALSTORE) - 1][0] = $array[1][1] $_aGUICtrlTableBordersINTERNALSTORE[UBound($_aGUICtrlTableBordersINTERNALSTORE) - 1][1] = $aTemp Return $array EndFunc ;==>_GUICtrlTable_Create ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Delete ; Description ...: Deletes the labels associated with this table, including borders, also nulls array entries ; Syntax.........: _GUICtrlTable_Delete(ByRef $array) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Delete(ByRef $array) Local $i, $j, $aRetrievedTableBorders, $test If IsArray($array) = 0 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 GUICtrlDelete($array[$i][$j]) Next Next _GUICtrlTable_Set_Border_All($array, 0) $array = 0 $aRetrievedTableBorders = 0 ;- Put retrieved borders back $_aGUICtrlTableBordersINTERNALSTORE[$test][0] = "" $_aGUICtrlTableBordersINTERNALSTORE[$test][1] = $aRetrievedTableBorders EndFunc ;==>_GUICtrlTable_Delete ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Move ; Description ...: Moves the x/y position of the table (including borders) ; Syntax.........: _GUICtrlTable_Move(ByRef $array, $iLeft, $iTop) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iLeft - new Horisontal position of first cell ; $iTop - new Vertical position of first cell ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Move(ByRef $array, $iLeft, $iTop) Local $i, $j, $k, $aTemp, $aTemp2, $iMoveLeft, $iMoveTop, $test, $aRetrievedTableBorders If IsArray($array) = 0 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next $aTemp = ControlGetPos("", "", $array[1][1]) $iMoveLeft = $aTemp[0] - $iLeft $iMoveTop = $aTemp[1] - $iTop For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 $aTemp = ControlGetPos("", "", $array[$i][$j]) GUICtrlSetPos($array[$i][$j], $aTemp[0] - $iMoveLeft, $aTemp[1] - $iMoveTop) For $k = 1 To 4 $aTemp2 = ControlGetPos("", "", $aRetrievedTableBorders[$i][$j][$k]) If IsArray($aTemp2) = 0 Then ContinueLoop GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp2[0] - $iMoveLeft, $aTemp2[1] - $iMoveTop) Next Next Next EndFunc ;==>_GUICtrlTable_Move ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_CellGetID ; Description ...: Retrieves the label control ID for the specified cell, enables user modification ; Syntax.........: _GUICtrlTable_CellGetID(ByRef $array, $iRow, $iCol) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - Cell row value ; $iCol - Cell column value ; Return values .: Success - Returns label control ID for specified 'cell' ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_CellGetID(ByRef $array, $iRow, $iCol) If IsArray($array) = 0 Then Return Return $array[$iRow][$iCol] EndFunc ;==>_GUICtrlTable_CellGetID ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_CellGetPos ; Description ...: Retrieves the label position for the specified cell, enables user modification ; Syntax.........: _GUICtrlTable_CellGetPos(ByRef $array, $iRow, $iCol) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - Cell row value ; $iCol - Cell column value ; Return values .: Success - Returns array as per ControlGetPos ($arra[0] = left, [1] = top etc) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_CellGetPos(ByRef $array, $iRow, $iCol) If IsArray($array) = 0 Then Return Return ControlGetPos("", "", $array[$iRow][$iCol]) EndFunc ;==>_GUICtrlTable_CellGetPos ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_ColumnWidth ; Description ...: Changes the width of a specified column of cells/labels ; Syntax.........: _GUICtrlTable_Set_ColumnWidth(ByRef $array, $iCol, $iWidth) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $iWidth - new width of column ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_ColumnWidth(ByRef $array, $iCol, $iWidth) Local $i, $j, $k, $iCurrBoxLeft, $bFirst, $aTemp, $aTemp2, $iGapWidth, $test, $aRetrievedTableBorders If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next $aTemp = ControlGetPos("", "", $array[1][1]) $aTemp2 = ControlGetPos("", "", $array[1][2]) $iGapWidth = $aTemp2[0] - ($aTemp[0] + $aTemp[2]) If $iGapWidth < 0 Then $iGapWidth = 0 For $i = 1 To UBound($array, 1) - 1 $bFirst = True For $j = $iCol To UBound($array, 2) - 1 $aTemp = ControlGetPos("", "", $array[$i][$j]) If $bFirst = True Then $iCurrBoxLeft = $aTemp[0] $bFirst = False Switch $j Case $iCol GUICtrlSetPos($array[$i][$j], $iCurrBoxLeft, $aTemp[1], $iWidth) For $k = 1 To 4 Switch $k Case 1 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1]) Case 2 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1], $iWidth) Case 3 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft + $iWidth - 1, $aTemp[1]) Case 4 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1] + $aTemp[3] - 1, $iWidth) EndSwitch Next $iCurrBoxLeft += $iWidth + $iGapWidth Case Else GUICtrlSetPos($array[$i][$j], $iCurrBoxLeft, $aTemp[1]) For $k = 1 To 4 Switch $k Case 1, 2 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1]) Case 3 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft + $aTemp[2] - 1, $aTemp[1]) Case 4 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $iCurrBoxLeft, $aTemp[1] + $aTemp[3] - 1) EndSwitch Next $iCurrBoxLeft += $aTemp[2] + $iGapWidth EndSwitch Next Next EndFunc ;==>_GUICtrlTable_Set_ColumnWidth ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_RowHeight ; Description ...: Changes the height of a specified row of cells/labels ; Syntax.........: _GUICtrlTable_Set_RowHeight(ByRef $array, $iRow, $iHeight) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $iHeight - new height for row ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_RowHeight(ByRef $array, $iRow, $iHeight) Local $i, $j, $k, $iCurrBoxTop, $bFirst, $aTemp, $aTemp2, $iGapWidth, $test, $aRetrievedTableBorders If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next $aTemp = ControlGetPos("", "", $array[1][1]) $aTemp2 = ControlGetPos("", "", $array[1][2]) $iGapWidth = $aTemp2[0] - ($aTemp[0] + $aTemp[2]) If $iGapWidth < 0 Then $iGapWidth = 0 $bFirst = True For $i = $iRow To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 $aTemp = ControlGetPos("", "", $array[$i][$j]) If $bFirst = True Then $iCurrBoxTop = $aTemp[1] $bFirst = False Switch $i Case $iRow GUICtrlSetPos($array[$i][$j], $aTemp[0], $iCurrBoxTop, $aTemp[2], $iHeight) For $k = 1 To 4 Switch $k Case 1 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0], $iCurrBoxTop, 1, $iHeight) Case 2 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0], $iCurrBoxTop) Case 3 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0] + $aTemp[2] - 1, $iCurrBoxTop, 1, $iHeight) Case 4 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0], $iCurrBoxTop + $iHeight - 1) EndSwitch Next Case Else GUICtrlSetPos($array[$i][$j], $aTemp[0], $iCurrBoxTop) For $k = 1 To 4 Switch $k Case 1, 2 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0], $iCurrBoxTop) Case 3 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0] + $aTemp[2] - 1, $iCurrBoxTop) Case 4 GUICtrlSetPos($aRetrievedTableBorders[$i][$j][$k], $aTemp[0], $iCurrBoxTop + $aTemp[3] - 1) EndSwitch Next EndSwitch Next Switch $i Case $iRow $iCurrBoxTop += $iHeight + $iGapWidth Case Else $iCurrBoxTop += $aTemp[3] + $iGapWidth EndSwitch Next EndFunc ;==>_GUICtrlTable_Set_RowHeight ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Text_Row ; Description ...: Changes the text of the cells in a row ; Syntax.........: _GUICtrlTable_Set_Text_Row(ByRef $array, $iRow, $sText[, $sDelimiter = "|"]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $sText - delimted text to add to cells ; $sDelimiter - character to act as text string delimiter ; Return values .: Success - (under construction) ; Failure - (under construction) ; Notes .........: If more delimiters exist in text than there are cells, the extra data is ignored ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Text_Row(ByRef $array, $iRow, $sText, $sDelimiter = "|") Local $i If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return Local $aString = StringSplit($sText, $sDelimiter) Local $iUpperlimit = UBound($array, 2) - 1 If $aString[0] < $iUpperlimit Then $iUpperlimit = $aString[0] For $i = 1 To $iUpperlimit GUICtrlSetData($array[$iRow][$i], $aString[$i]) Next EndFunc ;==>_GUICtrlTable_Set_Text_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Text_Column ; Description ...: Changes the text of the cells in a column ; Syntax.........: _GUICtrlTable_Set_Text_Column(ByRef $array, $iCol, $sText[, $sDelimiter = "|"]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $sText - delimted text to add to cells ; $sDelimiter - character to act as text string delimiter ; Return values .: Success - (under construction) ; Failure - (under construction) ; Notes .........: If more delimiters exist in text than there are cells, the extra data is ignored ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Text_Column(ByRef $array, $iCol, $sText, $sDelimiter = "|") Local $i If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return Local $aString = StringSplit($sText, $sDelimiter) Local $iUpperlimit = UBound($array, 1) - 1 If $aString[0] < $iUpperlimit Then $iUpperlimit = $aString[0] For $i = 1 To $iUpperlimit GUICtrlSetData($array[$i][$iCol], $aString[$i]) Next EndFunc ;==>_GUICtrlTable_Set_Text_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Text_Cell ; Description ...: Changes the text of the cells in a single cell ; Syntax.........: _GUICtrlTable_Set_Text_Cell(ByRef $array, $iRow, $iCol, $sText) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell column value ; $sText - text to add to cell ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Text_Cell(ByRef $array, $iRow, $iCol, $sText) If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return GUICtrlSetData($array[$iRow][$iCol], $sText) EndFunc ;==>_GUICtrlTable_Set_Text_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Get_Text_Row ; Description ...: Returns the data from a row of cells ; Syntax.........: _GUICtrlTable_Get_Text_Row(ByRef $array, $iRow[, $sDelimiter = "|"]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $sDelimiter - character to put between cell returns ; Return values .: Success - returns delimited string of cell data from specified row ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Get_Text_Row(ByRef $array, $iRow, $sDelimiter = "|") Local $i, $sString If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return ;set error too $sString = "" For $i = 1 To UBound($array, 2) - 1 $sString &= GUICtrlRead($array[$iRow][$i]) & $sDelimiter Next Return StringTrimRight($sString, 1) EndFunc ;==>_GUICtrlTable_Get_Text_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Get_Text_Column ; Description ...: Returns the data from a column of cells ; Syntax.........: _GUICtrlTable_Get_Text_Column(ByRef $array, $iCol[, $sDelimiter = "|"]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $sDelimiter - character to put between cell returns ; Return values .: Success - returns delimited string of cell data from specified column ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Get_Text_Column(ByRef $array, $iCol, $sDelimiter = "|") Local $i, $sString If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return ;set error too $sString = "" For $i = 1 To UBound($array, 1) - 1 $sString &= GUICtrlRead($array[$i][$iCol]) & $sDelimiter Next Return StringTrimRight($sString, 1) EndFunc ;==>_GUICtrlTable_Get_Text_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Get_Text_Cell ; Description ...: Returns the data from a specified cell ; Syntax.........: _GUICtrlTable_Get_Text_Cell(ByRef $array, $iRow, $iCol) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell Column value ; Return values .: Success - returns cell data from specified cell ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Get_Text_Cell(ByRef $array, $iRow, $iCol) If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return Return GUICtrlRead($array[$iRow][$iCol]) EndFunc ;==>_GUICtrlTable_Get_Text_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Get_Text_All ; Description ...: Returns all the data from a table ; Syntax.........: _GUICtrlTable_Get_Text_All(ByRef $array) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; Return values .: Success - returns a 2d array of cell data e.g. $array[row][column] ; Failure - (under construction) ; Notes .........: zero elements of returned array are empty ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Get_Text_All(ByRef $array) Local $i, $j, $aTemp If IsArray($array) = 0 Then Return $aTemp = $array For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 $aTemp[$i][$j] = GUICtrlRead($array[$i][$j]) Next Next Return $aTemp EndFunc ;==>_GUICtrlTable_Get_Text_All ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextColor_Row ; Description ...: Sets the text color of a row of cells ; Syntax.........: _GUICtrlTable_Set_TextColor_Row(ByRef $array, $iRow[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $iColor - color to set text ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextColor_Row(ByRef $array, $iRow, $iColor = 0x000000) Local $i If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return For $i = 1 To UBound($array, 2) - 1 GUICtrlSetColor($array[$iRow][$i], $iColor) Next EndFunc ;==>_GUICtrlTable_Set_TextColor_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextColor_Column ; Description ...: Sets the text color of a column of cells ; Syntax.........: _GUICtrlTable_Set_TextColor_Column(ByRef $array, $iCol[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $iColor - color to set text ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextColor_Column(ByRef $array, $iCol, $iColor = 0x000000) Local $i If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return For $i = 1 To UBound($array, 1) - 1 GUICtrlSetColor($array[$i][$iCol], $iColor) Next EndFunc ;==>_GUICtrlTable_Set_TextColor_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextColor_Cell ; Description ...: Sets the text color of a specified cell ; Syntax.........: _GUICtrlTable_Set_TextColor_Cell(ByRef $array, $iRow, $iCol[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell column value ; $iColor - color to set text ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextColor_Cell(ByRef $array, $iRow, $iCol, $iColor = 0x000000) If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return GUICtrlSetColor($array[$iRow][$iCol], $iColor) EndFunc ;==>_GUICtrlTable_Set_TextColor_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextColor_All ; Description ...: Sets the text color of all cells in table ; Syntax.........: _GUICtrlTable_Set_TextColor_All(ByRef $array[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iColor - color to set text ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextColor_All(ByRef $array, $iColor = 0x000000) Local $i, $j If IsArray($array) = 0 Then Return For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 GUICtrlSetColor($array[$i][$j], $iColor) Next Next EndFunc ;==>_GUICtrlTable_Set_TextColor_All ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextFont_Row ; Description ...: Sets the text size, weight, attribute and font of a row of cells ; Syntax.........: _GUICtrlTable_Set_TextFont_Row(ByRef $array, $iRow, $iSize[, $iWeight = 400[, $iAttribute = 0[, $sFontname = "MS Sans Serif"]]]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $iSize - font size ; $iWeight - weight of font (bold etc) ; $iAttribute - italic=2 underlined=4 strike=8 (add together) ; $sFontname - name of font to use ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextFont_Row(ByRef $array, $iRow, $iSize, $iWeight = 400, $iAttribute = 0, $sFontname = "MS Sans Serif") Local $i If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return For $i = 1 To UBound($array, 2) - 1 GUICtrlSetFont($array[$iRow][$i], $iSize, $iWeight, $iAttribute, $sFontname) Next EndFunc ;==>_GUICtrlTable_Set_TextFont_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextFont_Column ; Description ...: Sets the text size, weight, attribute and font of a column of cells ; Syntax.........: _GUICtrlTable_Set_TextFont_Column(ByRef $array, $iCol, $iSize[, $iWeight = 400[, $iAttribute = 0[, $sFontname = "MS Sans Serif"]]]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $iSize - font size ; $iWeight - weight of font (bold etc) ; $iAttribute - italic=2 underlined=4 strike=8 (add together) ; $sFontname - name of font to use ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextFont_Column(ByRef $array, $iCol, $iSize, $iWeight = 400, $iAttribute = 0, $sFontname = "MS Sans Serif") Local $i If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return For $i = 1 To UBound($array, 1) - 1 GUICtrlSetFont($array[$i][$iCol], $iSize, $iWeight, $iAttribute, $sFontname) Next EndFunc ;==>_GUICtrlTable_Set_TextFont_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextFont_Cell ; Description ...: Sets the text size, weight, attribute and font of a specified cell ; Syntax.........: _GUICtrlTable_Set_TextFont_Cell(ByRef $array, $iRow, $iCol, $iSize[, $iWeight = 400[, $iAttribute = 0[, $sFontname = "MS Sans Serif"]]]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell column value ; $iSize - font size ; $iWeight - weight of font (bold etc) ; $iAttribute - italic=2 underlined=4 strike=8 (add together) ; $sFontname - name of font to use ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextFont_Cell(ByRef $array, $iRow, $iCol, $iSize, $iWeight = 400, $iAttribute = 0, $sFontname = "MS Sans Serif") If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return GUICtrlSetFont($array[$iRow][$iCol], $iSize, $iWeight, $iAttribute, $sFontname) EndFunc ;==>_GUICtrlTable_Set_TextFont_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_TextFont_All ; Description ...: Sets the text size, weight, attribute and font of all cells in table ; Syntax.........: _GUICtrlTable_Set_TextFont_All(ByRef $array[, $iSize = 8.5[, $iWeight = 400[, $iAttribute = 0[, $sFontname = "MS Sans Serif"]]]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iSize - font size ; $iWeight - weight of font (bold etc) ; $iAttribute - italic=2 underlined=4 strike=8 (add together) ; $sFontname - name of font to use ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_TextFont_All(ByRef $array, $iSize = 8.5, $iWeight = 400, $iAttribute = 0, $sFontname = "MS Sans Serif") Local $i, $j If IsArray($array) = 0 Then Return For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 GUICtrlSetFont($array[$i][$j], $iSize, $iWeight, $iAttribute, $sFontname) Next Next EndFunc ;==>_GUICtrlTable_Set_TextFont_All ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_CellColor_Row ; Description ...: Sets the cell background color of a row of cells ; Syntax.........: _GUICtrlTable_Set_CellColor_Row(ByRef $array, $iRow[, $iColor = 0xFFFFFF]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $iColor - background color for cell ( -2 = transparent) ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_CellColor_Row(ByRef $array, $iRow, $iColor = 0xFFFFFF) Local $i If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return For $i = 1 To UBound($array, 2) - 1 GUICtrlSetBkColor($array[$iRow][$i], $iColor) Next EndFunc ;==>_GUICtrlTable_Set_CellColor_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_CellColor_Column ; Description ...: Sets the cell background color of a column of cells ; Syntax.........: _GUICtrlTable_Set_CellColor_Col(ByRef $array, $iCol[, $iColor = 0xFFFFFF]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $iColor - background color for cell ( -2 = transparent) ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_CellColor_Column(ByRef $array, $iCol, $iColor = 0xFFFFFF) Local $i If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return For $i = 1 To UBound($array, 1) - 1 GUICtrlSetBkColor($array[$i][$iCol], $iColor) Next EndFunc ;==>_GUICtrlTable_Set_CellColor_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_CellColor_Cell ; Description ...: Sets the cell background color of a specified of cell ; Syntax.........: _GUICtrlTable_Set_CellColor_Cell(ByRef $array, $iRow, $iCol[, $iColor = 0xFFFFFF]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell column value ; $iColor - background color for cell ( -2 = transparent) ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_CellColor_Cell(ByRef $array, $iRow, $iCol, $iColor = 0xFFFFFF) If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return GUICtrlSetBkColor($array[$iRow][$iCol], $iColor) EndFunc ;==>_GUICtrlTable_Set_CellColor_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_CellColor_All ; Description ...: Sets the cell background color of all cells in a table ; Syntax.........: _GUICtrlTable_Set_CellColor_All(ByRef $array[, $iColor = 0xFFFFFF]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iColor - background color for cells ( -2 = transparent) ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_CellColor_All(ByRef $array, $iColor = 0xFFFFFF) Local $i, $j If IsArray($array) = 0 Then Return For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 GUICtrlSetBkColor($array[$i][$j], $iColor) Next Next EndFunc ;==>_GUICtrlTable_Set_CellColor_All ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Justify_Row ; Description ...: Sets the justification (text position in cell) of a row of cells ; Syntax.........: _GUICtrlTable_Set_Justify_Row(ByRef $array, $iRow, $iJustify[, $iVCenter = 0]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $iJustify - left = 0, center = 1, right = 2 ; $iVCenter - vertical position, top = 0, center = 1 ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Justify_Row(ByRef $array, $iRow, $iJustify, $iVCenter = 0) Local $i If $iJustify < 0 Or $iJustify > 2 Then Return If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If $iVCenter <> 0 Then $iJustify += 0x0200 For $i = 1 To UBound($array, 2) - 1 GUICtrlSetStyle($array[$iRow][$i], $iJustify) Next EndFunc ;==>_GUICtrlTable_Set_Justify_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Justify_Column ; Description ...: Sets the justification (text position in cell) of a column of cells ; Syntax.........: _GUICtrlTable_Set_Justify_Column(ByRef $array, $iCol, $iJustify[, $iVCenter = 0]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table column value ; $iJustify - left = 0, center = 1, right = 2 ; $iVCenter - vertical position, top = 0, center = 1 ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Justify_Column(ByRef $array, $iCol, $iJustify, $iVCenter = 0) Local $i If $iJustify < 0 Or $iJustify > 2 Then Return If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return If $iVCenter <> 0 Then $iJustify += 0x0200 For $i = 1 To UBound($array, 1) - 1 GUICtrlSetStyle($array[$i][$iCol], $iJustify) Next EndFunc ;==>_GUICtrlTable_Set_Justify_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Justify_Cell ; Description ...: Sets the justification (text position in cell) of a specified cell ; Syntax.........: _GUICtrlTable_Set_Justify_Cell(ByRef $array, $iRow, $iCol, $iJustify[, $iVCenter = 0]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell column value ; $iJustify - left = 0, center = 1, right = 2 ; $iVCenter - vertical position, top = 0, center = 1 ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Justify_Cell(ByRef $array, $iRow, $iCol, $iJustify, $iVCenter = 0) If $iJustify < 0 Or $iJustify > 2 Then Return If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return If $iVCenter <> 0 Then $iJustify += 0x0200 GUICtrlSetStyle($array[$iRow][$iCol], $iJustify) EndFunc ;==>_GUICtrlTable_Set_Justify_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Justify_All ; Description ...: Sets the justification (text position in cell) of all cells in table ; Syntax.........: _GUICtrlTable_Set_Justify_All(ByRef $array, $iJustify[, $iVCenter = 0]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iJustify - left = 0, center = 1, right = 2 ; $iVCenter - vertical position, top = 0, center = 1 ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Justify_All(ByRef $array, $iJustify, $iVCenter = 0) Local $i, $j If $iJustify < 0 Or $iJustify > 2 Then Return If IsArray($array) = 0 Then Return If $iVCenter <> 0 Then $iJustify += 0x0200 For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 GUICtrlSetStyle($array[$i][$j], $iJustify) Next Next EndFunc ;==>_GUICtrlTable_Set_Justify_All ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Border_Row ; Description ...: Draws a border on specified row of cells ; Syntax.........: _GUICtrlTable_Set_Border_Row(ByRef $array, $iRow, $iType[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - table row value ; $iType - left = 1, top = 2, right = 4, bottom = 8 (add values, e.g. full border = 15) NoBorder = 0 ; $iColor - color of border to add ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; Credits .......: Authenticity (demonstrated API/dll z-order calls) ; =========================================================================================== Func _GUICtrlTable_Set_Border_Row(ByRef $array, $iRow, $iType, $iColor = 0x000000) Local $hLabel, $i, $aTemp, $test, $aRetrievedTableBorders If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next For $i = 1 To UBound($array, 2) - 1 $aTemp = ControlGetPos("", "", $array[$iRow][$i]) ;none = 0 Switch $iType Case 0 GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][1]) GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][2]) GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][3]) GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][4]) EndSwitch ;left border = 1 Switch $iType Case 1, 3, 5, 7, 9, 11, 13, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][1]) $aRetrievedTableBorders[$iRow][$i][1] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) ;set label to top DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;top border = 2 Switch $iType Case 2, 3, 6, 7, 10, 11, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][2]) $aRetrievedTableBorders[$iRow][$i][2] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;right border = 4 Switch $iType Case 4, 5, 6, 7, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][3]) $aRetrievedTableBorders[$iRow][$i][3] = GUICtrlCreateLabel("", $aTemp[0] + $aTemp[2] - 1, $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;bottom border = 8 Switch $iType Case 8, 9, 10, 11, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$i][4]) $aRetrievedTableBorders[$iRow][$i][4] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1] + $aTemp[3] - 1, $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch Next ;- Put retrieved borders back $_aGUICtrlTableBordersINTERNALSTORE[$test][1] = $aRetrievedTableBorders ;refresh window (not needed?) ;DllCall("User32.dll", "int", "InvalidateRect", "hwnd", "", "ptr", 0, "int", True) EndFunc ;==>_GUICtrlTable_Set_Border_Row ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Border_Column ; Description ...: Draws a border on specified column of cells ; Syntax.........: _GUICtrlTable_Set_Border_Column(ByRef $array, $iCol, $iType[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iCol - table col value ; $iType - left = 1, top = 2, right = 4, bottom = 8 (add values, e.g. full border = 15) NoBorder = 0 ; $iColor - color of border to add ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; Credits .......: Authenticity (demonstrated API/dll z-order calls) ; =========================================================================================== Func _GUICtrlTable_Set_Border_Column(ByRef $array, $iCol, $iType, $iColor = 0x000000) Local $hLabel, $i, $aTemp, $test, $aRetrievedTableBorders If IsArray($array) = 0 Then Return If $iCol = 0 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next For $i = 1 To UBound($array, 1) - 1 $aTemp = ControlGetPos("", "", $array[$i][$iCol]) ;none = 0 Switch $iType Case 0 GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][1]) GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][2]) GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][3]) GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][4]) EndSwitch ;left border = 1 Switch $iType Case 1, 3, 5, 7, 9, 11, 13, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][1]) $aRetrievedTableBorders[$i][$iCol][1] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) ;set label to top DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;top border = 2 Switch $iType Case 2, 3, 6, 7, 10, 11, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][2]) $aRetrievedTableBorders[$i][$iCol][2] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;right border = 4 Switch $iType Case 4, 5, 6, 7, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][3]) $aRetrievedTableBorders[$i][$iCol][3] = GUICtrlCreateLabel("", $aTemp[0] + $aTemp[2] - 1, $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;bottom border = 8 Switch $iType Case 8, 9, 10, 11, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$iCol][4]) $aRetrievedTableBorders[$i][$iCol][4] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1] + $aTemp[3] - 1, $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch Next ;- Put retrieved borders back $_aGUICtrlTableBordersINTERNALSTORE[$test][1] = $aRetrievedTableBorders ;refresh window ;DllCall("User32.dll", "int", "InvalidateRect", "hwnd", "", "ptr", 0, "int", True) EndFunc ;==>_GUICtrlTable_Set_Border_Column ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Border_Cell ; Description ...: Draws a border on specified cell ; Syntax.........: _GUICtrlTable_Set_Border_Cell(ByRef $array, $iRow, $iCol, $iType[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iRow - cell row value ; $iCol - cell col value ; $iType - left = 1, top = 2, right = 4, bottom = 8 (add values, e.g. full border = 15) NoBorder = 0 ; $iColor - color of border to add ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; Credits .......: Authenticity (demonstrated API/dll z-order calls) ; =========================================================================================== Func _GUICtrlTable_Set_Border_Cell(ByRef $array, $iRow, $iCol, $iType, $iColor = 0x000000) Local $hLabel, $aTemp, $test, $aRetrievedTableBorders, $i If IsArray($array) = 0 Then Return If $iRow = 0 Then Return If $iCol = 0 Then Return If Number($iRow) > UBound($array, 1) - 1 Then Return If Number($iCol) > UBound($array, 2) - 1 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next $aTemp = ControlGetPos("", "", $array[$iRow][$iCol]) ;none = 0 Switch $iType Case 0 GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][1]) GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][2]) GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][3]) GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][4]) EndSwitch ;left border = 1 Switch $iType Case 1, 3, 5, 7, 9, 11, 13, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][1]) $aRetrievedTableBorders[$iRow][$iCol][1] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) ;set label to top DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;top border = 2 Switch $iType Case 2, 3, 6, 7, 10, 11, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][2]) $aRetrievedTableBorders[$iRow][$iCol][2] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;right border = 4 Switch $iType Case 4, 5, 6, 7, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][3]) $aRetrievedTableBorders[$iRow][$iCol][3] = GUICtrlCreateLabel("", $aTemp[0] + $aTemp[2] - 1, $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;bottom border = 8 Switch $iType Case 8, 9, 10, 11, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$iRow][$iCol][4]) $aRetrievedTableBorders[$iRow][$iCol][4] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1] + $aTemp[3] - 1, $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;- Put retrieved borders back $_aGUICtrlTableBordersINTERNALSTORE[$test][1] = $aRetrievedTableBorders ;refresh window ;DllCall("User32.dll", "int", "InvalidateRect", "hwnd", "", "ptr", 0, "int", True) EndFunc ;==>_GUICtrlTable_Set_Border_Cell ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Border_All ; Description ...: Draws a border on all cells in table ; Syntax.........: _GUICtrlTable_Set_Border_Cell(ByRef $array, iType[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iType - left = 1, top = 2, right = 4, bottom = 8 (add values, e.g. full border = 15) NoBorder = 0 ; $iColor - color of border to add ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; Credits .......: Authenticity (demonstrated API/dll z-order calls) ; =========================================================================================== Func _GUICtrlTable_Set_Border_All(ByRef $array, $iType, $iColor = 0x000000) Local $hLabel, $i, $aTemp, $test, $aRetrievedTableBorders If IsArray($array) = 0 Then Return ;- Get border array from store - $test = "" For $i = 1 To UBound($_aGUICtrlTableBordersINTERNALSTORE, 1) - 1 $test = $_aGUICtrlTableBordersINTERNALSTORE[$i][0] If $array[1][1] = $test Then $aRetrievedTableBorders = $_aGUICtrlTableBordersINTERNALSTORE[$i][1] $test = $i ExitLoop EndIf Next For $i = 1 To UBound($array, 1) - 1 For $j = 1 To UBound($array, 2) - 1 $aTemp = ControlGetPos("", "", $array[$i][$j]) ;none = 0 Switch $iType Case 0 GUICtrlDelete($aRetrievedTableBorders[$i][$j][1]) GUICtrlDelete($aRetrievedTableBorders[$i][$j][2]) GUICtrlDelete($aRetrievedTableBorders[$i][$j][3]) GUICtrlDelete($aRetrievedTableBorders[$i][$j][4]) EndSwitch ;left border = 1 Switch $iType Case 1, 3, 5, 7, 9, 11, 13, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$j][1]) $aRetrievedTableBorders[$i][$j][1] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) ;set label to top DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;top border = 2 Switch $iType Case 2, 3, 6, 7, 10, 11, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$j][2]) $aRetrievedTableBorders[$i][$j][2] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1], $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;right border = 4 Switch $iType Case 4, 5, 6, 7, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$j][3]) $aRetrievedTableBorders[$i][$j][3] = GUICtrlCreateLabel("", $aTemp[0] + $aTemp[2] - 1, $aTemp[1], 1, $aTemp[3]) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch ;bottom border = 8 Switch $iType Case 8, 9, 10, 11, 12, 13, 14, 15 GUICtrlDelete($aRetrievedTableBorders[$i][$j][4]) $aRetrievedTableBorders[$i][$j][4] = GUICtrlCreateLabel("", $aTemp[0], $aTemp[1] + $aTemp[3] - 1, $aTemp[2], 1) GUICtrlSetBkColor(-1, $iColor) $hLabel = GUICtrlGetHandle(-1) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hLabel, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", 3) EndSwitch Next Next ;- Put retrieved borders back $_aGUICtrlTableBordersINTERNALSTORE[$test][1] = $aRetrievedTableBorders ;refresh window ;DllCall("User32.dll", "int", "InvalidateRect", "hwnd", "", "ptr", 0, "int", True) EndFunc ;==>_GUICtrlTable_Set_Border_All ; #FUNCTION# ;=============================================================================== ; Name...........: _GUICtrlTable_Set_Border_Table ; Description ...: Draws a border around the whole table ; Syntax.........: _GUICtrlTable_Set_Border_Table(ByRef $array[, $iColor = 0x000000]) ; Parameters ....: $array - array returned from _GUICtrlTable_Create ; $iColor - color of border to add ; Return values .: Success - (under construction) ; Failure - (under construction) ; Author ........: AndyBiochem ; =========================================================================================== Func _GUICtrlTable_Set_Border_Table(ByRef $array, $iColor = 0x000000) If IsArray($array) = 0 Then Return _GUICtrlTable_Set_Border_Row($array,1,2,$iColor) _GUICtrlTable_Set_Border_Row($array,UBound($array,1) - 1,8,$iColor) _GUICtrlTable_Set_Border_Column($array,1,1,$iColor) _GUICtrlTable_Set_Border_Column($array,UBound($array,2) - 1,4,$iColor) EndFunc THANKS TO: - Authenticity (demonstrated API/dll z-order calls)1 point -
_GUICtrlMenu_Recent() is for those that enjoy using GUICtrlCreateMenu() and would love to have the ability to have a "Recent" menu list with little to no fuss at all. The UDF contains only 7 functions and due to the design of the UDF, reading the recent menu item that was chosen is very easy indeed. Try the Example provided to get an idea of how it works. Any suggestions or improvements then please post below. Thanks. Example: UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _GUICtrlMenu_Recent_ ; AutoIt Version : v3.3.12.0 or higher ; Language ......: English ; Description ...: Create a recent menu to add previously opened files or other text items to. ; Author(s) .....: guinness ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> ; #GLOBAL VARIABLES# ================================================================================================= Global Const $RECENTMENU_GUID = '051F0003-4E0A-4E4B-8B1A-113B16972254' Global Const $RECENTMENU = 0 Global Const $RECENTMENU_STARTINDEX = 1 Global Enum $RECENTMENU_CAPACITY, $RECENTMENU_ID, $RECENTMENU_INDEX, $RECENTMENU_MENUID, $RECENTMENU_MAX Global Enum $RECENTMENU_CONTROLID, $RECENTMENU_FILEPATH, $RECENTMENU_SHORTPATH ; #CURRENT# ===================================================================================================================== ; _GUICtrlMenu_RecentAdd: Add an item to the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; _GUICtrlMenu_RecentCapacity: Change the total number of items to be displayed in the recent menu. ; _GUICtrlMenu_RecentCreate: Create a recent menu that is added to an existing menu created by GUICtrlCreateMenu(). ; _GUICtrlMenu_RecentDelete: Delete an item in the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; _GUICtrlMenu_RecentDestroy: Destroy the handle created by _GUICtrlMenu_RecentCreate(). ; _GUICtrlMenu_RecentIsInMenu: Search if a filepath or text is currently in the menu list. ; _GUICtrlMenu_RecentSelected: Retrieve the text of a selected menu item and delete from the menu list. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __GUICtrlMenu_RecentDelete ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentAdd ; Description ...: Add an item to the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; Syntax ........: _GUICtrlMenu_RecentAdd(ByRef $aRecentMenu, $sText) ; Parameters ....: $aRecentMenu - $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] ; $sText - Text to be added to the recent menu. ; $bShortText - [optional] Display the text as short text e.g. 'C:\Example...\Test.au3'. Default is False. ; Return values .: Success - ControlID from GUICtrlCreateMenuItem(). ; Failure - 0 and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentAdd(ByRef $aRecentMenu, $sText, $bShortText = False) Local $iError = 1, $iReturn = 0 If __GUICtrlMenu_IsAPI($aRecentMenu) Then _GUICtrlMenu_RecentIsInMenu($aRecentMenu, $sText) __GUICtrlMenu_RecentDelete($aRecentMenu, @extended) If $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] = $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] Then __GUICtrlMenu_RecentDelete($aRecentMenu, $RECENTMENU_STARTINDEX) EndIf Local $sShortText = $sText If IsBool($bShortText) And $bShortText Then $sShortText = StringRegExpReplace($sText, '(^.{3,11}\\|.{11})(.*)(\\.{6,27}|.{27})$', '\1...\3') ; Thanks to AZJIO for the regular expression. EndIf $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] += 1 $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_CONTROLID] = GUICtrlCreateMenuItem($sShortText, $aRecentMenu[$RECENTMENU][$RECENTMENU_MENUID], 0) $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_FILEPATH] = $sText $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_SHORTPATH] = $sShortText $iReturn = $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_CONTROLID] $iError = (($iReturn > 0) ? 1 : 0) EndIf Return SetError($iError, 0, $iReturn) EndFunc ;==>_GUICtrlMenu_RecentAdd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentCapacity ; Description ...: Change the total number of items to be displayed in the recent menu. ; Syntax ........: _GUICtrlMenu_RecentCapacity(ByRef $aRecentMenu, $iCapacity) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; $iCapacity - Maximum total number of recent menu items to be displayed. If this is exceeded then old values will be overwritten. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentCapacity(ByRef $aRecentMenu, $iCapacity) Local $bReturn = False If __GUICtrlMenu_IsAPI($aRecentMenu) Then $iCapacity = Int($iCapacity) If $iCapacity >= $RECENTMENU_STARTINDEX And $iCapacity <> $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] Then $bReturn = True If $iCapacity < $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] Then For $i = $RECENTMENU_STARTINDEX To ($aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] - $iCapacity) GUICtrlDelete($aRecentMenu[$i][$RECENTMENU_CONTROLID]) Next Local $iIndex = ($aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] - $iCapacity) + 1 For $i = $RECENTMENU_STARTINDEX To $iCapacity For $j = 0 To $RECENTMENU_MAX - 1 $aRecentMenu[$i][$j] = $aRecentMenu[$iIndex][$j] Next $iIndex += 1 Next $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] = $iCapacity EndIf $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] = $iCapacity ReDim $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] + $RECENTMENU_STARTINDEX][$RECENTMENU_MAX] EndIf EndIf Return $bReturn EndFunc ;==>_GUICtrlMenu_RecentCapacity ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentCreate ; Description ...: Create a recent menu that is added to an existing menu created by GUICtrlCreateMenu(). ; Syntax ........: _GUICtrlMenu_RecentCreate($iCapacity, $iMenu, $sTitle) ; Parameters ....: $iCapacity - Maximum total number of recent menu items to be displayed. If this is exceeded then old values will be overwritten. ; $iMenu - Existing menu id created by GUICtrlCreateMenu(). ; $sTitle - Title of the recent menu. ; Return values .: Success - Handle to be passed to the recent menu functions. ; Failure - None ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentCreate($iCapacity, $iMenu, $sTitle) If $iCapacity = Default Or Int($iCapacity) <= 0 Then $iCapacity = 10 EndIf Local $aRecentMenu[$iCapacity + $RECENTMENU_STARTINDEX][$RECENTMENU_MAX] $aRecentMenu[$RECENTMENU][$RECENTMENU_ID] = $RECENTMENU_GUID $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] = 0 ; Index of next item. $aRecentMenu[$RECENTMENU][$RECENTMENU_MENUID] = (($iMenu > 0) ? GUICtrlCreateMenu($sTitle, $iMenu) : GUICtrlCreateMenu($sTitle)) $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] = $iCapacity ; Total number of rows. Return $aRecentMenu EndFunc ;==>_GUICtrlMenu_RecentCreate ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentDelete ; Description ...: Delete an item in the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; Syntax ........: _GUICtrlMenu_RecentDelete(ByRef $aRecentMenu, $vIndex) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; $vIndex - Value to be deleted. This can either be an integer of the handle index (see _GUICtrlMenu_RecentIsInMenu() and remarks) ; or a string value of the item. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentDelete(ByRef $aRecentMenu, $vIndex) Local $bReturn = False If __GUICtrlMenu_IsAPI($aRecentMenu) Then If IsString($vIndex) Then _GUICtrlMenu_RecentIsInMenu($aRecentMenu, $vIndex) $vIndex = @extended EndIf $bReturn = __GUICtrlMenu_RecentDelete($aRecentMenu, $vIndex) EndIf Return $bReturn EndFunc ;==>_GUICtrlMenu_RecentDelete ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentDestroy ; Description ...: Destroy the handle created by _GUICtrlMenu_RecentCreate(). ; Syntax ........: _GUICtrlMenu_RecentDestroy(ByRef $aRecentMenu) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentDestroy(ByRef $aRecentMenu) Local $bReturn = False If __GUICtrlMenu_IsAPI($aRecentMenu) Then $bReturn = True For $i = $RECENTMENU_STARTINDEX To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] GUICtrlDelete($aRecentMenu[$i][$RECENTMENU_CONTROLID]) Next EndIf $aRecentMenu = 0 Return $bReturn EndFunc ;==>_GUICtrlMenu_RecentDestroy ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentIsInMenu ; Description ...: Search if a filepath or text is currently in the menu list. ; Syntax ........: _GUICtrlMenu_RecentIsInMenu(ByRef $aRecentMenu, $sText) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; $sText - Text to search for. This is a case-sensitive search. ; Return values .: Success - True and sets @extended to the index position of the text. ; Failure - False and sets @extended to zero. ; Author ........: guinness ; Remarks .......: @extended is set to the index position in the handle. This is useful if using GUICtrlMenu_RecentDelete(). ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentIsInMenu(ByRef $aRecentMenu, $sText) Local $bReturn = False, _ $iExtended = 0 If __GUICtrlMenu_IsAPI($aRecentMenu) Then For $i = $RECENTMENU_STARTINDEX To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] If ($sText == $aRecentMenu[$i][$RECENTMENU_FILEPATH]) Or ($sText == $aRecentMenu[$i][$RECENTMENU_SHORTPATH]) Then $bReturn = True $iExtended = $i ExitLoop EndIf Next EndIf Return SetExtended($iExtended, $bReturn) EndFunc ;==>_GUICtrlMenu_RecentIsInMenu ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentSelected ; Description ...: Retrieve the text of a selected menu item and delete from the menu list. ; Syntax ........: _GUICtrlMenu_RecentSelected(ByRef $aRecentMenu, $iMsg) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate().. ; $iMsg - Message id returned by GUIGetMsg(). ; Return values .: Success - Text of the selected menu. ; Failure - Null and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentSelected(ByRef $aRecentMenu, $iMsg) Local $iError = 1, _ $sReturn = Null If $iMsg > 0 And __GUICtrlMenu_IsAPI($aRecentMenu) Then For $i = $RECENTMENU_STARTINDEX To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] If $iMsg = $aRecentMenu[$i][$RECENTMENU_CONTROLID] Then $iError = 0 $sReturn = $aRecentMenu[$i][$RECENTMENU_FILEPATH] __GUICtrlMenu_RecentDelete($aRecentMenu, $i) ExitLoop EndIf Next EndIf Return SetError($iError, 0, $sReturn) EndFunc ;==>_GUICtrlMenu_RecentSelected ; #INTERNAL_USE_ONLY#============================================================================================================ Func __GUICtrlMenu_RecentDelete(ByRef $aRecentMenu, $iIndex) Local $bReturn = False If $iIndex >= $RECENTMENU_STARTINDEX And $iIndex <= $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] And GUICtrlDelete($aRecentMenu[$iIndex][$RECENTMENU_CONTROLID]) Then $bReturn = True Local $iSwap = 0 For $i = $iIndex To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] - 1 For $j = 0 To $RECENTMENU_MAX - 1 $iSwap = $i + 1 $aRecentMenu[$i][$j] = $aRecentMenu[$iSwap][$j] $aRecentMenu[$iSwap][$j] = Null Next Next $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] -= 1 EndIf Return $bReturn EndFunc ;==>__GUICtrlMenu_RecentDelete Func __GUICtrlMenu_IsAPI(ByRef $aRecentMenu) Return UBound($aRecentMenu, $UBOUND_COLUMNS) = $RECENTMENU_MAX And $aRecentMenu[$RECENTMENU][$RECENTMENU_ID] = $RECENTMENU_GUID EndFunc ;==>__GUICtrlMenu_IsAPI Example 1: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include '_GUICtrlMenu_Recent.au3' Example() Func Example() Local $hGUI = GUICreate('_GUICtrlMenu_Recent() Example', 300, 200) Local $iFileMenu = GUICtrlCreateMenu('&File') Local $iOpen = GUICtrlCreateMenuItem('Open', $iFileMenu) GUICtrlSetState($iOpen, $GUI_DEFBUTTON) ; Create a recent menu with a maximum of 5 displayed items. Local $hRecentMenu = _GUICtrlMenu_RecentCreate(5, $iFileMenu, 'Recent Files') GUICtrlCreateMenuItem('', $iFileMenu) ; Seperator Line. GUICtrlCreateMenuItem('Save', $iFileMenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $iExit = GUICtrlCreateMenuItem('Exit', $iFileMenu) Local $iOpenFile = GUICtrlCreateButton('Open File', 5, 10, 85, 25) Local $iIncreaseItems = GUICtrlCreateButton('Increase Recent List', 5, 35, 115, 25) GUISetState(@SW_SHOW, $hGUI) ; Add the current script to the recent menu. _GUICtrlMenu_RecentAdd($hRecentMenu, @ScriptFullPath, True) Local $iMsg = 0, _ $sFilePath = '' While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $iExit ExitLoop Case $iOpenFile, $iOpen $sFilePath = FileOpenDialog('Choose File...', @ScriptDir, 'All (*.*)') If Not @error Then ; Check whether or not the filepath is currently in the recent menu. If it isn't then add to the recent menu. If Not _GUICtrlMenu_RecentIsInMenu($hRecentMenu, $sFilePath) Then ; If the button or open menu items are selected then add a filepath to the recent menu. _GUICtrlMenu_RecentAdd($hRecentMenu, $sFilePath, True) ; Display the text as short text. EndIf EndIf Case $iIncreaseItems ; Increase the capacity to 20 items instead of the previous 5. If _GUICtrlMenu_RecentCapacity($hRecentMenu, 20) Then MsgBox($MB_SYSTEMMODAL, '', 'The recent menu list was increased to a maximum of 20 items.', 0, $hGUI) Else MsgBox($MB_SYSTEMMODAL, '', 'The recent menu list wasn''t increased to a maximum of 20 items. An error occurred.', 0, $hGUI) EndIf Case Else ; Check if the message id returned by GUIGetMsg() is present in the recent menu list. $sFilePath = _GUICtrlMenu_RecentSelected($hRecentMenu, $iMsg) If Not @error Then MsgBox($MB_SYSTEMMODAL, '', 'The recent menu was selected and the following item was chosen' & @CRLF & _ @CRLF & _ $sFilePath, 0, $hGUI) EndIf EndSwitch WEnd ; Destroy the recent menu. _GUICtrlMenu_RecentDestroy($hRecentMenu) GUIDelete($hGUI) EndFunc ;==>Example All of the above has been included in a ZIP file. GUICtrlMenu_Recent.zip1 point
-
As promised, here is my zip-from-scratch udf. It is not at all a substitute for any of the other functional udf's, but merely a good base if doing it from scratch yourself. I have used this code myself s part of a steganographic example with ooXML documents (but excluded from this udf), and it is very nice when you have such control over a zip file without being dependant on external libraries. The code will currently only generate three global 2-dimensional arrays; 1. The local file headers. 2. The central directory headers. 3. The central directory end. The data descriptor, which is rarely used, is not included. However, I believe most fields are included in the arrays. When working with the zip content, it is advisable to use Ward's machine code udf's for zlib and crc32 (compression and checksum). It works fine on both x86 and x64. If you wonder what the heck you would need this for, then you probably don't need it, so move on. Anyways, apoligies for the weird coding style and variable names. I doubt that I will have time to expand on this udf, which is the reason I share it incase others feel like. Link to some documentation; http://en.wikipedia.org/wiki/Zip_(file_format) and http://www.pkware.com/documents/casestudies/APPNOTE.TXT Joakim ZIP_STRUCTS.au31 point
-
Alupis, You know you are not welcome here. M231 point
-
Au3Recorder, it comes with the standard download of AutoIt.1 point
-
Graphic Elements on GUIs
mesale0077 reacted to UEZ for a topic
Try this: ; ; Script to test images as buttons on floating PNG backdrop ; #NoTrayIcon ; #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> $STM_SETIMAGE = 0x0172 ;Global $HBitmap = "" ;=================== create GUI for this process ================ _GDIPlus_Startup() ; Fetch the backdrop image $backdrop = @ScriptDir & "\Panel.png" $hImage = _GDIPlus_ImageLoadFromFile($backdrop) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBitmap_Exit = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\exit.bmp") $hBitmap_Button = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\BUTTON.png") _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Exit, 160, 100) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Button, 20, 20) ; create the main GUI and load with image Global $GUI = GUICreate("Test", $width, $height, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) $exit = GUICtrlCreateLabel("", 163, 103, 99, 57, -1, $GUI_WS_EX_PARENTDRAG) $button = GUICtrlCreateLabel("", 23, 23, 142, 73, -1, $GUI_WS_EX_PARENTDRAG) SetBitmap($GUI, $hImage, 255) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") Global $hGUI_Child = GUICreate("", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $GUI) GUISetBkColor(0xABCDEF, $hGUI_Child) GUICtrlCreateLabel("Text on panel", 50, 160, 140, 50) GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5) _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF) GUISetState(@SW_SHOWNA, $GUI) GUISetState(@SW_SHOW, $hGUI_Child) ; ============= Run the GUI until the user closes it ============= While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $exit _Exit() Case $button MsgBox(0, "BUTTON", "clicked", 0, $GUI) EndSwitch WEnd ;============== functions ============================= Func _Exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap_Exit) _GDIPlus_BitmapDispose($hBitmap_Button) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST Func SetBitmap($hGUI, $hImage, $iOpacity) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Br, UEZ1 point -
thx i removed the +1 now its woring! idk why i added this xD1 point
-
Yeah ravkr, forgot to say so earlier; nice contribution, it looks great. RT1 point
-
Need some functions that would help me use auto it to implement a genetic algorithm
NoLandsMan reacted to Mat for a topic
Why are you using floats? You get less bit-pairs in a float than in an integer of equivalent size. Are the floats always between 0 and 1, that would make it a lot easier (though also reduce you to pretty much using integers). Using base 4 would mean each gene is a single digit.1 point -
1 point
-
1 point
-
UDF is made on base of the library zLib. The original library zLib does not support removing the files from archive and, accordingly, does not support overwriting the files in archive, at coincidence of the names. In given library is implemented to overwrite files in the archive with the same name by method repacking of the archive, similarly that, as this does, for instance WinRar. UDF: Global Const $pZip_dll = @ScriptDir & '\pZip.dll' ; #FUNCTION# ===================================================================== ; Name...........: _zip_FileInfo ; Description....: Get file information from all files in current archive. ; Syntax.........: _zip_FileInfo($sFile) ; Parameters.....: $sFile - The path of the archive. ; Return values..: The array that contains the following information. ; ; [0][0] = Number of entries ; [n][0] - nth Filename. ; [n][1] - nth Compressed Size ; [n][2] - nth Uncompressed Size ; [n][3] - nth Last Modification Date ; [n][4] - nth Crc32 ; [n][5] - nth Compression Method ; ; Author.........: asdf8 ; ================================================================================ Func _zip_FileInfo($sFile) Local $ret[1][6], $res, $tmp, $i, $j If Not $sFile Or Not FileExists($sFile) Then Return SetError(1, 0, $ret) $res = DllCall($pZip_dll, 'str', 'pZIP_FileInfo', 'str', $sFile) If Not IsArray($res) Then Return SetError(2, 0, $ret) If $res[0] Then $res = StringRegExp($res[0], '([^|]+)', 3) ReDim $ret[UBound($res) + 1][6] $ret[0][0] = UBound($res) $ret[0][1] = 'Compressed Size' $ret[0][2] = 'Uncompressed Size' $ret[0][3] = 'Date' $ret[0][4] = 'Crc32' $ret[0][5] = 'Compression Method' For $i = 1 To $ret[0][0] $tmp = StringSplit($res[$i - 1], '*', 2) For $j = 0 To 5 $ret[$i][$j] = $tmp[$j] Next Next EndIf Return SetError(0, 0, $ret) EndFunc ; #FUNCTION# ===================================================================== ; Name...........: _zip_FindFile ; Description....: Find file in archive. ; Syntax.........: _zip_FindFile($sFile, $FindName[, $IncludingPath = 1]) ; Parameters.....: $sFile - The path of the archive. ; $FindName - The filename to find. ; $IncludingPath - 0 search only for filename. ; 1 (default), search for path + filename. ; Return values..: Success - The array file info. ; ; [0] - nth Filename. ; [1] - nth Compressed Size ; [2] - nth Uncompressed Size ; [3] - nth Last Modification Date ; [4] - nth Crc32 ; [5] - nth Compression Method ; ; Failure - (-1) if not found. ; Author.........: asdf8 ; ================================================================================ Func _zip_FindFile($sFile, $FindName, $IncludingPath = 1) If Not $sFile Or Not FileExists($sFile) Or Not $FindName Then Return SetError(1, 0, -1) Local $res = DllCall($pZip_dll, 'str', 'pZIP_FindFile', 'str', $sFile, 'str', $FindName, 'int', $IncludingPath) If Not IsArray($res) Then Return SetError(2, 0, -1) If $res[0] Then $res = StringSplit($res[0], '*', 2) Return SetError(0, 0, $res) Else Return SetError(0, 0, -1) EndIf EndFunc ; #FUNCTION# ===================================================================== ; Name...........: _zip_AddFiles ; Description....: Add files to archive. ; Syntax.........: _zip_AddFiles($sFile, $FilePathMask, $StoreRelPath = 1, $Recursive = 1) ; Parameters.....: $sFile - The path of the archive. ; $FilePathMask - File mask supports wildcards. ; $StoreRelPath - 0 Store Only filename. ; 1 (default), store path relative basedir. ; $Recursive - 0 no recursive search. ; 1 (default), recursive file search. ; 2 recursive file search and add empty directories (use only if necessary). ; Return values..: Number of added files. ; Author.........: asdf8 ; ================================================================================ Func _zip_AddFiles($sFile, $FilePathMask, $StoreRelPath = 1, $Recursive = 1) If Not $sFile Or Not $FilePathMask Then Return SetError(1, 0, 0) Local $res = DllCall($pZip_dll, 'int', 'pZIP_AddFiles', 'str', $sFile, 'str', $FilePathMask, 'int', $StoreRelPath, 'int', $Recursive) If Not IsArray($res) Then Return SetError(2, 0, -1) Return SetError(0, 0, $res[0]) EndFunc ; #FUNCTION# ===================================================================== ; Name...........: _zip_ExtractFiles ; Description....: Extract files from archive. ; Syntax.........: _zip_ExtractFiles($sFile, $OutputPath[, $FileMask = ""[, $IncludingPath = 1]]) ; Parameters.....: $sFile - The path of the archive. ; $OutputPath - Output path. ; $FileMask - File mask supports wildcards. ; $IncludingPath - 0 only filename is extracted. ; 1 (default), the complete filename (including path) is extracted. ; Return values..: Number of extracted files. ; Author.........: asdf8 ; ================================================================================ Func _zip_ExtractFiles($sFile, $OutputPath, $FileMask = "", $IncludingPath = 1) If Not $sFile Or Not FileExists($sFile) Or Not $OutputPath Then Return SetError(1, 0, 0) Local $res = DllCall($pZip_dll, 'int', 'pZIP_ExtractFiles', 'str', $sFile, 'str', $OutputPath, 'str', $FileMask, 'int', $IncludingPath) If Not IsArray($res) Then Return SetError(2, 0, -1) Return SetError(0, 0, $res[0]) EndFunc Example: #Include <Array.au3>; need only for "_ArrayDisplay" #Include <pZip.au3> $inFile = @ScriptDir & '\Test.zip' $OutPath = @DesktopDir & '\Test_zip\123' $toZip = @ScriptDir $ret = _zip_AddFiles($inFile, $toZip) $ar = _zip_FileInfo($inFile) _ArrayDisplay($ar, '-1-AddFiles->' & $ret & '--error>' & @error) $ar = _zip_FindFile($inFile, @ScriptName, 1) If IsArray($ar) Then _ArrayDisplay($ar, '-FindFile->' & @ScriptName & '--error>' & @error) Else ConsoleWrite('Not Find File ' & @ScriptName & @CRLF) EndIf FileCopy(@ScriptFullPath, @ScriptDir & '\123\_' & @ScriptName, 9) $ret = _zip_AddFiles($inFile, @ScriptDir & '\_' & @ScriptName, 1, 1) $ar = _zip_FileInfo($inFile) _ArrayDisplay($ar, '-2-AddFiles->' & $ret & '--error>' & @error) $ret = _zip_AddFiles($inFile, @ScriptDir & '\123\_' & @ScriptName, 0, 1) $ar = _zip_FileInfo($inFile) _ArrayDisplay($ar, '-3-AddFiles->' & $ret & '--error>' & @error) $ret = _zip_AddFiles($inFile, @ScriptDir & '\*.au3', 1, 1) $ar = _zip_FileInfo($inFile) _ArrayDisplay($ar, '-4-AddFiles->' & $ret & '--error>' & @error) $ret = _zip_ExtractFiles($inFile, $OutPath);$FileMask = "*.au3" ConsoleWrite('Extract Files >' & $ret & '--error>' & @error & @CRLF) ShellExecute($OutPath) MsgBox(0, '', 'Delete all temp files') DirRemove(@ScriptDir & '\123', 1) DirRemove(@DesktopDir & '\Test_zip', 1) FileDelete($inFile) Only for x86. New in version 2: - added support for working with encrypted files. - added support for various compression methods. - added item "Flag Encrypted" for file info. - enhanced support for masks of files and folders. New in version 3: - fixed critical bugs version 2 pZip.rar pZip_v3.rar1 point
-
Graph UDF UPDATED 14/10/09
mLipok reacted to andybiochem for a topic
UPDATED 14/10/09 EDIT - also see my new GDI+ version of this UDF Hi! I've created a lot of programs/calculators that use graphs, and have been meaning to create a simple UDF to allow quick creation of graphs and their x / y axes. Here is what I have done so far, I'll add other features as I come up with them.... hopefully it should end up with things like bar-charts, scatter plots etc in the future. FUNCTIONS: _Graph_Create ...............creates the graph area _Graph_Clear..................removes any plotted items _Graph_Delete.................deletes graph and labels _Graph_SetRange_X.........sets the x axis _Graph_SetRange_Y.........sets the Y axis _Graph_Plot_Start............moves the starting plot position (equivalent to $GUI_GR_MOVE) _Graph_Plot_Line.............draws a line NEW FUNCTIONS (14/10/09): _Graph_Plot_Point.............plots small square around x,y _Graph_Plot_Dot...................plots a single pixel at x,y _Graph_Set_PenSize................sets next pen size _Graph_Set_Color..................sets the colour/background colour of next drawing _Graph_Plot_Bar_X.................plots a bar chart bar along the x axis _Graph_Plot_Bar_Y.................plots a bar chart bar along the y axis _Graph_SetGrid_X..................sets the x axis grid _Graph_SetGrid_Y..................sets the y axis grid The UDF: Graph UDF.au3 #include-once #include <GUIConstantsEx.au3> ; #FUNCTION# ============================================================================ ; Name...........: _Graph_Create ; Description ...: Creates graph area, and prepares array of specified data ; Syntax.........: _Graph_Create($iLeft,$iTop,$iWidth,$iHeight) ; Parameters ....: $iLeft - left most position in GUI ; $iTop - top most position in GUI ; $iWidth - width of graph in pixels ; $iHeight - height of graph in pixels ; Return values .: Returns array containing variables for subsequent functions... ; Returned Graph array is: ; [1] graphic control handle ; [2] left ; [3] top ; [4] width ; [5] height ; [6] x low ; [7] x high ; [8] y low ; [9] y high ; [10] x ticks handles ; [11] x labels handles ; [12] y ticks handles ; [13] y labels handles ; [14] Border Colour ; [15] Fill Colour ; ======================================================================================= Func _Graph_Create($iLeft,$iTop,$iWidth,$iHeight,$hColourBorder = 0x000000,$hColorFill = 0xFFFFFF) $hWnd = GUICtrlCreateGraphic($iLeft,$iTop,$iWidth+1,$iHeight+1) GUICtrlSetColor(-1,$hColourBorder) GUICtrlSetBkColor(-1,$hColorFill) Local $ahTicksLabelsX[1] Local $ahTicksLabelsY[1] Local $ahTicksX[1] Local $ahTicksY[1] Dim $aGraphArray[16] = ["",$hWnd,$iLeft,$iTop,$iWidth,$iHeight,0,1,0,1, _ $ahTicksX,$ahTicksLabelsX,$ahTicksY,$ahTicksLabelsY,$hColourBorder,$hColorFill] Return $aGraphArray EndFunc ; #FUNCTION# ============================================================================ ; Name...........: _Graph_Delete ; Description ...: Deletes previously created graph and related ticks/labels ; Syntax.........: _Graph_Delete(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; ======================================================================================= Func _Graph_Delete(ByRef $aGraphArray) ;----- delete x ticks/labels ----- $ahTicksX = $aGraphArray[10] $ahTicksLabelsX = $aGraphArray[11] For $i = 1 to (UBound($ahTicksX) - 1) GUICtrlDelete($ahTicksX[$i]) Next For $i = 1 to (UBound($ahTicksLabelsX) - 1) GUICtrlDelete($ahTicksLabelsX[$i]) Next ;----- delete y ticks/labels ----- $ahTicksY = $aGraphArray[12] $ahTicksLabelsY = $aGraphArray[13] For $i = 1 to (UBound($ahTicksY) - 1) GUICtrlDelete($ahTicksY[$i]) Next For $i = 1 to (UBound($ahTicksLabelsY) - 1) GUICtrlDelete($ahTicksLabelsY[$i]) Next Dim $ahTicksLabelsY[1] ;----- delete graphic control ----- GUICtrlDelete($aGraphArray[1]) ;----- close array ----- $aGraphArray = 0 EndFunc ; #FUNCTION# ============================================================================ ; Name...........: _Graph_Clear ; Description ...: Clears graph content ; Syntax.........: _Graph_Clear(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; ======================================================================================= Func _Graph_Clear(ByRef $aGraphArray) GUICtrlDelete($aGraphArray[1]) $aGraphArray[1] = GUICtrlCreateGraphic($aGraphArray[2],$aGraphArray[3], _ $aGraphArray[4]+1,$aGraphArray[5]+1) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetColor(-1,0x000000) EndFunc ; #FUNCTION# ============================================================================ ; Name...........: _Graph_SetRange_X ; Description ...: Allows user to set the range of the X axis and set ticks and rounding levels ; Syntax.........: _Graph_SetRange_X(ByRef $aGraphArray,$iLow,$iHigh,$iXTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iLow - the lowest value for the X axis (can be negative) ; $iHigh - the highest value for the X axis ; $iXTicks - [optional] number of ticks to show below axis, if = 0 then no ticks created ; $bLabels - [optional] 1=show labels, any other number=do not show labels ; $iRound - [optional] rounding level of label values ; ======================================================================================= Func _Graph_SetRange_X(ByRef $aGraphArray,$iLow,$iHigh,$iXTicks = 1,$bLabels = 1,$iRound = 0) ;----- load user vars to array ----- $aGraphArray[6] = $iLow $aGraphArray[7] = $iHigh ;----- prepare nested array ----- $ahTicksX = $aGraphArray[10] $ahTicksLabelsX = $aGraphArray[11] ;----- delete any existing ticks ----- For $i = 1 to (UBound($ahTicksX) - 1) GUICtrlDelete($ahTicksX[$i]) Next Dim $ahTicksX[1] ;----- create new ticks ----- For $i = 1 To $iXTicks + 1 ReDim $ahTicksX[$i + 1] $ahTicksX[$i] = GUICtrlCreateLabel("",(($i - 1) * ($aGraphArray[4] / $iXTicks)) + $aGraphArray[2], _ $aGraphArray[3] + $aGraphArray[5],1,5) GUICtrlSetBkColor(-1,0x000000) GUICtrlSetState(-1,$GUI_DISABLE) Next ;----- delete any existing labels ----- For $i = 1 to (UBound($ahTicksLabelsX) - 1) GUICtrlDelete($ahTicksLabelsX[$i]) Next Dim $ahTicksLabelsX[1] ;----- create new labels ----- For $i = 1 To $iXTicks + 1 ReDim $ahTicksLabelsX[$i + 1] $ahTicksLabelsX[$i] = GUICtrlCreateLabel("", _ ($aGraphArray[2] + (($aGraphArray[4] / $iXTicks) * ($i - 1))) - (($aGraphArray[4] / $iXTicks) / 2), _ $aGraphArray[3] + $aGraphArray[5] + 10,$aGraphArray[4] / $iXTicks,13,1) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsX) - 1) GUICtrlSetData($ahTicksLabelsX[$i], _ StringFormat("%." & $iRound & "f",_Graph_Reference_Pixel("p",(($i - 1) * ($aGraphArray[4] / $iXTicks)), _ $aGraphArray[6],$aGraphArray[7],$aGraphArray[4]))) Next EndIf ;----- load created arrays back into array ----- $aGraphArray[10] = $ahTicksX $aGraphArray[11] = $ahTicksLabelsX EndFunc ; #FUNCTION# ============================================================================ ; Name...........: _Graph_SetRange_Y ; Description ...: Allows user to set the range of the Y axis and set ticks and rounding levels ; Syntax.........: _Graph_SetRange_Y(ByRef $aGraphArray,$iLow,$iHigh,$iYTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iLow - the lowest value for the Y axis (can be negative) ; $iHigh - the highest value for the Y axis ; $iYTicks - [optional] number of ticks to show next to axis, if = 0 then no ticks created ; $bLabels - [optional] 1=show labels, any other number=do not show labels ; $iRound - [optional] rounding level of label values ; ======================================================================================= Func _Graph_SetRange_Y(ByRef $aGraphArray,$iLow,$iHigh,$iYTicks = 1,$bLabels = 1,$iRound = 0) ;----- load user vars to array ----- $aGraphArray[8] = $iLow $aGraphArray[9] = $iHigh ;----- prepare nested array ----- $ahTicksY = $aGraphArray[12] $ahTicksLabelsY = $aGraphArray[13] ;----- delete any existing ticks ----- For $i = 1 to (UBound($ahTicksY) - 1) GUICtrlDelete($ahTicksY[$i]) Next Dim $ahTicksY[1] ;----- create new ticks ----- For $i = 1 To $iYTicks + 1 ReDim $ahTicksY[$i + 1] $ahTicksY[$i] = GUICtrlCreateLabel("",$aGraphArray[2] - 5, _ ($aGraphArray[3] + $aGraphArray[5]) - (($aGraphArray[5] / $iYTicks) * ($i - 1)),5,1) GUICtrlSetBkColor(-1,0x000000) GUICtrlSetState(-1,$GUI_DISABLE) Next ;----- delete any existing labels ----- For $i = 1 to (UBound($ahTicksLabelsY) - 1) GUICtrlDelete($ahTicksLabelsY[$i]) Next Dim $ahTicksLabelsY[1] ;----- create new labels ----- For $i = 1 To $iYTicks + 1 ReDim $ahTicksLabelsY[$i + 1] $ahTicksLabelsY[$i] = GUICtrlCreateLabel("",$aGraphArray[2] - 40, _ ($aGraphArray[3] + $aGraphArray[5]) - (($aGraphArray[5] / $iYTicks) * ($i - 1)) - 6,30,13,2) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsY) - 1) GUICtrlSetData($ahTicksLabelsY[$i],StringFormat("%." & $iRound & "f",_Graph_Reference_Pixel("p", _ (($i - 1) * ($aGraphArray[5] / $iYTicks)),$aGraphArray[8],$aGraphArray[9],$aGraphArray[5]))) Next EndIf ;----- load created arrays back into array ----- $aGraphArray[12] = $ahTicksY $aGraphArray[13] = $ahTicksLabelsY EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Start ; Description ...: Move starting point of plot ; Syntax.........: _Graph_Plot_Start(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to start at ; $iY - y value to start at ; ======================================================================================== Func _Graph_Plot_Start(ByRef $aGraphArray,$iX,$iY) ;----- MOVE pen to start point ----- GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_MOVE, _ _Graph_Reference_Pixel("x",$iX,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]), _ _Graph_Reference_Pixel("y",$iY,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5])) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Line ; Description ...: draws straight line to x,y from previous point / starting point ; Syntax.........: _Graph_Plot_Line(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to draw to ; $iY - y value to draw to ; ======================================================================================== Func _Graph_Plot_Line(ByRef $aGraphArray,$iX,$iY) ;----- Draw line from previous point to new point ----- GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_LINE, _ _Graph_Reference_Pixel("x",$iX,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]), _ _Graph_Reference_Pixel("y",$iY,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5])) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Point ; Description ...: draws point at coords ; Syntax.........: _Graph_Plot_Point(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _Graph_Plot_Point(ByRef $aGraphArray,$iX,$iY) ;----- Draw point from previous point to new point ----- GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_DOT, _ _Graph_Reference_Pixel("x",$iX,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]), _ _Graph_Reference_Pixel("y",$iY,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5])) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Dot ; Description ...: draws single pixel dot at coords ; Syntax.........: _Graph_Plot_Dot(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _Graph_Plot_Dot(ByRef $aGraphArray,$iX,$iY) ;----- Draw point from previous point to new point ----- GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_PIXEL, _ _Graph_Reference_Pixel("x",$iX,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]), _ _Graph_Reference_Pixel("y",$iY,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5])) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Set_Color ; Description ...: sets the color for the next drawing ; Syntax.........: _Graph_Set_Color(ByRef $aGraphArray,$hColor,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $hColor - the color of the next item ; $hBkGrdColor - the background color of the next item ; ======================================================================================== Func _Graph_Set_Color(ByRef $aGraphArray,$hColor,$hBkGrdColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_COLOR,$hColor,$hBkGrdColor) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Set_PenSize ; Description ...: sets the pen for the next drawing ; Syntax.........: _Graph_Set_PenSize(ByRef $aGraphArray,$iSize = 1) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iSize - size of pen line ; ======================================================================================== Func _Graph_Set_PenSize(ByRef $aGraphArray,$iSize = 1) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_PENSIZE,$iSize) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Bar_X ; Description ...: Draws bar chart bar from the x axis ; Syntax.........: _Graph_Plot_Bar_X(ByRef $aGraphArray,$iStart,$iWidth,$nYValue,$hColor = 0x000000,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iStart - the x axis value for start of bar (in x axis units) ; $iWidth - width of the bar (in x axis units) ; $nYValue - 'height' of the bar (in y axis units) ; $hColor - Bar border colour ; $hBkGrdColor - Bar fill colour ; ======================================================================================== Func _Graph_Plot_Bar_X(ByRef $aGraphArray,$iStart,$iWidth,$nYValue,$hColor = 0x000000,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ;----- Draw Bar for BarChart Application ----- _Graph_Set_Color($aGraphArray,$hColor,$hBkGrdColor) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_RECT, _ _Graph_Reference_Pixel("x",$iStart,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]), _ ;x $aGraphArray[5]+1, _ Round(_Graph_Reference_Pixel("x",$iStart + $iWidth,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]) - _ ;width _Graph_Reference_Pixel("x",$iStart,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]) + 1), _ - $aGraphArray[5] + _Graph_Reference_Pixel("y",$nYValue,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5]) - 1) ;height ;- redraw axis in case coloured - _Graph_Set_Color($aGraphArray,$aGraphArray[14],$GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_RECT,0,0,$aGraphArray[4]+1,$aGraphArray[5]+1) ;- set colour back to default - _Graph_Set_Color($aGraphArray,0x000000,$GUI_GR_NOBKCOLOR) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Plot_Bar_Y ; Description ...: Draws bar chart bar from the y axis ; Syntax.........: _Graph_Plot_Bar_Y(ByRef $aGraphArray,$iStart,$iWidth,$nYValue,$hColor = 0x000000,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $iStart - the y axis value for start of bar (in y axis units) ; $iWidth - width of the bar (in y axis units) ; $nXValue - 'length' of the bar (in x axis units) ; $hColor - Bar border colour ; $hBkGrdColor - Bar fill colour ; ======================================================================================== Func _Graph_Plot_Bar_Y(ByRef $aGraphArray,$iStart,$iWidth,$nYValue,$hColor = 0x000000,$hBkGrdColor = $GUI_GR_NOBKCOLOR) ;----- Draw Bar for BarChart Application ----- _Graph_Set_Color($aGraphArray,$hColor,$hBkGrdColor) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_RECT, _ 0, _ ;x _Graph_Reference_Pixel("y",$iStart + $iWidth,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5]), _ ;y _Graph_Reference_Pixel("x",$nYValue,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]) + 1, _ ;width _Graph_Reference_Pixel("y",$iStart,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5]) - _ ;height _Graph_Reference_Pixel("y",$iStart + $iWidth,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5]) + 1) ;- redraw axis in case coloured - _Graph_Set_Color($aGraphArray,$aGraphArray[14],$GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_RECT,0,0,$aGraphArray[4]+1,$aGraphArray[5]+1) ;- set colour back to default - _Graph_Set_Color($aGraphArray,0x000000,$GUI_GR_NOBKCOLOR) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_SetGrid_X ; Description ...: Adds X gridlines. ; Syntax.........: _Graph_SetGrid(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining color of grid. Default is a light gray ; ======================================================================================= Func _Graph_SetGrid_X(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) _Graph_Set_Color($aGraphArray,$hColor,$GUI_GR_NOBKCOLOR) Select Case $Ticks > 0 For $i = $aGraphArray[6] To $aGraphArray[7] Step $Ticks If $i = Number($aGraphArray[6]) Or $i = Number($aGraphArray[7]) Then ContinueLoop GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_RECT, _ ;rectangle _Graph_Reference_Pixel("x",$i,$aGraphArray[6],$aGraphArray[7],$aGraphArray[4]), _ ;x 1, _ ;y 1, _ ;width $aGraphArray[5] - 1) ;height Next EndSelect _Graph_Set_Color($aGraphArray,0x000000) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_SetGrid_Y ; Description ...: Adds Y gridlines. ; Syntax.........: _Graph_SetGrid(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining color of grid. Default is a light gray ; ======================================================================================= Func _Graph_SetGrid_Y(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) _Graph_Set_Color($aGraphArray,$hColor,$GUI_GR_NOBKCOLOR) Select Case $Ticks > 0 For $i = $aGraphArray[8] To $aGraphArray[9] Step $Ticks If $i = Number($aGraphArray[8]) Or $i = Number($aGraphArray[9]) Then ContinueLoop GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_RECT, _ ;rectangle 1, _ ;x _Graph_Reference_Pixel("y",$i,$aGraphArray[8],$aGraphArray[9],$aGraphArray[5]), _ ;y $aGraphArray[4] - 1, _ ;width 1) ;height Next EndSelect _Graph_Set_Color($aGraphArray,0x000000) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Refresh ; Description ...: refreshes the graphic ; Syntax.........: _Graph_Refresh(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _Graph_Create ; ======================================================================================== Func _Graph_Refresh(ByRef $aGraphArray) GUICtrlSetGraphic($aGraphArray[1],$GUI_GR_REFRESH) EndFunc ; #FUNCTION# ============================================================================= ; Name...........: _Graph_Reference_Pixel ; Description ...: INTERNAL FUNCTION - performs pixel reference calculations ; Syntax.........: _Graph_Reference_Pixel($iType,$iValue,$iLow,$iHigh,$iTotalPixels) ; Parameters ....: $iType - "x"=x axis pix, "y" = y axis pix, "p"=value from pixels ; $iValue - pixels reference or value ; $iLow - lower limit of axis ; $iHigh - upper limit of axis ; $iTotalPixels - total number of pixels in range (either width or height) ; ========================================================================================= Func _Graph_Reference_Pixel($iType,$iValue,$iLow,$iHigh,$iTotalPixels) ;----- perform pixel reference calculations ----- Switch $iType Case "x" Return (($iTotalPixels/($iHigh-$iLow))*(($iHigh-$iLow)*(($iValue-$iLow)/($iHigh-$iLow)))) Case "y" Return ($iTotalPixels - (($iTotalPixels/($iHigh-$iLow))*(($iHigh-$iLow)*(($iValue-$iLow)/($iHigh-$iLow))))) Case "p" Return ($iValue / ($iTotalPixels/ ($iHigh - $iLow))) + $iLow EndSwitch EndFunc Example usage: Notes: Thanks to joseLB for looking at adding grid lines to the graph area. I hope you don't mind, but I changed the approach quite a bit. I wanted to keep it in line with the 'standardised' approach of the other functions. Actually, I wish I'd approached this UDF in a completely different way now, but it's used throughout my statistical software and major changes would render those programs useless! argh! Feel free to comment / criticise!1 point