Leaderboard
Popular Content
Showing content with the highest reputation on 04/06/2015 in all areas
-
You have to have the file encoding in SciTE set for UTF8 so it will show correctly.2 points
-
LAST VERSION - 1.0 02-Feb-15 This UDF allows to use API Virtual Hard Disk (VHD) in AutoIt scripts. VHD format is a publicly-available image format specification that specifies a virtual hard disk encapsulated in a single file, capable of hosting native file systems while supporting standard disk and file operations. VHD is supported on Windows 7 and Windows Server 2008 R2. WinAPIVhd UDF written for AutoIt 3.3.6.x or later, however, if you are using AutiIt 3.3.12.x, you can integrate this library into AutoIt package (see below). The library contains a detailed help file (WinAPIVhd.chm) in AutoIt style, syntax highlighting and calltips files for SciTE (required full version), and full examples. I hope that many users will find this library useful. Moreover, I created two icons for the file types .vhd (Virtual Hard Disk) and .vhdx (Hyper-V Virtual Hard Disk) which you can use for yourself. You can also download more document icons in the same style for AutoIt, Restorator, etc. To associate icons with the required file types, you can use my simple utility >File Types Manager. Installation (optionaly) If you are using AutiIt 3.3.12.0 or later, you can integrate WinAPIVhd UDF library into AutoIt package. This will add the calltips and syntax highlighting for new functions, and provide a simpler way to include the library in your scripts. To integrate WinAPIVhd UDF library into AutoIt, you should do the following steps. Before to do anything, you should make sure that the WinAPIVhd UDF library is not included in the AutoIt package. For more information, see the help file (WinAPIVhd.chm) within the archive. Сopy APIVhdConstants.au3 and WinAPIVhd.au3 to AutoIt3Include.Сopy Examples*.au3 to AutoIt3ExamplesHelpFile.Сopy SciTE*.* to AutoIt3SciTE (only if the full version of SciTE is installed).Сopy HelpWinAPIVhd.chm to AutoIt3.Open AutoIt3IncludeAPIConstants.au3 in SciTE and add the line #include "APIVhdConstants.au3" to the end of list.Open AutoIt3IncludeWinAPIEx.au3 in SciTE and add the line #include "WinAPIVhd.au3" to the end of list. Available functions WinAPIVhd UDF Library v1.0 Previous downloads: 17 WinAPIVhd.zip Example #Include <APIConstants.au3> #Include <GUIConstantsEx.au3> #Include <EditConstants.au3> #Include <WinAPIEx.au3> #Include <APIVhdConstants.au3> #Include <WinAPIVhd.au3> Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) Global $hForm, $hVHD = 0, $Edit, $Button[3], $Path, $Size = 128 * 1024 * 1024 If _WinAPI_GetVersion() < '6.1' Then MsgBox(16, 'Error', 'Require Windows 7 or later.') Exit EndIf $hForm = GUICreate('VHD API Example', 460, 302) $Edit = GUICtrlCreateEdit('', 13, 13, 434, 238, $ES_READONLY) GUICtrlSetFont(-1, 9, 400, 0, 'Courier New') GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetColor(-1, 0x404040) $Button[0] = GUICtrlCreateButton('Create VHD', 12, 263, 140, 27) $Button[1] = GUICtrlCreateButton('Open VHD', 160, 263, 140, 27) $Button[2] = GUICtrlCreateButton('Close VHD', 308, 263, 140, 27) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE If $hVHD Then _VHD_Close() EndIf Exit Case $Button[0] $Path = FileSaveDialog('Create VHD', @ScriptDir, 'Virtual Hard Disk (*.vhd)|All Files (*.*)', 2 + 16, 'Test.vhd', $hForm) If $Path Then If FileExists($Path) Then FileDelete($Path) EndIf Else ContinueLoop EndIf GUICtrlSetData($Edit, '') If Not _VHD_Create($Path, $Size) Then If FileExists($Path) Then FileDelete($Path) EndIf ContinueLoop EndIf For $i = 0 To 1 GUiCtrlSetState($Button[$i], $GUI_DISABLE) Next GUiCtrlSetState($Button[2], $GUI_ENABLE) Case $Button[1] $Path = FileOpenDialog('Open VHD', @ScriptDir, 'Virtual Hard Disk (*.vhd)|All Files (*.*)', 1 + 2, '', $hForm) If $Path Then Else ContinueLoop EndIf GUICtrlSetData($Edit, '') If Not _VHD_Open($Path) Then ContinueLoop EndIf For $i = 0 To 1 GUiCtrlSetState($Button[$i], $GUI_DISABLE) Next GUiCtrlSetState($Button[2], $GUI_ENABLE) Case $Button[2] _VHD_Close() GUiCtrlSetState($Button[2], $GUI_DISABLE) For $i = 0 To 1 GUiCtrlSetState($Button[$i], $GUI_ENABLE) Next EndSwitch WEnd Func _P2L($sDisk) Local $aData, $aList, $iDisk, $iTime, $sMask = '' $iDisk = StringReplace($sDisk, '\\.\PHYSICALDRIVE', '') If Not StringIsDigit($iDisk) Then Return $sDisk EndIf $iDisk = Number($iDisk) $iTime = TimerInit() While TimerDiff($iTime) < 5000 $aList = DriveGetDrive('FIXED') If IsArray($aList) Then For $i = 1 To $aList[0] If Not StringInStr($sMask, $aList[$i]) Then $aData =_WinAPI_GetDriveNumber($aList[$i]) If (IsArray($aData)) And ($aData[1] = $iDisk) Then Return StringUpper($aList[$i]) EndIf EndIf $sMask&= $aList[$i] Next EndIf Sleep(10) WEnd Return $sDisk EndFunc ;==>_P2L Func _Log($sEvent, $iError = -1) Switch $iError Case -1 $sEvent &= @CRLF Case 0 $sEvent &= ': OK' & @CRLF Case Else $sEvent &= ': FAIL (' & $iError & ')' & @CRLF EndSwitch GUICtrlSendMsg($Edit, $EM_SETSEL, 32767, 32767) GUICtrlSetData($Edit, $sEvent, 1) EndFunc ;==>_Log Func _VHD_Close() Local $sDisk = _P2L(_WinAPI_GetVirtualDiskPhysicalPath($hVHD)) _WinAPI_DetachVirtualDisk($hVHD) If @Error Then _Log('Detach', @Extended) Else _Log('Detach', 0) EndIf _WinAPI_CloseHandle($hVHD) $hVHD = 0 If $sDisk Then _Log('VHD (' & $sDisk & ') has been closed!') EndIf EndFunc ;==>_VHD_Close Func _VHD_Create($sPath, $iSize) Local $tVST, $tCVDPV1, $tGVDI, $sDisk, $Error = True _Log('Path: ' & _WinAPI_PathCompactPathEx($sPath, 60)) Do $tVST = _WinAPI_CreateVirtualStorageType($VIRTUAL_STORAGE_TYPE_DEVICE_VHD, $VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT) $tCVDPV1 = _WinAPI_CreateCreateVirtualDiskParametersV1($iSize) $hVHD = _WinAPI_CreateVirtualDisk($sPath, $tVST, $tCVDPV1, $VIRTUAL_DISK_ACCESS_ALL, $CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION) If @Error Then _Log('Create', @Extended) ExitLoop Else _Log('Create', 0) EndIf _WinAPI_AttachVirtualDisk($hVHD) If @Error Then _Log('Attach', @Extended) ExitLoop Else _Log('Attach', 0) EndIf $sDisk = _WinAPI_GetVirtualDiskPhysicalPath($hVHD) If @Error Then ; Nothing EndIf _VHD_Initialize($sDisk) If @Error Then _Log('Initialize', @Extended) ExitLoop Else _Log('Initialize', 0) EndIf $Error = False Until 1 If $Error Then If $hVHD Then _WinAPI_DetachVirtualDisk($hVHD) _WinAPI_CloseHandle($hVHD) EndIf $hVHD = 0 Return 0 EndIf $tGVDI = _WinAPI_GetVirtualDiskInformation($hVHD, $GET_VIRTUAL_DISK_INFO_IDENTIFIER) If Not @Error Then _Log('GUID: ' & _WinAPI_StringFromGUID(DllStructGetPtr($tGVDI, 'Identifier'))) EndIf $tGVDI = _WinAPI_GetVirtualDiskInformation($hVHD, $GET_VIRTUAL_DISK_INFO_SIZE) If Not @Error Then _Log('Size: ' & _WinAPI_StrFormatByteSize(DllStructGetData($tGVDI, 'VirtualSize'))) EndIf _Log('VHD (' & _P2L($sDisk) & ') has been successfully created and ready for use!') Return 1 EndFunc ;==>_VHD_Create Func _VHD_Initialize($sDisk) ;~ Local Const $PARTITION_ENTRY_UNUSED = 0x00 ;~ Local Const $PARTITION_EXTENDED = 0x05 ;~ Local Const $PARTITION_FAT_12 = 0x01 ;~ Local Const $PARTITION_FAT_16 = 0x04 ;~ Local Const $PARTITION_FAT_32 = 0x0B Local Const $PARTITION_IFS = 0x07 ;~ Local Const $PARTITION_LDM = 0x42 ;~ Local Const $PARTITION_NTFT = 0x80 ;~ Local Const $PARTITION_VALID_NTFT = 0xC0 Local Const $PARTITION_STYLE_MBR = 0 ;~ Local Const $PARTITION_STYLE_GPT = 1 ;~ Local Const $PARTITION_STYLE_RAW = 2 Local Const $tagDISK_GEOMETRY = 'int64 Cylinders;dword MediaType;dword TracksPerCylinder;dword SectorsPerTrack;dword BytesPerSector;' Local Const $tagCREATE_DISK_MBR = 'dword Signature;byte GPT[16];' ;~ Local Const $tagCREATE_DISK_GPT = 'byte DiskId[16];dword MaxPartitionCount' Local Const $tagCREATE_DISK = 'dword PartitionStyle;' & $tagCREATE_DISK_MBR Local Const $tagPARTITION_INFORMATION_MBR = 'byte PartitionType;boolean BootIndicator;boolean RecognizedPartition;dword HiddenSectors;byte GPT[104];' ;~ Local Const $tagPARTITION_INFORMATION_GPT = 'byte PartitionType[16];byte PartitionId[16];uint64 Attributes;wchar Name[36];' Local Const $tagPARTITION_INFORMATION_EX = 'dword PartitionStyle;int64 StartingOffset;int64 PartitionLength;dword PartitionNumber;boolean RewritePartition;byte Alignment[3];' & $tagPARTITION_INFORMATION_MBR Local Const $tagDRIVE_LAYOUT_INFORMATION_MBR = 'ulong Signature;byte GPT[36];' ;~ Local Const $tagDRIVE_LAYOUT_INFORMATION_GPT = 'byte DiskId[16];int64 StartingUsableOffset;int64 UsableLength;ulong MaxPartitionCount;' Local Const $tagDRIVE_LAYOUT_INFORMATION_EX = 'dword PartitionStyle;dword PartitionCount;' & $tagDRIVE_LAYOUT_INFORMATION_MBR & 'byte PartitionEntry[144];' Local Const $tagVERIFY_INFORMATION = 'int64 StartingOffset;dword Length' Local $hFile, $tDG, $tCD, $tDLIEX, $tPIEX, $tVI, $Error, $Extended = 0 Do $Error = 1 $hFile = _WinAPI_CreateFileEx($sDisk, $OPEN_EXISTING, BitOR($GENERIC_READ, $GENERIC_WRITE), BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE), $FILE_ATTRIBUTE_NORMAL) If @Error Then ExitLoop EndIf ; IOCTL_DISK_GET_DRIVE_GEOMETRY $Error = 2 $tDG = DllStructCreate($tagDISK_GEOMETRY) If Not _WinAPI_DeviceIoControl($hFile, $IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0, DllStructGetPtr($tDG), DllStructGetSize($tDG)) Then ExitLoop EndIf ; IOCTL_DISK_CREATE_DISK $Error = 3 $tCD = DllStructCreate($tagCREATE_DISK) DllStructSetData($tCD, 'PartitionStyle', $PARTITION_STYLE_MBR) DllStructSetData($tCD, 'Signature', 0xA4B57300) If Not _WinAPI_DeviceIoControl($hFile, $IOCTL_DISK_CREATE_DISK, DllStructGetPtr($tCD), DllStructGetSize($tCD)) Then ExitLoop EndIf ; IOCTL_DISK_SET_DRIVE_LAYOUT_EX $Error = 4 $tDLIEX = DllStructCreate($tagDRIVE_LAYOUT_INFORMATION_EX) DllStructSetData($tDLIEX, 'PartitionStyle', $PARTITION_STYLE_MBR) DllStructSetData($tDLIEX, 'PartitionCount', 1) DllStructSetData($tDLIEX, 'Signature', 0xA4B57300) $tPIEX = DllStructCreate($tagPARTITION_INFORMATION_EX, DllStructGetPtr($tDLIEX, 'PartitionEntry')) DllStructSetData($tPIEX, 'PartitionStyle', $PARTITION_STYLE_MBR) DllStructSetData($tPIEX, 'StartingOffset', 0) DllStructSetData($tPIEX, 'PartitionLength', DllStructGetData($tDG, 'Cylinders') * DllStructGetData($tDG, 'TracksPerCylinder') * DllStructGetData($tDG, 'SectorsPerTrack') * DllStructGetData($tDG, 'BytesPerSector')) DllStructSetData($tPIEX, 'PartitionNumber', 1) DllStructSetData($tPIEX, 'RewritePartition', 1) DllStructSetData($tPIEX, 'PartitionType', $PARTITION_IFS) DllStructSetData($tPIEX, 'BootIndicator', 0) DllStructSetData($tPIEX, 'RecognizedPartition', 1) DllStructSetData($tPIEX, 'HiddenSectors', 1) If Not _WinAPI_DeviceIoControl($hFile, $IOCTL_DISK_SET_DRIVE_LAYOUT_EX, DllStructGetPtr($tDLIEX), DllStructGetSize($tDLIEX)) Then ExitLoop EndIf ; IOCTL_DISK_VERIFY $Error = 5 $tVI = DllStructCreate($tagVERIFY_INFORMATION) DllStructSetData($tVI, 'StartingOffset', 0) DllStructSetData($tVI, 'Length', DllStructGetData($tPIEX, 'PartitionLength')) If Not _WinAPI_DeviceIoControl($hFile, $IOCTL_DISK_VERIFY, DllStructGetPtr($tVI), DllStructGetSize($tVI)) Then ExitLoop EndIf ; IOCTL_DISK_UPDATE_PROPERTIES $Error = 6 If Not _WinAPI_DeviceIoControl($hFile, $IOCTL_DISK_UPDATE_PROPERTIES) Then ExitLoop EndIf $Error = 0 Until 1 If $Error Then $Extended = _WinAPI_GetLastError() EndIf If $hFile Then _WinAPI_CloseHandle($hFile) EndIf Return SetError($Error, $Extended, Not $Error) EndFunc ;==>_VHD_Initialize Func _VHD_Open($sPath) Local $tVST, $tGVDI, $sDisk, $Error = True _Log('Path: ' & _WinAPI_PathCompactPathEx($sPath, 50)) Do $tVST = _WinAPI_CreateVirtualStorageType($VIRTUAL_STORAGE_TYPE_DEVICE_VHD, $VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT) $hVHD = _WinAPI_OpenVirtualDisk($sPath, $tVST, 0, $VIRTUAL_DISK_ACCESS_ALL) If @Error Then _Log('Open', @Extended) ExitLoop Else _Log('Open', 0) EndIf _WinAPI_AttachVirtualDisk($hVHD) If @Error Then _Log('Attach', @Extended) ExitLoop Else _Log('Attach', 0) EndIf $Error = False Until 1 If $Error Then If $hVHD Then _WinAPI_DetachVirtualDisk($hVHD) _WinAPI_CloseHandle($hVHD) EndIf $hVHD = 0 Return 0 EndIf $tGVDI = _WinAPI_GetVirtualDiskInformation($hVHD, $GET_VIRTUAL_DISK_INFO_IDENTIFIER) If Not @Error Then _Log('GUID: ' & _WinAPI_StringFromGUID(DllStructGetPtr($tGVDI, 'Identifier'))) EndIf $tGVDI = _WinAPI_GetVirtualDiskInformation($hVHD, $GET_VIRTUAL_DISK_INFO_SIZE) If Not @Error Then _Log('Size: ' & _WinAPI_StrFormatByteSize(DllStructGetData($tGVDI, 'VirtualSize'))) EndIf $sDisk = _WinAPI_GetVirtualDiskPhysicalPath($hVHD) If Not @Error Then _Log('VHD (' & _P2L($sDisk) & ') has been successfully opened and ready for use!') EndIf Return 1 EndFunc ;==>_VHD_Open1 point
-
GraphGDIPlus UDF - Create GDI+ line graphs
DinFuv reacted to andybiochem for a topic
Last Updated: 20/02/2010 Hi! A while back I created a Graph UDF to enable drawing of graphs in a GUI-control-style way. I've converted that UDF to use GDI+ to take advantage of double-buffering. Functions: _GraphGDIPlus_Create - create graph area _GraphGDIPlus_Delete - delete graph & shutdown GDI+ _GraphGDIPlus_Clear - clear current drawings _GraphGDIPlus_Set_RangeX - set x axis range _GraphGDIPlus_Set_RangeY - set y axis range _GraphGDIPlus_Set_PenColor - set color of line _GraphGDIPlus_Set_PenSize - set line width _GraphGDIPlus_Set_PenDash - set line dash style _GraphGDIPlus_Set_GridX - add grid (x ticks) _GraphGDIPlus_Set_GridY - add grid (y ticks) _GraphGDIPlus_Plot_Start - define starting position _GraphGDIPlus_Plot_Line - plot line _GraphGDIPlus_Plot_Point - plot a small square _GraphGDIPlus_Plot_Dot - plot a single pixel _GraphGDIPlus_Refresh - refresh graph area (draw) NOTES / UPDATES: - be aware that "WM_ACTIVATE" is registered in_GraphGDIPlus_Create (this allows redrawing of the GDI+ when mini/maximizing the GUI) - due to a hideous over-sight on my part, I've had to update the way that "WM_ACTIVATE" is registered by using a global var in the UDF... so DON'T use "$aGraphGDIPlusaGraphArrayINTERNAL" in your script pls!! (couldn't think of any other way to do this) - be aware that WinSetTrans($hWnd,"",255) is called in _GraphGDIPlus_Create (this prevents GDI+ glitches when moving GUI) - _GraphGDIPlus_Delete must be called upon GUI exit (it shuts down GDI+, and disposes of pens etc) - Using _GraphGDIPlus_Clear will remove grid-lines too. You will need to redraw these using _GraphGDIPlus_Set_Grid... after clearing - updated to allow setting color of the x=0 and y=0 lines when visible (when using -ve and +ve axes) - updated to allow user to decide whether to shut down GDI+ completely when deleting the graph (you may have your own graphics etc) - updated to declare all vars as Local in functions. Sorry if you had problems with this, no excuses, entirely my fault. - updated to clean up pen use - be aware that "WM_MOVE" is registered in_GraphGDIPlus_Create (this allows redrawing of the GDI+ when moving the GUI) The updates should NOT be script breaking, unless you are manually using Pen vars/handles from the returned graph array. TO DO - Look at adding a "save image as..." option (suggested by UEZ - thanks!) - Error checking / returns ???? any suggestions ???? Example Use This graph draws Gamma Function in real-time... #include "GraphGDIPlus.au3" Opt("GUIOnEventMode", 1) $GUI = GUICreate("",600,600) GUISetOnEvent(-3,"_Exit") GUISetState() ;----- Create Graph area ----- $Graph = _GraphGDIPlus_Create($GUI,40,30,530,520,0xFF000000,0xFF88B3DD) ;----- Set X axis range from -5 to 5 ----- _GraphGDIPlus_Set_RangeX($Graph,-5,5,10,1,1) _GraphGDIPlus_Set_RangeY($Graph,-5,5,10,1,1) ;----- Set Y axis range from -5 to 5 ----- _GraphGDIPlus_Set_GridX($Graph,1,0xFF6993BE) _GraphGDIPlus_Set_GridY($Graph,1,0xFF6993BE) ;----- Draw the graph ----- _Draw_Graph() While 1 Sleep(100) WEnd Func _Draw_Graph() ;----- Set line color and size ----- _GraphGDIPlus_Set_PenColor($Graph,0xFF325D87) _GraphGDIPlus_Set_PenSize($Graph,2) ;----- draw lines ----- $First = True For $i = -5 to 5 Step 0.005 $y = _GammaFunction($i) If $First = True Then _GraphGDIPlus_Plot_Start($Graph,$i,$y) $First = False _GraphGDIPlus_Plot_Line($Graph,$i,$y) _GraphGDIPlus_Refresh($Graph) Next EndFunc Func _GammaFunction($iZ) $nProduct = ((2^$iZ) / (1 + $iZ)) For $n = 2 to 1000 $nProduct *= ((1 + (1/$n))^$iZ) / (1 + ($iZ / $n)) Next Return (1/$iZ) * $nProduct EndFunc Func _Exit() ;----- close down GDI+ and clear graphic ----- _GraphGDIPlus_Delete($GUI,$Graph) Exit EndFunc UDF: GraphGDIPlus.au3 Updated 20/02/2010 ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# =============================================================================== ; Title .........: GraphGDIPlus ; AutoIt Version: 3.3.0.0+ ; Language: English ; Description ...: A Graph control to draw line graphs, using GDI+, also double-buffered. ; Notes .........: ; ======================================================================================= ; #VARIABLES/INCLUDES# ================================================================== #include-once #include <GDIplus.au3> Global $aGraphGDIPlusaGraphArrayINTERNAL[1] ; ======================================================================================= ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Create ; Description ...: Creates graph area, and prepares array of specified data ; Syntax.........: _GraphGDIPlus_Create($hWnd,$iLeft,$iTop,$iWidth,$iHeight,$hColorBorder = 0xFF000000,$hColorFill = 0xFFFFFFFF) ; Parameters ....: $hWnd - Handle to GUI ; $iLeft - left most position in GUI ; $iTop - top most position in GUI ; $iWidth - width of graph in pixels ; $iHeight - height of graph in pixels ; $hColorBorder - Color of graph border (ARGB) ; $hColorFill - Color of background (ARGB) ; 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 Color ; [15] Fill Color ; [16] Bitmap Handle ; [17] Backbuffer Handle ; [18] Last used x pos ; [19] Last used y pos ; [20] Pen (main) Handle ; [21] Brush (fill) Handle ; [22] Pen (border) Handle ; [23] Pen (grid) Handle ; ======================================================================================= Func _GraphGDIPlus_Create($hWnd, $iLeft, $iTop, $iWidth, $iHeight, $hColorBorder = 0xFF000000, $hColorFill = 0xFFFFFFFF, $iSmooth = 2) Local $graphics, $bitmap, $backbuffer, $brush, $bpen, $gpen, $pen Local $ahTicksLabelsX[1] Local $ahTicksLabelsY[1] Local $ahTicksX[1] Local $ahTicksY[1] Local $aGraphArray[1] ;----- Set GUI transparency to SOLID (prevents GDI+ glitches) ----- ;WinSetTrans($hWnd, "", 255) - causes problems when more than 2 graphs used ;----- GDI+ Initiate ----- _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) ;graphics area $bitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth + 1, $iHeight + 1, $graphics);buffer bitmap $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) ;buffer area _GDIPlus_GraphicsSetSmoothingMode($backbuffer, $iSmooth) ;----- Set background Color ----- $brush = _GDIPlus_BrushCreateSolid($hColorFill) _GDIPlus_GraphicsFillRect($backbuffer, 0, 0, $iWidth, $iHeight, $brush) ;----- Set border Pen + color ----- $bpen = _GDIPlus_PenCreate($hColorBorder) _GDIPlus_PenSetEndCap($bpen, $GDIP_LINECAPROUND) ;----- Set Grid Pen + color ----- $gpen = _GDIPlus_PenCreate(0xFFf0f0f0) _GDIPlus_PenSetEndCap($gpen, $GDIP_LINECAPROUND) ;----- set Drawing Pen + Color ----- $pen = _GDIPlus_PenCreate() ;drawing pen initially black, user to set _GDIPlus_PenSetEndCap($pen, $GDIP_LINECAPROUND) _GDIPlus_GraphicsDrawRect($backbuffer, 0, 0, $iWidth, $iHeight, $pen) ;----- draw ----- _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, $iLeft, $iTop, $iWidth + 1, $iHeight + 1) ;----- register redraw ----- GUIRegisterMsg(0x0006, "_GraphGDIPlus_ReDraw") ;0x0006 = win activate GUIRegisterMsg(0x0003, "_GraphGDIPlus_ReDraw") ;0x0003 = win move ;----- prep + load array ----- Dim $aGraphArray[24] = ["", $graphics, $iLeft, $iTop, $iWidth, $iHeight, 0, 1, 0, 1, _ $ahTicksX, $ahTicksLabelsX, $ahTicksY, $ahTicksLabelsY, $hColorBorder, $hColorFill, _ $bitmap, $backbuffer, 0, 0, $pen, $brush, $bpen, $gpen] ;----- prep re-draw array for all graphs created ----- ReDim $aGraphGDIPlusaGraphArrayINTERNAL[UBound($aGraphGDIPlusaGraphArrayINTERNAL) + 1] $aGraphGDIPlusaGraphArrayINTERNAL[UBound($aGraphGDIPlusaGraphArrayINTERNAL) - 1] = $aGraphArray Return $aGraphArray EndFunc ;==>_GraphGDIPlus_Create Func _GraphGDIPlus_ReDraw($hWnd) ;----- Allows redraw of the GDI+ Image upon window min/maximize ----- Local $i _WinAPI_RedrawWindow($hWnd, 0, 0, 0x0100) For $i = 1 To UBound($aGraphGDIPlusaGraphArrayINTERNAL) - 1 If $aGraphGDIPlusaGraphArrayINTERNAL[$i] = 0 Then ContinueLoop _GraphGDIPlus_Refresh($aGraphGDIPlusaGraphArrayINTERNAL[$i]) Next EndFunc ;==>_GraphGDIPlus_ReDraw ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Delete ; Description ...: Deletes previously created graph and related ticks/labels ; Syntax.........: _GraphGDIPlus_Delete($hWnd,ByRef $aGraphArray) ; Parameters ....: $hWnd - GUI handle ; $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iKeepGDIPlus - if not zero, function will not _GDIPlus_Shutdown() ; ======================================================================================= Func _GraphGDIPlus_Delete($hWnd, ByRef $aGraphArray, $iKeepGDIPlus = 0) If IsArray($aGraphArray) = 0 Then Return Local $ahTicksX, $ahTicksLabelsX, $ahTicksY, $ahTicksLabelsY, $i, $aTemp ;----- 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 ;----- delete graphic control ----- _GDIPlus_GraphicsDispose($aGraphArray[17]) _GDIPlus_BitmapDispose($aGraphArray[16]) _GDIPlus_GraphicsDispose($aGraphArray[1]) _GDIPlus_BrushDispose($aGraphArray[21]) _GDIPlus_PenDispose($aGraphArray[20]) _GDIPlus_PenDispose($aGraphArray[22]) _GDIPlus_PenDispose($aGraphArray[23]) If $iKeepGDIPlus = 0 Then _GDIPlus_Shutdown() _WinAPI_InvalidateRect($hWnd) ;----- remove form global redraw array ----- For $i = 1 To UBound($aGraphGDIPlusaGraphArrayINTERNAL) - 1 $aTemp = $aGraphGDIPlusaGraphArrayINTERNAL[$i] If IsArray($aTemp) = 0 Then ContinueLoop If $aTemp[1] = $aGraphArray[1] Then $aGraphGDIPlusaGraphArrayINTERNAL[$i] = 0 Next ;----- close array ----- $aGraphArray = 0 EndFunc ;==>_GraphGDIPlus_Delete ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Clear ; Description ...: Clears graph content ; Syntax.........: _GraphGDIPlus_Clear(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; ======================================================================================= Func _GraphGDIPlus_Clear(ByRef $aGraphArray) If IsArray($aGraphArray) = 0 Then Return ;----- Set background Color ----- _GDIPlus_GraphicsFillRect($aGraphArray[17], 0, 0, $aGraphArray[4], $aGraphArray[5], $aGraphArray[21]) ;----- set border + Color ----- _GraphGDIPlus_RedrawRect($aGraphArray) EndFunc ;==>_GraphGDIPlus_Clear ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Refresh ; Description ...: refreshes the graphic ; Syntax.........: _GraphGDIPlus_Refresh(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; ======================================================================================== Func _GraphGDIPlus_Refresh(ByRef $aGraphArray) If IsArray($aGraphArray) = 0 Then Return ;----- draw ----- _GDIPlus_GraphicsDrawImageRect($aGraphArray[1], $aGraphArray[16], $aGraphArray[2], _ $aGraphArray[3], $aGraphArray[4] + 1, $aGraphArray[5] + 1) EndFunc ;==>_GraphGDIPlus_Refresh ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Set_RangeX ; Description ...: Allows user to set the range of the X axis and set ticks and rounding levels ; Syntax.........: _GraphGDIPlus_Set_RangeX(ByRef $aGraphArray,$iLow,$iHigh,$iXTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_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 _GraphGDIPlus_Set_RangeX(ByRef $aGraphArray, $iLow, $iHigh, $iXTicks = 1, $bLabels = 1, $iRound = 0) If IsArray($aGraphArray) = 0 Then Return Local $ahTicksX, $ahTicksLabelsX, $i ;----- 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, 128) 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, -2) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsX) - 1) GUICtrlSetData($ahTicksLabelsX[$i], _ StringFormat("%." & $iRound & "f", _GraphGDIPlus_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 ;==>_GraphGDIPlus_Set_RangeX ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Set_RangeY ; Description ...: Allows user to set the range of the Y axis and set ticks and rounding levels ; Syntax.........: _GraphGDIPlus_SetRange_Y(ByRef $aGraphArray,$iLow,$iHigh,$iYTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_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 _GraphGDIPlus_Set_RangeY(ByRef $aGraphArray, $iLow, $iHigh, $iYTicks = 1, $bLabels = 1, $iRound = 0) If IsArray($aGraphArray) = 0 Then Return Local $ahTicksY, $ahTicksLabelsY, $i ;----- 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, 128) 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, -2) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsY) - 1) GUICtrlSetData($ahTicksLabelsY[$i], StringFormat("%." & $iRound & "f", _GraphGDIPlus_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 ;==>_GraphGDIPlus_Set_RangeY ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Start ; Description ...: Move starting point of plot ; Syntax.........: _GraphGDIPlus_Plot_Start(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to start at ; $iY - y value to start at ; ======================================================================================== Func _GraphGDIPlus_Plot_Start(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- MOVE pen to start point ----- $aGraphArray[18] = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $aGraphArray[19] = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) EndFunc ;==>_GraphGDIPlus_Plot_Start ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Line ; Description ...: draws straight line to x,y from previous point / starting point ; Syntax.........: _GraphGDIPlus_Plot_Line(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to draw to ; $iY - y value to draw to ; ======================================================================================== Func _GraphGDIPlus_Plot_Line(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- Draw line from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) _GDIPlus_GraphicsDrawLine($aGraphArray[17], $aGraphArray[18], $aGraphArray[19], $iX, $iY, $aGraphArray[20]) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Line ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Point ; Description ...: draws point at coords ; Syntax.........: _GraphGDIPlus_Plot_Point(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _GraphGDIPlus_Plot_Point(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- Draw point from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) _GDIPlus_GraphicsDrawRect($aGraphArray[17], $iX-1, $iY-1, 2, 2, $aGraphArray[20]) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Point ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Dot ; Description ...: draws single pixel dot at coords ; Syntax.........: _GraphGDIPlus_Plot_Dot(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _GraphGDIPlus_Plot_Dot(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- Draw point from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) _GDIPlus_GraphicsDrawRect($aGraphArray[17], $iX, $iY, 1, 1, $aGraphArray[20]) ;draws 2x2 dot ?HOW to get 1x1 pixel????? _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Dot ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_PenColor ; Description ...: sets the Color for the next drawing ; Syntax.........: _GraphGDIPlus_Set_PenColor(ByRef $aGraphArray,$hColor,$hBkGrdColor = $GUI_GR_NOBKColor) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $hColor - the Color of the next item (ARGB) ; ======================================================================================== Func _GraphGDIPlus_Set_PenColor(ByRef $aGraphArray, $hColor) If IsArray($aGraphArray) = 0 Then Return ;----- apply pen Color ----- _GDIPlus_PenSetColor($aGraphArray[20], $hColor) EndFunc ;==>_GraphGDIPlus_Set_PenColor ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_PenSize ; Description ...: sets the pen for the next drawing ; Syntax.........: _GraphGDIPlus_Set_PenSize(ByRef $aGraphArray,$iSize = 1) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iSize - size of pen line ; ======================================================================================== Func _GraphGDIPlus_Set_PenSize(ByRef $aGraphArray, $iSize = 1) If IsArray($aGraphArray) = 0 Then Return ;----- apply pen size ----- _GDIPlus_PenSetWidth($aGraphArray[20], $iSize) EndFunc ;==>_GraphGDIPlus_Set_PenSize ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_PenDash ; Description ...: sets the pen dash style for the next drawing ; Syntax.........: GraphGDIPlus_Set_PenDash(ByRef $aGraphArray,$iDash = 0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iDash - style of dash, where: ; 0 = solid line ; 1 = simple dashed line ; 2 = simple dotted line ; 3 = dash dot line ; 4 = dash dot dot line ; ======================================================================================== Func _GraphGDIPlus_Set_PenDash(ByRef $aGraphArray, $iDash = 0) If IsArray($aGraphArray) = 0 Then Return Local $Style Switch $iDash Case 0 ;solid line _____ $Style = $GDIP_DASHSTYLESOLID Case 1 ;simple dash ----- $Style = $GDIP_DASHSTYLEDASH Case 2 ;simple dotted ..... $Style = $GDIP_DASHSTYLEDOT Case 3 ;dash dot -.-.- $Style = $GDIP_DASHSTYLEDASHDOT Case 4 ;dash dot dot -..-..-.. $Style = $GDIP_DASHSTYLEDASHDOTDOT EndSwitch ;----- apply pen dash ----- _GDIPlus_PenSetDashStyle($aGraphArray[20], $Style) EndFunc ;==>_GraphGDIPlus_Set_PenDash ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_GridX ; Description ...: Adds X gridlines. ; Syntax.........: _GraphGDIPlus_Set_GridX(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining Color of grid. Default is a light gray ; $hColorY0 - [optional] RGB value, defining Color of Y=0 line, Default black ; ======================================================================================= Func _GraphGDIPlus_Set_GridX(ByRef $aGraphArray, $Ticks = 1, $hColor = 0xFFf0f0f0, $hColorY0 = 0xFF000000) If IsArray($aGraphArray) = 0 Then Return ;----- Set gpen to user color ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;----- draw grid lines ----- 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 _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ _GraphGDIPlus_Reference_Pixel("x", $i, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ 1, _ _GraphGDIPlus_Reference_Pixel("x", $i, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ $aGraphArray[5] - 1, _ $aGraphArray[23]) Next EndSelect ;----- draw y=0 ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColorY0) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ 1, _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ $aGraphArray[5] - 1, _ $aGraphArray[23]) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[4] - 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[23]) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- re-set to user specs ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;set Color back to user def EndFunc ;==>_GraphGDIPlus_Set_GridX ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_GridY ; Description ...: Adds Y gridlines. ; Syntax.........: _GraphGDIPlus_Set_GridY(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining Color of grid. Default is a light gray ; $hColorX0 - [optional] RGB value, defining Color of X=0 line, Default black ; ======================================================================================= Func _GraphGDIPlus_Set_GridY(ByRef $aGraphArray, $Ticks = 1, $hColor = 0xFFf0f0f0, $hColorX0 = 0xFF000000) If IsArray($aGraphArray) = 0 Then Return ;----- Set gpen to user color ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;----- draw grid lines ----- 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 _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ 1, _ _GraphGDIPlus_Reference_Pixel("y", $i, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[4] - 1, _ _GraphGDIPlus_Reference_Pixel("y", $i, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[23]) Next EndSelect ;----- draw abcissa/ordinate ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColorX0) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ 1, _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ $aGraphArray[5] - 1, _ $aGraphArray[23]) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[4] - 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[23]) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- re-set to user specs ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;set Color back to user def EndFunc ;==>_GraphGDIPlus_Set_GridY ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_RedrawRect ; Description ...: INTERNAL FUNCTION - Re-draws the border ; Syntax.........: _GraphGDIPlus_RedrawRect(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; Notes..........: This prevents drawing over the border of the graph area ; ========================================================================================= Func _GraphGDIPlus_RedrawRect(ByRef $aGraphArray) If IsArray($aGraphArray) = 0 Then Return ;----- draw border ----- _GDIPlus_GraphicsDrawRect($aGraphArray[17], 0, 0, $aGraphArray[4], $aGraphArray[5], $aGraphArray[22]) ;draw border EndFunc ;==>_GraphGDIPlus_RedrawRect ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Reference_Pixel ; Description ...: INTERNAL FUNCTION - performs pixel reference calculations ; Syntax.........: _GraphGDIPlus_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 _GraphGDIPlus_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 ;==>_GraphGDIPlus_Reference_Pixel Thanks To: joseLB for looking at adding grid lines in the original UDF monoceres for the e-x-c-e-l-l-e-n-t GDI+ double buffer template UEZ for suggesting anti-aliasing (now included by default) winux38 for pointing out an error1 point -
Virtual listviews are lightning fast and can handle millions of rows. Virtual listviews are of interest when you have to insert more than 10,000 rows. When there are less than 10,000 rows, the standard listviews are sufficiently rapid. See the section "Using standard listviews" below. In a virtual listview data are not stored directly in the listview. Data are stored in an array, a structure (DllStructCreate), a flat fixed-length record file, a database or similar. The listview only contains the rows which are visible depending on the height of the listview. See About List-View Controls in the MicroSoft documentation for more information. An array or a structure can be used for listviews with 10,000 - 100,000 rows. If there are more than 100,000 rows a fixed-length record file or a database seems to be the best solution, because they have low impact on memory usage. But you get nothing for free. The costs is that a part of the built-in features does not work, and you will have to implement these features yourself. Because data isn't stored in the listview the Set- and Get-functions to manipulate data doesn't work. You have to manipulate the data source directly. And sorting is not supported at all by virtual listviews. If you need sorting, a database seems to be the best solution in all cases, because sorting can be handled by the database. Below you'll find the following sections: Data stored in arrays Data stored in databases Data stored in fixed-length record files Sorting rows in a virtual listview $LVN_ODFINDITEM notifications Using standard listviews Updates Zip file Examples The next two sections shows how to use virtual listviews, when data are stored in arrays or databases. In first section data are stored in 3 arrays with 10,000/50,000/100,000 rows and 10 columns. In second section data are stored in 3 databases with 100,000/1,000,000/10,000,000 rows and 10 columns. Data stored in arrays For a virtual listview rows are displayed with $LVN_GETDISPINFO notifications and the $tagNMLVDISPINFO structure. Code for $LVN_GETDISPINFO messages in the WM_NOTIFY function can be implemented in this manner: Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $sItem = $aItems[DllStructGetData($tNMLVDISPINFO,"Item")][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf Run LvVirtArray.au3. It takes some time to create the arrays. But when the arrays are created, switching from one array to another (which means updating the listview) is instantaneous. Data stored in databases When data are stored in a database, $LVN_ODCACHEHINT notifications and the $tagNMLVCACHEHINT structure is used to insert the rows in an array cache before they are displayed with $LVN_GETDISPINFO messages. The $tagNMLVCACHEHINT structure is defined in this way: Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" Note that $tagNMLVCACHEHINT is not included in GuiListView.au3 or StructureConstants.au3. Code for $LVN_ODCACHEHINT messages in the WM_NOTIFY function can be implemented in this manner: Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ), $iColumns $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) Local $sSQL = "SELECT * FROM lvdata WHERE item_id >= " & $iFrom & _ " AND item_id <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" _SQLite_GetTable2d( -1, $sSQL, $aResult, $iRows, $iColumns ) $aResult is the array cache. The purpose of the cache is to limit the number of SELECT statements. When the listview is displayed for the first time, all visible rows (in this example about 20) have to be updated. In this case $aResult will contain 20 rows and 10 columns. 20 rows is also the maximum number of rows in $aResult. A virtual listview will never update more than the visible number of rows at one time. Code for $LVN_GETDISPINFO messages can be implemented in this way: Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom + 1 If $iIndex > 0 And $iIndex < $iRows + 1 Then Local $sItem = $aResult[$iIndex][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf EndIf The zip below contains a small GUI, CreateDB.au3, to create 3 SQLite databases with 100,000/1,000,000/10,000,000 rows. The databases will use about 10/100/1000 MB of diskspace, and the creation will take about ½/5/40 minutes (on an old XP). You must select a database and click a button to start the creation. If you get tired of waiting, you can cancel (checked for every 10,000 rows) the process and continue another time. The process will continue where it stopped. You can run the examples even though the databases might only contain 30,000/200,000/1,500,000 rows. You do not have to create all three databases. Run LvVirtDB.au3. Data stored in fixed-length record files (update 2015-04-01) Extracting data directly from a fixed-length record file by setting the file pointer to the current record and reading the required number of bytes is another example, where $LVN_ODCACHEHINT messages should be used to insert records in an array cache before they are displayed. Code for $LVN_ODCACHEHINT and $LVN_GETDISPINFO messages can be implemented as shown: Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ) $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) $iRows = DllStructGetData( $tNMLVCACHEHINT, "iTo" ) - $iFrom + 1 FileSetPos( $hFile, $iFrom * 12, 0 ) ; Each line is 10 chars + CR + LF $aCache = StringSplit( FileRead( $hFile, $iRows * 12 - 2 ), @CRLF, 3 ) The purpose of the cache is to limit the number of FileRead statements. Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom If -1 < $iIndex And $iIndex < $iRows Then DllStructSetData( $tText, 1, $aCache[$iIndex] ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", 10 ) ; Each line is 10 chars EndIf EndIf Run LvVirtFile.au3. A fixed-length record file with 10,000 records (LvVirtFile.txt) is included in the zip. I have tested this example on a 1,1 GB file and 100,000,000 rows. The listview responds immediately. The solution with a flat fixed-length record file is extremely fast. Much faster than a database. But also with very much limited functionality compared to a database. Sorting rows in a virtual listview (update 2015-04-01) Sorting is not supported at all by virtual listviews. If you want rows to be sorted, you have to feed the listview with the rows in sorted order. If the rows are stored in an array, you have to sort the array before you feed the listview. If you want to sort the rows by two or more columns, you have to store the rows in two or more arrays which are sorted for the current column. Or you have to create two or more indexes to handle the sorting. Sorting arrays and creating indexes is time consuming. If you need sorting, a database seems to be the best solution, because sorting can be handled by the database. Nevertheless, here's an example that stores 10,000/20,000/30,000 rows and 3 columns in arrays, and creates indexes to handle the sorting. The columns are strings, integers and floating point numbers, and indexes are calculated for all 3 columns. To be able to create the indexes as fast as possible, structures (DllStructCreate) are used to create the indexes. This is the function to create indexes for integers and floating point numbers. The function for strings is equivalent. $tIndex = DllStructCreate( "uint[" & $iRows & "]" ) Func SortNumbers( ByRef $aItems, $iRows, $iCol, $pIndex, $tIndex ) Local $k, $n, $lo, $hi, $mi, $gt HourglassCursor( True ) WinSetTitle( $hGui, "", "Virtual ListViews. Sort numbers: 0 rows" ) For $i = 0 To $iRows / 10000 - 1 $k = $i * 10000 For $j = 0 To 9999 $n = $aItems[$k+$j][$iCol] ; Binary search $lo = 0 $hi = $k + $j - 1 While $lo <= $hi $mi = Int( ( $lo + $hi ) / 2 ) If $n < $aItems[DllStructGetData($tIndex,1,$mi+1)][$iCol] Then $gt = 0 $hi = $mi - 1 Else $gt = 1 $lo = $mi + 1 EndIf WEnd ; Make space for the new value DllCall( $hKernel32Dll, "none", "RtlMoveMemory", "struct*", $pIndex+($mi+1)*4, "struct*", $pIndex+$mi*4, "ulong_ptr", ($k+$j-$mi)*4 ) ; Insert new value DllStructSetData( $tIndex, 1, $k+$j, $mi+1+$gt ) Next WinSetTitle( $hGui, "", "Virtual ListViews. Sort numbers: " & $k + 10000 & " rows" ) Next HourglassCursor( False ) WinSetTitle( $hGui, "", "Virtual ListViews (sorted)" ) EndFunc Run LvVirtArraySort.au3. It takes some time to create the arrays and indexes. But when everything is created, sorting by different columns and switching from one array to another is instantaneous. Because it's easy and fast to save/load a structure to/from a binary file, it may be advantageous to calculate the arrays and indexes in another script before the GUI is opened. $LVN_ODFINDITEM notifications (update 2015-04-01) Three notifications are important for virtual listviews. $LVN_GETDISPINFO (to get information about the rows to display in the listview) and $LVN_ODCACHEHINT (to store rows from a file or database in an array cache before they are displayed with $LVN_GETDISPINFO messages) are already mentioned above. The last is $LVN_ODFINDITEM, which is used to find a row when you press one or a few keys on the keyboard. Information from $LVN_ODFINDITEM is stored in the $tagNMLVFINDITEM structure. The codebox shows the code for $LVN_ODFINDITEM notifications: Case $LVN_ODFINDITEMW Local $tNMLVFINDITEM = DllStructCreate( $tagNMLVFINDITEM, $lParam ) If BitAND( DllStructGetData( $tNMLVFINDITEM, "Flags" ), $LVFI_STRING ) Then Return SearchText( DllStructGetData( $tNMLVFINDITEM, "Start" ), _ ; Start DllStructGetData( DllStructCreate( "wchar[20]", DllStructGetData( $tNMLVFINDITEM, "Text" ) ), 1 ) ) ; Text EndIf Start is the row where you start the search. Text contains the key presses to search for. You have to implement the search function (here SearchText) yourself. If the function finds a row, it should return the index of the row. If not, it should return -1. Run LvVirtArrayFind.au3. Using standard listviews (update 2015-04-01) If not more than 10,000 rows have to be inserted in a listview, a standard listview is sufficiently rapid. Because of speed you should use native (built-in) functions to fill the listview and not functions in GuiListView.au3 UDF. When the listview is filled, you can use all the functions in the UDF. This code shows how to quickly fill a listview with native functions: Func FillListView( $idLV, ByRef $aItems, $iRows ) Local $tLVITEM = DllStructCreate( $tagLVITEM ) Local $pLVITEM = DllStructGetPtr( $tLVITEM ), $k, $s DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image) DllStructSetData( $tLVITEM, "SubItem", 0 ) ; First column HourglassCursor( True ) For $i = 0 To $iRows / 10000 - 1 $k = $i * 10000 For $j = 0 To 9999 ; Text $s = $aItems[$k+$j][0] For $l = 1 To 9 $s &= "|" & $aItems[$k+$j][$l] Next GUICtrlCreateListViewItem( $s, $idLV ) ; Add item and all texts ; Icon Select Case Mod( $k + $j, 3 ) = 0 DllStructSetData( $tLVITEM, "Image", 2 ) ; Icon index Case Mod( $k + $j, 2 ) = 0 DllStructSetData( $tLVITEM, "Image", 1 ) Case Else DllStructSetData( $tLVITEM, "Image", 0 ) EndSelect DllStructSetData( $tLVITEM, "Item", $k + $j ) ; Row GUICtrlSendMsg( $idLV, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon Next WinSetTitle( $hGui, "", "GUICtrlCreateListViewItem ListViews. Fills listview: " & $k + 10000 & " rows" ) Next HourglassCursor( False ) WinSetTitle( $hGui, "", "GUICtrlCreateListViewItem ListViews" ) EndFunc Run LvStandard.au3. LvStandardIni.au3 shows how to quickly load an inifile (LvStandardIni.ini, created with IniWriteSection) into a listview. Because an inifile is a small file (only the first 32767 chars are read) it should always be loaded into a standard listview. Updates Update 2015-03-24 Added two array-examples. An example (LvVirtArrayIcons.au3) that shows how to use checkboxes and icons, and an example (LvVirtArrayColors.au3) that shows how to draw every second row with a different background color. In this post you can find an example where all items are drawn with a random background color. Update 2015-04-01 Cleaned up code in previous examples. Added more examples as described above. Zip updated. UDF versions (2018-04-27) Over the past weeks, new display functions have been added to Data display functions based on virtual listviews, and new functions have been added to use the listviews as embedded GUI controls. All the functions work and are used in much the same way. Apart from the data source, the function parameters are the same for all functions. The display functions support a wide range of features, all specified via a single function parameter $aFeatures, which is the last parameter. The central code to handle $LVN_ODCACHEHINT and $LVN_GETDISPINFO notifications is very optimized code. First of all, the code is implemented through the subclassing technique. This means that messages are received directly from the operating system and not from AutoIt's internal message management code. Messages are returned again directly to the operating system and again without interference with AutoIt's internal message handling code. Next, the code is divided into different include files each taking care of a particular feature. That way, it's avoided that a lot of control statements makes the code slow. And it's enough to include the code that's actually used. One reason why so much work has been done in optimizing code and developing features is that these functions will also work as UDF versions for the examples here. It's far from a trivial task to develop UDF versions of examples like these. Since the first version of the display functions was created in this thread 2½ years ago and then has been continuously developed, it's obvious to use the functions as UDF versions of these examples. The following examples are implemented as UDF versions: Data stored in arrays Data stored in CSV files Data stored in SQLite databases Zip file Examples in zip: LvVirtArray.au3 - Data stored in arrays LvVirtArrayColors.au3 - Alternating row colors LvVirtArrayFind.au3 - $LVN_ODFINDITEM notifications LvVirtArrayIcons.au3 - Checkboxes and icons LvVirtArraySort.au3 - Sorting rows in a virtual listview LvVirtDB.au3 - Data stored in databases (use CreateDB.au3 to create DBs) LvVirtFile.au3 - Data stored in fixed-length record files LvStandard.au3 - Using standard listviews LvStandardIni.au3 - Load inifile into a listview The size of the zip is caused by a 118 KB txtfile, LvVirtFile.txt, used by LvVirtFile.au3, and a 28 KB inifile, LvStandardIni.ini, used by LvStandardIni.au3. Tested with AutoIt 3.3.10 on Windows 7 64 bit and Windows XP 32 bit. Should work on all AutoIt versions from 3.3.10 and all Windows versions. Virtual ListViews.7z Examples Examples based on virtual listviews. Array examples: A lot of rows and random background colors for each cell - This post in another thread Incremental search (update as you type) in a virtual listview - Post 29 Sorting arrays: Rows can be sorted by strings, integers, floats and checkboxes, checked rows in top - Post 48 File sources: A CSV-file with 100,000 rows and 10 columns is data source - Post 56 SQLite examples: Various issues related to the use of a database - Post 34, 35, 43 An example that shows a way to implement a search box - Post 411 point
-
Explorer like search in SQLite
argumentum reacted to jchd for a topic
https://www.sqlite.org/fts3.html Support for FTS4 is build in sqlite3.dll distributed thru AutoIt.1 point -
Inputbox description ?
Alexxander reacted to jguinch for a topic
https://msdn.microsoft.com/en-us/library/windows/desktop/bb761639(v=vs.85).aspx1 point -
Divider lines between listview rows ?
Alexxander reacted to JohnOne for a topic
Try. $idListview = GUICtrlCreateListView("", 2, 2, 696, @DesktopHeight - @DesktopHeight/3, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))1 point -
Here a script to convert month numbers to month names. $iMon = InputBox("Month", "Enter Month ( 1 - 12)", @MON) If $iMon < 1 Or $iMon > 12 Then Exit MsgBox(16 + 262144, Default, "Wrong month input. Only 1 to 12 accepted.", 0) $sLocalLongMon = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'ulong', 0, 'dword', 55 + $iMon, 'wstr', '', 'int', 2048)[3] $sLocalShortMon = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'ulong', 0, 'dword', 67 + $iMon, 'wstr', '', 'int', 2048)[3] $sUSLongMon = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'ulong', 1033, 'dword', 55 + $iMon, 'wstr', '', 'int', 2048)[3] $sUSShortMon = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'ulong', 1033, 'dword', 67 + $iMon, 'wstr', '', 'int', 2048)[3] MsgBox(262144, Default, "Local name: " & $sLocalLongMon & " / " & $sLocalShortMon & @LF & "US name: " & $sUSLongMon & " / " & $sUSShortMon, 0)1 point
-
Senseless unless the string is very long and also not really AutoIt but… #include <Memory.au3> Func StringCountLF($sString) Local $pCountLF = _MemVirtualAlloc(Null, 25, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) DllStructSetData(DllStructCreate("BYTE[25]", $pCountLF), 1, "0x" _ & "8B4C2404" _ ;~ mov ecx, dword[esp+04h] & "31C0" _ ;~ xor eax, eax & "8A11" _ ;~ @@:mov dl, byte[ecx] & "80FA00" _ ;~ cmp dl, 00h & "7409" _ ;~ je @f & "41" _ ;~ inc ecx & "80FA0A" _ ;~ cmp dl, 0Ah & "75F3" _ ;~ jne @b & "40" _ ;~ inc eax & "EBF0" _ ;~ jmp @b & "C20400" _ ;~ @@:ret 4 ) Local $nResult = DllCallAddress("INT", $pCountLF, "STR", $sString)[0] _MemVirtualFree($pCountLF, 0, $MEM_RELEASE) Return $nResult EndFunc1 point
-
Visible Controls on a Transparent window
CodeTinkerer reacted to martin for a topic
Do you mean like this? #include <GuiConstants.au3> HotKeySet("{ESC}", "QuitApp") $BG = GUICreate("back windoww",400,400,0,0) ;WinSetTrans("back window","",0) $Main_Gui = GUICreate("", 400, 400,0,0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21) $Info_Edit = GUICtrlCreateEdit("A few words to start off with", 80, 150, 300, 220) GUISetControlsVisible($Main_Gui) $wp = WinGetPos(WinGetHandle("Untitled")) GUISetState(@SW_SHOW,$BG) GUISetState(@SW_SHOW,$Main_Gui) GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUIRegisterMsg($WM_MOVE, "WM_MOVE") GUISwitch($BG) $n = 100 $way = 1 While 1 $Msg = GUIGetMsg() if $Msg = $But1 Then Exitloop WinSetTrans("back window","",$n) ;WinSetTrans($Main_Gui,"",$n);<--------choose this line instead of one above to make the components fade rather than the window if $n > 253 or $n < 40 then $way *= -1 Sleep(20);<-------------------------adjust for speed of fade $n += $way WEnd Func GUISetControlsVisible($hWnd) Local $aClassList, $aM_Mask, $aCtrlPos, $aMask ;Set $WS_POPUP style part: Local Const $GWL_STYLE = -16 Local Const $GWL_EXSTYLE = -20 Local Const $SWP_NOMOVE = 0x2 Local Const $SWP_NOSIZE = 0x1 Local Const $SWP_SHOWWINDOW = 0x40 Local Const $SWP_NOZORDER = 0x4 Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $WS_POPUP) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", $iFlags) ;End Set $WS_POPUP style part $aClassList = StringSplit(_WinGetClassListEx($hWnd), @LF) $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) For $i = 1 To UBound($aClassList) - 1 $aCtrlPos = ControlGetPos($hWnd, '', $aClassList[$i]) If Not IsArray($aCtrlPos) Then ContinueLoop $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _ "long", $aCtrlPos[0], _ "long", $aCtrlPos[1], _ "long", $aCtrlPos[0] + $aCtrlPos[2], _ "long", $aCtrlPos[1] + $aCtrlPos[3]) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc Func _WinGetClassListEx($sTitle) Local $sClassList = WinGetClassList($sTitle) Local $aClassList = StringSplit($sClassList, @LF) Local $sRetClassList = "", $sHold_List = "|" Local $aiInHold, $iInHold For $i = 1 To UBound($aClassList) - 1 If $aClassList[$i] = "" Then ContinueLoop If StringRegExp($sHold_List, "\|" & $aClassList[$i] & "~(\d+)\|") Then $aiInHold = StringRegExp($sHold_List, ".*\|" & $aClassList[$i] & "~(\d+)\|.*", 1) $iInHold = Number($aiInHold[UBound($aiInHold)-1]) If $iInHold = 0 Then $iInHold += 1 $aClassList[$i] &= "~" & $iInHold + 1 $sHold_List &= $aClassList[$i] & "|" $sRetClassList &= $aClassList[$i] & @LF Else $aClassList[$i] &= "~1" $sHold_List &= $aClassList[$i] & "|" $sRetClassList &= $aClassList[$i] & @LF EndIf Next Return StringReplace(StringStripWS($sRetClassList, 3), "~", "") EndFunc Func QuitApp() Exit EndFunc Func WM_MOVE($hWndGUI) If $hWndGUI <> $BG Then Return $GUI_RUNDEFMSG Local $ParentPosArr = WinGetPos($hWndGUI) WinMove($Main_Gui, "", $ParentPosArr[0], $ParentPosArr[1]) EndFunc Func WM_ACTIVATE($hWndGUI) If $hWndGUI = $BG Then WinActivate($Main_Gui) EndFunc1 point