Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/08/2016 in Posts

  1. Checkboxes If LVS_EX_CHECKBOXES extended style is applied to a listview, two images are automatically added to the state image list: An unchecked checkbox (index 0) and a checked checkbox (index 1). You can get a handle for the state image list with $hStateImageList = _GUICtrlListView_GetImageList( $hListView, 2 ) ; 2 = Image list with state images Then you can set the state image list as a normal small icon image list: _GUICtrlListView_SetImageList( $hListView, $hStateImageList, 1 ) ; 1 = Image list with small icons If you apply this code line to all listview items the result is two checkboxes in first column: _GUICtrlListView_SetItemImage( $hListView, $iItem, 0 ) ; Unchecked checkbox (index 0) for $iItem Use this code line to add subitem checkboxes (requires LVS_EX_SUBITEMIMAGES extended style) to fourth column: _GUICtrlListView_SetItemImage( $hListView, $iItem, 0, 3 ) ; 3 is the zero based index of fourth column Another consequence of LVS_EX_CHECKBOXES extended style is that the image is automatically switched between the unchecked and checked ckeckbox when you click the icon. You have to implement this functionality yourself for the checkboxes added through the normal image list. This is easily done by responding to NM_CLICK events in a WM_NOTIFY message handler: Case $NM_CLICK Local $aHit = _GUICtrlListView_SubItemHitTest( $hListView ) If $aHit[6] Then ; On item? If $aHit[3] Then ; On icon? If $aHit[1] = 0 Or $aHit[1] = 3 Then ; On subitem 0 or 3? Local $iImage = _GUICtrlListView_GetItemImage( $hListView, $aHit[0], $aHit[1] ) ; Image index 0 or 1 _GUICtrlListView_SetItemImage( $hListView, $aHit[0], $iImage ? 0 : 1, $aHit[1] ) ; Switch index value EndIf ; $iItem $iImage $iSubItem EndIf EndIf The above is demonstrated in example 1) Subitem checkboxes.au3. If you don't want checkboxes for all of the listview items example 2) Remove some checkboxes.au3 shows how to remove some of the checkboxes. This is a picture of example 2: In example 1 and 2 the selected and focused states are removed from the listview items. Overlay icons In this picture of example 3) Overlay icons.au3 you can see cyan, green and yellow overlay icons on top of the original item icons: Overlay icons are stored in the small and large image lists. The function ImageList_SetOverlayImage implemented in GuiImageListEx.au3 tells the image list that this is a special image that is used as an overlay icon. Overlay icons must be stored among the first 15 images in the image list. To apply an overlay icon to a listview item the one based image index of the overlay icon must be stored in bits 8 - 11 in the state member of the LVITEM structure. Because 4 bits are used to store the image index you can only use 15 overlay icons. If all 4 bits are zero, it means that there is no overlay icon. Use these commands to add cyan, green and yellow overlay icons as the first three images in the image list: _GUIImageList_AddIcon( $hImageList, "icons\Cyan.ico" ) ; Index 0 _GUIImageList_AddIcon( $hImageList, "icons\Green.ico" ) ; Index 1 _GUIImageList_AddIcon( $hImageList, "icons\Yellow.ico" ) ; Index 2 Tell the imagelist that this is overlay icons: ImageList_SetOverlayImage( $hImageList, 0, 1 ) ; First overlay icon ImageList_SetOverlayImage( $hImageList, 1, 2 ) ; Second overlay icon ImageList_SetOverlayImage( $hImageList, 2, 3 ) ; Third overlay icon Add overlay icons to listview items A, B, C (256 = 2^8 is the value of bit 8): _GUICtrlListView_SetItemState( $hListView, $iItemA, 1 * 256 , $LVIS_OVERLAYMASK ) ; First overlay icon, cyan _GUICtrlListView_SetItemState( $hListView, $iItemB, 2 * 256 , $LVIS_OVERLAYMASK ) ; Second overlay icon, green _GUICtrlListView_SetItemState( $hListView, $iItemC, 3 * 256 , $LVIS_OVERLAYMASK ) ; Third overlay icon, yellow _GUICtrlListView_SetItemState( $hListView, $iItemD, 0 * 256 , $LVIS_OVERLAYMASK ) ; Remove an overlay icon State images If you want to use your own custom state images eg. green, yellow and red images (to signal ok, warning and error) instead of checkboxes, apply the LVS_EX_CHECKBOXES extended style to the listview, get a handle to the state image list, delete the images of the unchecked (index 0) and checked (index 1) checkboxes and add the green, yellow and red images to the state image list. Add custom state images to listview items A, B, C: _GUICtrlListView_SetItemStateImage( $hListView, $iItemA, 1 ) ; First state image, green _GUICtrlListView_SetItemStateImage( $hListView, $iItemB, 2 ) ; Second state image, yellow _GUICtrlListView_SetItemStateImage( $hListView, $iItemC, 3 ) ; Third state image, red _GUICtrlListView_SetItemStateImage( $hListView, $iItemD, 0 ) ; Remove a state image If you click a green state image, the image switches to yellow. If you click a yellow state image, it switches to red. If you click a red state image, it switches to green again. No code is needed for the image switching. It's a consequence of the LVS_EX_CHECKBOXES extended style. This is demonstrated in example 4) State images.au3. CheckboxesAndIcons.7z icons\ - Overlay icons 1) Subitem checkboxes.au3 2) Remove some checkboxes.au3 3) Overlay icons.au3 4) State images.au3 GuiImageListEx.au3 GuiListViewEx.au3 You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) CheckboxesAndIcons.7z
    2 points
  2. Hello Community, here's the latest update on... SMF - Search my Files Current Version: v18 (2025-May-18) SMF - Search my Files features A good looking GUI, Search files by location, Search files and / or folders, Poll [-]File names and Locations in Long and Short (8.3) format, [-]File Extensions, [-]File Times (modified, created, accessed), [-]File size, [-]File Attributes, [-]File Extended Attributes, Filter by [-]Extension, [-]Attribute, [-]File size, [-]File time, Free Name filtering by usage of RegEx, GUI designed to fit to 800x600 desktops with Tab-Design Nice looking Icon Minimize to Tray (also while searching) Export Result to CSV-file Export Result to XML-file Save & Load search runs Build Tree for local Computer on StartUp, add NetworkDrives optional A separate Report-GUI [-]Pre-Select output columns [-]SQLite driven [-]Dynamically generated statements, fully user adjustable [-]Dynamically sub filtering of results on the fly [-]Results can be executed directly, starting with the default associated program (ShellExcecute) [-]Select Results by drag, copy selected URIs to clipboard [-]Copy, move, delete or Erase results or subset of results md5 driven Duplicate file finder [-]High-Performance [-]added trimmed md5 short calculation (false md5, but sufficient for dup-search and a great speed improvement!) [-]Search 30.000 pics for dups in 1min 30secs Added many other ideas (some not activated / implemented yet) Limitations / Bugs / ToDos Lots and lots of unnecessary Global Variables Ugly code PLUS violations of any coding principal known to man... But hey, thats why I release the source, so that YOU help me to further improve SMF... SMF works fine at least on the 32bit XP SP3 and 64bit Win7/Win8/Win10 machines and I've tested it on. If you find bugs please let me know. Thanks to my sweet girlfriend for reviewing, giving new ideas and having so much patience with me :-*. Thanks to Jon, Larry, Jos, Valik, Jpm, Melba23 and Trancexx and for creating AutoIt and maintaining the forum. And finally thanks to all these great guys from the forum, providing excellent UDFs, snippets of code I use in SMF or help and feedback: Achilles, Ascend4nt, Ed_Maximized, Elgabionline, Erik Pilsits (Wraithdu), Eukalyptus, Gafrost, Holger Kotsch, Jarvis J. Stubblefield (JSThePatriot), Jos, Lahire Biette, Lazycat, Lod3n, Prog@ndy, Ptrex, Rasim, RazorM, RobSaunders, Sean Hart, Siao, Simucal, Smashly, SmOke_N, Teh_hahn, Valik, Ward, WideBoyDixon, Yann Perrin, Yashied & Zedna. Please let me know if you found some piece of code in the source for which I forgot to mention a credit. The executable and the source can be downloaded from my site: https://funk.eu Enjoy, let me know what you think of SMF and with Best Regards
    1 point
  3. Hello all ! Here are some functions that I have created to manipulate multidimensionnal arrays. I think some of them can be useful. Some functions are limited to 32 dimensions. List of the functions : _ArrayAssign : Assigns an array variable by name with the data. _ArrayCompare : Checks if two array are identical (size or data) _ArrayDeclare : Creates an empty array with the specified size. _ArrayDeclareFromString : Creates an array from an array declaration type string. _ArrayEnumValues : Returns all values and indexes of an array in a 2D array. _ArrayEval : Returns the array from an array variable name, or the value of an array element by its name _ArrayShuffleMultiDim : Shuffle the whole data of an array. _ArrayToDeclarationString : Returns an array declaration string. The returned string can be used with _ArrayDeclareFromString. Some examples : _Example1() _Example2() _Example3() _Example4() _Example5() _Example6() _Example7() Func _Example1() Local $aArray1 = _ArrayDeclareFromString("[ [ 1, 2, 3], ['a', 'b', 'c'], [True, False, Null], [], [0x10, 1.3, -10.2E-3] ]") _ArrayDisplay($aArray1, "_ArrayDeclareFromString") EndFunc Func _Example2() Global $aArray2 = [[1,2,""], [4,5,6]] ; Must be a global variable _ArrayDisplay($aArray2, "Before _ArrayAssign") _ArrayAssign("aArray2[0][2]", 3) _ArrayDisplay($aArray2, "After _ArrayAssign") EndFunc Func _Example3() Local $aValues = [ [1,2,3], ['a', True, False] ] _ArrayAssign("aArray3", $aValues) Local $aRet = _ArrayEval("aArray3") _ArrayDisplay($aRet, "_ArrayEval") MsgBox(0, "", "Value for aArray3[1][0] : " & _ArrayEval("aArray3[1][0]") ) EndFunc Func _Example4() Local $aArray3 = [ [[ "000", "001", "002"], ["010", "011", "012"]] , [[ "100", "101", "102"], ["110", "111", "112"]] ] Local $aArray = _ArrayEnumValues($aArray3) _ArrayDisplay($aArray) EndFunc Func _Example5() Local $aArray4 = [ [1, 2, 3], [], ['A string', "That's so ""cool"" !"], [0x10, 1.3, -10.2E-3] ] Local $sDeclaration = _ArrayToDeclarationString($aArray4) MsgBox(0, "", $sDeclaration) EndFunc Func _Example6() Local $aArray5 = [ [[ "000", "001", "002"], ["010", "011", "012"]] , [[ "100", "101", "102"], ["110", "111", "112"]] ] Local $aBefore = _ArrayEnumValues($aArray5) _ArrayDisplay($aBefore, "Before shuffle") _ArrayShuffleMultiDim($aArray5) Local $aAfter = _ArrayEnumValues($aArray5) _ArrayDisplay($aAfter, "After shuffle") EndFunc Func _Example7() Local $aArray6 = [[1, 2], [3, 4]] Local $aArray7 = [["", 2], [3, 4]] Local $iRet = _ArrayCompare($aArray6, $aArray7) If $iRet Then MsgBox(0, "", "Arrays have exactly the same size") Else MsgBox(0, "", "Arrays do not have the same size and dimension.") EndIf $iRet = _ArrayCompare($aArray6, $aArray7, 1) If $iRet Then MsgBox(0, "", "Arrays have exactly the same size and values") Else MsgBox(0, "", "Arrays do not have the same size and values.") EndIf EndFunc ArrayMultiDim.au3
    1 point
  4. Items in a standard listview in details/report view (this example deals only with listviews in details/report view) can display a single line of text. There seems not to be any options to change this. There is no word wrap option. If you search the forums, it's possible to find examples of listviews with multiple lines of text in each row. The multi-line items are implemented as owner drawn items through LVS_OWNERDRAWFIXED control style and WM_DRAWITEM messages. A problem with the owner drawn technique is that you are forced to draw everything yourself. Besides item texts and the background behind texts (white for non-selected items, dark blue for selected items with focus, button face for selected items without focus) you also have to draw checkboxes, images, icons and the background behind these elements yourself. Another technique is custom drawn listview items. Custom drawn items are implemented through NM_CUSTOMDRAW notifications included in WM_NOTIFY messages. NM_CUSTOMDRAW notifications are generated automatically by the code in ComCtl32.dll when the listview is updated. Implementing custom drawn items is a matter of responding to these messages or not. The great advantage of custom drawn items is that the drawing process is divided into several stages. For a listview up to six different stages. Some of these stages can be used for default drawing without any additional code at all. Other stages can be used for custom drawing with your own code. Multi-line text items fits perfectly with the custom drawn technique. Item texts and the background is drawn by custom code. Checkboxes, images, icons and the background is drawn by default code. Increase height of listview items The usual way to increase the height of listview items is to respond to WM_MEASUREITEM messages. But this method can only be used for owner drawn listviews. In a custom drawn listview the height can be increased by defining a text font with a suitable height: Func _GUICtrlListView_SetItemHeightByFont( $hListView, $iHeight ) ; Get font of ListView control ; Copied from _GUICtrlGetFont example by KaFu ; See https://www.autoitscript.com/forum/index.php?showtopic=124526 Local $hDC = _WinAPI_GetDC( $hListView ), $hFont = _SendMessage( $hListView, $WM_GETFONT ) Local $hObject = _WinAPI_SelectObject( $hDC, $hFont ), $lvLOGFONT = DllStructCreate( $tagLOGFONT ) _WinAPI_GetObject( $hFont, DllStructGetSize( $lvLOGFONT ), DllStructGetPtr( $lvLOGFONT ) ) Local $hLVfont = _WinAPI_CreateFontIndirect( $lvLOGFONT ) ; Original ListView font _WinAPI_SelectObject( $hDC, $hObject ) _WinAPI_ReleaseDC( $hListView, $hDC ) _WinAPI_DeleteObject( $hFont ) ; Set height of ListView items by applying text font with suitable height $hFont = _WinAPI_CreateFont( $iHeight, 0 ) _WinAPI_SetFont( $hListView, $hFont ) _WinAPI_DeleteObject( $hFont ) ; Restore font of Header control Local $hHeader = _GUICtrlListView_GetHeader( $hListView ) If $hHeader Then _WinAPI_SetFont( $hHeader, $hLVfont ) ; Return original ListView font Return $hLVfont EndFunc Large images will also increase the height of listview items. See example E. Height of listview If the height of the listview does not fit an integer number of rows, you can see empty space below last row in the bottom of the listview. This issue is exacerbated by tall items. The following function is used to calculate the height of the listview to match a given number of rows: Func _GUICtrlListView_GetHeightToFitRows( $hListView, $iRows ) ; Get height of Header control Local $tRect = _WinAPI_GetClientRect( $hListView ) Local $hHeader = _GUICtrlListView_GetHeader( $hListView ) Local $tWindowPos = _GUICtrlHeader_Layout( $hHeader, $tRect ) Local $iHdrHeight = DllStructGetData( $tWindowPos , "CY" ) ; Get height of ListView item 0 (item 0 must exist) Local $aItemRect = _GUICtrlListView_GetItemRect( $hListView, 0, 0 ) ; Return height of ListView to fit $iRows items ; Including Header height and 8 pixels of additional room Return ( $aItemRect[3] - $aItemRect[1] ) * $iRows + $iHdrHeight + 8 EndFunc The calculation includes the height of the header. This means that the function works for a multi-line header with tall items (example A and B). Reference example WM_NOTIFY messages and NM_CUSTOMDRAW notifications are send to the parent of the listview control. The parent is the AutoIt GUI and messages can be handled by a function registered with GUIRegisterMsg. Example 1 is a reference example which shows the different stages of the custom drawing process. None of the stages contains any code except for ConsoleWrite statements. This is code for the reference example: #include <GUIConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" Opt( "MustDeclareVars", 1 ) Global $hGui, $idListView, $hListView, $fListViewHasFocus = 0, $iItems = 3, $bAutoItMsgLoop = False Example() Func Example() ; Create GUI $hGui = GUICreate( "Custom draw stages", 420, 200 ) ; Create ListView $idListView = GUICtrlCreateListView( "", 10, 10, 400, 180, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE+$LVS_EX_FULLROWSELECT+$LVS_EX_GRIDLINES ) $hListView = GUICtrlGetHandle( $idListView ) ; Add columns to ListView _GUICtrlListView_AddColumn( $hListView, "Column 1", 94 ) _GUICtrlListView_AddColumn( $hListView, "Column 2", 94 ) _GUICtrlListView_AddColumn( $hListView, "Column 3", 94 ) _GUICtrlListView_AddColumn( $hListView, "Column 4", 94 ) ; Fill ListView For $i = 0 To $iItems - 1 GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView ) Next ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows( $hListView, 10 ) WinMove( $hGui, "", Default, Default, Default, WinGetPos( $hGui )[3] - WinGetClientSize( $hGui )[1] + $iLvHeight + 20 ) WinMove( $hListView, "", Default, Default, Default, $iLvHeight ) ; Register WM_NOTIFY message handler ; To handle NM_CUSTOMDRAW notifications ; And to check when ListView receives/loses focus GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Register WM_ACTIVATE message handler ; If GUI loses focus selected listview items are drawn with a button face background color. ; To check when GUI receives/loses focus ; When GUI receives focus selected items are redrawn with the dark blue background color. GUIRegisterMsg( $WM_ACTIVATE, "WM_ACTIVATE" ) ; Detection of received focus is faster through the WM_ACTIVATE message than directly ; through the listview. This provides a faster and smoother redraw of selected items. ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If Not $bAutoItMsgLoop Then _ ; We want to see only one message at a time $bAutoItMsgLoop = ( ConsoleWrite( "AutoIt message loop <<<<<<<<<<<<<<<<<<<<<" & @CRLF ) > 0 ) WEnd ; Cleanup GUIDelete() EndFunc ; WM_NOTIFY message handler Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Local $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Local $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW $bAutoItMsgLoop = False Local $tNMLVCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Specifies the drawing stage ; Stage 1 Case $CDDS_PREPAINT ; Before the paint cycle begins ConsoleWrite( "Stage 1: CDDS_PREPAINT" & @CRLF ) Return $CDRF_NOTIFYITEMDRAW + _ ; Stage 2 will be carried out $CDRF_NOTIFYPOSTPAINT ; Stage 6 will be carried out Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window before an item is painted Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after the paint cycle is complete ; Stage 2 Case $CDDS_ITEMPREPAINT ; Before an item is painted ConsoleWrite( "Stage 2: CDDS_ITEMPREPAINT" & @CRLF ) Return $CDRF_NOTIFYSUBITEMDRAW + _ ; Stage 3 will be carried out $CDRF_NOTIFYPOSTPAINT ; Stage 5 will be carried out Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window before a subitem is painted Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after an item is painted ; Stage 3 Case BitOR( $CDDS_ITEMPREPAINT, _ $CDDS_SUBITEM ) ; Before a subitem is painted ConsoleWrite( "Stage 3: CDDS_ITEMPREPAINT, CDDS_SUBITEM" & @CRLF ) Return $CDRF_NOTIFYPOSTPAINT ; Stage 4 will be carried out Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after a subitem is painted ; Stage 4 Case BitOR( $CDDS_ITEMPOSTPAINT, _ $CDDS_SUBITEM ) ; After a subitem has been painted ConsoleWrite( "Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM" & @CRLF ) ; Stage 5 Case $CDDS_ITEMPOSTPAINT ; After an item has been painted ConsoleWrite( "Stage 5: CDDS_ITEMPOSTPAINT" & @CRLF ) ; Stage 6 Case $CDDS_POSTPAINT ; After the paint cycle is complete ConsoleWrite( "Stage 6: CDDS_POSTPAINT" & @CRLF ) EndSwitch Case $NM_KILLFOCUS If $fListViewHasFocus Then GUICtrlSendMsg( $idListView, $LVM_REDRAWITEMS, 0, $iItems - 1 ) $fListViewHasFocus = 0 EndIf Case $NM_SETFOCUS If Not $fListViewHasFocus Then _ GUICtrlSendMsg( $idListView, $LVM_REDRAWITEMS, 0, $iItems - 1 ) $fListViewHasFocus = 2 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ; WM_ACTIVATE message handler Func WM_ACTIVATE( $hWnd, $iMsg, $wParam, $lParam ) #forceref $iMsg, $lParam If $hWnd = $hGui Then _ $fListViewHasFocus = BitAND( $wParam, 0xFFFF ) ? 1 : 0 Return $GUI_RUNDEFMSG EndFunc Code is added to check when GUI and listview receives and loses focus. This is important in the other examples. Output in SciTE console immediately after example is opened: Stage 1: CDDS_PREPAINT Stage 2: CDDS_ITEMPREPAINT Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 5: CDDS_ITEMPOSTPAINT Stage 2: CDDS_ITEMPREPAINT Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 5: CDDS_ITEMPOSTPAINT Stage 2: CDDS_ITEMPREPAINT Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 5: CDDS_ITEMPOSTPAINT Stage 6: CDDS_POSTPAINT AutoIt message loop <<<<<<<<<<<<<<<<<<<<< Note that the entire custom draw process from stage 1 to 6 is not interrupted by the AutoIt message loop. The other examples are all based on the reference example. Examples This is common to all examples. First line in item texts is stored directly in the listview. Additional lines are stored in a global array named $aLines. Index in the array is item ID as returned by GUICtrlCreateListViewItem and stored in ItemParam internally in listview memory. Item texts and background is drawn with custom code. Other item elements and background is drawn with default code. In all examples LVS_SINGLESEL style is removed to be able to select multiple items. This is a picture of example E: Example 2, 3 and 4 are simple examples. Example 5 and 6 deals with subitem icons and colors. Example 7 about listview notifications shows a way to catch double click and Enter key. A dummy control is used to forward the double click event to AutoIt main message loop to avoid lengthy or blocking code in WM_NOTIFY function. Example 8 and 9 shows how to respond to header notifications and how to rearrange columns by dragging header items with the mouse. In both examples LVS_EX_HEADERDRAGDROP extended style is added to the listview. When columns are rearranged, header item index and listview subitem index is always the same independent of column position, while header item order changes depending on column position. Because the header is a child control of the listview, the listview must be subclassed to catch header notifications. Subclassing is implemented with the four functions SetWindowSubclass, GetWindowSubclass, RemoveWindowSubclass and DefSubclassProc (all implemented in WinAPIShellEx.au3). Since we are subclassing a header control contained in a listview this issue must be taking into account. Note that the subclass callback function is only running while the primary mouse button is pressed on the header. This means no performance impact on the listview eg. when you are dragging the scroll bar. This is important for a custom drawn listview. Quite a lot of extra code is added (most easily seen in example 9) to fix an issue due to column 0 and other columns have different left margins. When first column is moved to another position there is a white gap between columns for selected rows (Windows XP), or the text is painted too close to the left edge of the item (Windows 7). The problem is seen in the picture to the right where the two first columns are swapped: LVS_EX_HEADERDRAGDROP style is only used in example 8 and 9. Usage of a multi-line header is demonstrated in example A and B. See Custom/owner drawn multi-line header in ListView for more information. Example C shows a method to deal with focus issues when more controls (here just a single button) are added to the GUI. When the listview has focus selected items are drawn with the dark blue background color. The problem arises if the listview and GUI loses focus eg. to Calculator. When focus is lost selected items are drawn with the button face background color. If GUI receives focus again by clicking the button (and not the listview), selected items are first very briefly redrawn with the dark blue background color (it seems like a blink) and then with the correct button face background color. To avoid this issue a hidden label control is added to the GUI. Immediately before the GUI loses focus, focus is moved from the listview to the label. In example D items are added with the commands _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem. In all examples an array is used to store the multi-line item texts. The array contains all lines except the first line which is stored directly in the listview. This example shows how to manually store array row index in ItemParam when items are added with _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem. Inspiration for example E about large images in first column (see picture above) comes from this thread. In example E the images are used to increase the height of the listview items instead of a text font. Because it's large 128x128 pixel images there is plenty of room in subitems in second and third column. In all examples 15 lines of code is used to repaint the first line item text. The text that was painted by default code in middle of the item is first deleted by filling the item with the background color. Then the text is extracted from the listview and repainted in top of item. This code can be avoided by storing all text lines in the array. This is demonstrated in example F. This makes the custom draw code faster. Performance considerations In a custom drawn (or owner drawn or virtual) listview performance considerations are important because the custom drawing (or owner drawing or data display) is performed by AutoIt code. In a normal listview drawing and data display is performed by compiled C++ code in ComCtl32.dll. Lengthy and slow code in NM_CUSTOMDRAW Case statements (or WM_DRAWITEM functions or LVN_GETDISPINFO Case statements) should be avoided. Perform as many calculations as possible before the repetitive and fast executions of these code blocks. Use static variables to avoid repeating the same calculation again and again. Executing a function directly with DllCall or GUICtrlSendMsg is faster than executing the same function through an implementation in an UDF. Simple GDI functions are faster than more advanced GDI+ functions. Use different drawing stages to optimize custom drawing. The CDDS_PREPAINT stage is only performed once for the entire drawing process. The CDDS_ITEMPREPAINT stage is performed once per item. The stage given by BitOR( CDDS_ITEMPREPAINT, CDDS_SUBITEM ) is performed once per subitem including subitem 0. Default drawing should be used as much as possible, because the code is running in ComCtl32.dll. In a listview the time it takes to update all visible rows is proportional to the number of visible rows. Reducing the height of the list view and thus the number of visible rows improves performance. Especially in a custom drawn (or owner drawn or virtual) listview. ListviewMultilineItems.7z 1) Custom draw stages.au3 2) Two-line listview items.au3 3) Three-line listview items.au3 4) First column checkbox and icon.au3 5) Check boxes and icons.au3 6) Background and text colors.au3 7) ListView notifications.au3 8) Header notifications.au3 9) Rearrange columns.au3 A) Multi-line header 1.au3 A) Multi-line header 2.au3 C) Button control.au3 D) _GUICtrlListView_AddItem.au3 E) Large images in first column.au3 F) Storing all lines in array.au3 GuiHeaderEx.au3 GuiListViewEx.au3 ListViewCustomDraw.au3 Images\ 8 images for example E You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListviewMultilineItems.7z
    1 point
  5. I know your problem is solved, but maybe you can modify your regex to add a blank value at the first position of your returned array. Here is the trick : #Include <Array.au3> $string = "This is a string with seven words" $aWords = StringRegExp($string, "(?|^()|(\w+))", 3) $aWords[0] = UBound($aWords) - 1 _ArrayDisplay($aWords)You can note the empty group ^() which captures an empty value once. It's the first value of the returned array, so you can set it to UBound($array) - 1
    1 point
  6. GMK

    OOo/LibO Calc UDF

    Before I upload any of the above changes, are there any other feature requests to research and implement?
    1 point
  7. There are lots of alternative GUI inspection tools, many of them free. I use Ranorex myself, but that one is now proprietary.
    1 point
  8. KaFu

    File-save (encoding)

    Create the .ini file manually with the correct encoding (before first write). $h_file = FileOpen(@ScriptDir & "\data.ini", 2 + 1024) ; 1024 = UTF16-LE > initially create ini file in unicode format FileWrite($h_file, "[Settings]" & @CRLF) ; you need to write something FileClose($h_file)
    1 point
  9. It can be done: #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $idListView, $hListView, $fListViewHasFocus = 0, $hLVfont, $iItems Example() Func Example() $hGui = GUICreate("ListView Get Item Text", 500, 300) ; $hGui is used in WM_ACTIVATE $idListView = GUICtrlCreateListView("", 2, 2, 494, 268) $hListView = GUICtrlGetHandle( $idListView ) ;GUISetState(@SW_SHOW) ; Increase item height ; Because a larger font is set for the listview, all $hLVfont = _GUICtrlListView_SetItemHeightByFont( $hListView, 26 ) ; items must be displayed through WM_NOTIFY function ; to be able to display the text with the original font. ; Add columns _GUICtrlListView_AddColumn($idListView, "Items", 100) _GUICtrlListView_AddColumn($idListView, "Column 2", 100) _GUICtrlListView_AddColumn($idListView, "Column 3", 100) _GUICtrlListView_AddColumn($idListView, "Column 4", 100) ; Add items ;_GUICtrlListView_AddItem($idListView, "Item 1") ; More columns and lines are added to be able ;_GUICtrlListView_AddItem($idListView, "Item 2") ; to test performance with the scrollbar. If ;_GUICtrlListView_AddItem($idListView, "Item 3") ; scrolling is OK performance is OK. For $i = 1 To 1000 If Mod( $i, 3 ) = 2 Then ; GUICtrlCreateListViewItem is used because of performance GUICtrlCreateListViewItem( "Item " & $i & @CRLF & "Second line" & "|Item " & $i & " Col 2" & @CRLF & "Second line col 2" & "|Item " & $i & " Col 3" & @CRLF & "Second line col 3" & "|Item " & $i & " Col 4" & @CRLF & "Second line col 4", $idListView ) Else GUICtrlCreateListViewItem( "Item " & $i & "|Item " & $i & " Col 2" & "|Item " & $i & " Col 3" & "|Item " & $i & " Col 4", $idListView ) EndIf Next _GUICtrlListView_SetColumnWidth( $idListView, 0, 100 ) ; The long text lines have changed the column widths _GUICtrlListView_SetColumnWidth( $idListView, 1, 100 ) _GUICtrlListView_SetColumnWidth( $idListView, 2, 100 ) _GUICtrlListView_SetColumnWidth( $idListView, 3, 100 ) ; Set item 2 text ; HERE I ADD NEW LINE ;_GUICtrlListView_SetItemText($idListView, 1, "New Item 2" & @CRLF & "second line") ;MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Text: " & _GUICtrlListView_GetItemText($idListView, 1)) $iItems = _GUICtrlListView_GetItemCount( $idListView ) ; Register WM_NOTIFY message handler ; To handle NM_CUSTOMDRAW notifications ; And to check when ListView receives/loses focus GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Register WM_ACTIVATE message handler ; If GUI loses focus selected listview items are drawn with a button face background color. ; To check when GUI receives/loses focus ; When GUI receives focus selected items are redrawn with the dark blue background color. GUIRegisterMsg( $WM_ACTIVATE, "WM_ACTIVATE" ) ; Detection of received focus is faster through the WM_ACTIVATE message than directly ; through the listview. This provides a faster and smoother redraw of selected items. GUISetState(@SW_SHOW) ; Showing the GUI at this point ensures that the listview ; items are displayed through the WM_NOTIFY function. ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example ; WM_NOTIFY message handler Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam ; Use static variables to avoid recalculating everything on each function call Local Static $hDC, $iItem, $iSelected, $tRect = DllStructCreate( $tagRECT ), $pRect = DllStructGetPtr( $tRect ) Local Static $tLVitem = DllStructCreate( $tagLVITEM ), $pLVitem = DllStructGetPtr( $tLVitem ) Local Static $tBuffer = DllStructCreate( "wchar Text[4096]" ), $pBuffer = DllStructGetPtr( $tBuffer ) Local Static $hBrushNormal = _WinAPI_CreateSolidBrush( 0xFFFFFF ), $hBrushHighLight = _WinAPI_GetSysColorBrush( $COLOR_HIGHLIGHT ), $hBrushButtonFace = _WinAPI_GetSysColorBrush( $COLOR_BTNFACE ) Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Local $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Local $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tNMLVCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Specifies the drawing stage ; Stage 1 Case $CDDS_PREPAINT ; Before the paint cycle begins $hDC = DllStructGetData( $tNMLVCustomDraw, "hDC" ) ; Device context _WinAPI_SelectObject( $hDC, $hLVfont ) ; Set original font <<<<<<<<<<<<<<<<<<<<<<<<<<<< _WinAPI_SetBkMode( $hDC, $TRANSPARENT ) ; Transparent background Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window before an item is painted ; Stage 2 Case $CDDS_ITEMPREPAINT ; Before an item is painted $iItem = DllStructGetData( $tNMLVCustomDraw, "dwItemSpec" ) ; Item index $iSelected = GUICtrlSendMsg( $idListView, $LVM_GETITEMSTATE, $iItem, $LVIS_SELECTED ) ; Item state Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window before a subitem is painted ; Stage 3 Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before a subitem is painted: Default painting of checkbox, image, icon Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after a subitem is painted ; Stage 4 Case BitOR( $CDDS_ITEMPOSTPAINT, $CDDS_SUBITEM ) ; After a subitem has been painted: Custom painting of text lines Local $iSubItem = DllStructGetData( $tNMLVCustomDraw, "iSubItem" ) ; Subitem index ; Subitem rectangle DllStructSetData( $tRect, "Top", $iSubItem ) DllStructSetData( $tRect, "Left", $iSubItem ? $LVIR_BOUNDS : $LVIR_LABEL ) GUICtrlSendMsg( $idListView, $LVM_GETSUBITEMRECT, $iItem, $pRect ) ; Subitem back ground color ; Delete default painting of text because it's painted in the middle of the subitem ; And because it paints the entire text string including any @CRLF characters ; The text is deleted by filling the subitem rectangle with the back ground color DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $iSelected ? ( $fListViewHasFocus ? $hBrushHighLight : $hBrushButtonFace ) : $hBrushNormal ) ; _WinAPI_FillRect ; Subitem text color (fore color) DllCall( "gdi32.dll", "int", "SetTextColor", "handle", $hDC, "int", ( $iSelected And $fListViewHasFocus ) ? 0xFFFFFF : 0x000000 ) ; _WinAPI_SetTextColor ; Left margin of item text DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( $iSubItem ? 6 : 2 ) ) ; Extract text line directly from ListView DllStructSetData( $tLVitem, "Mask", $LVIF_TEXT ) DllStructSetData( $tLVitem, "SubItem", $iSubItem ) DllStructSetData( $tLVitem, "Text", $pBuffer ) DllStructSetData( $tLVitem, "TextMax", 4096 ) GUICtrlSendMsg( $idListView, $LVM_GETITEMTEXTW, $iItem, $pLVitem ) ; Does the text contain a @CRLF character combination Local $iPos = StringInStr( DllStructGetData( $tBuffer, "Text" ), @CRLF ) If Not $iPos Then ; No @CRLF characters, draw text line DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", DllStructGetData( $tBuffer, "Text" ), "int", -1, "struct*", $tRect, "uint", $DT_WORD_ELLIPSIS ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndIf ; The text is divided into two lines ; Paint first part of the text line DllStructSetData( $tBuffer, "Text", 0, $iPos ) ; 0-terminate first part of the text DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", DllStructGetData( $tBuffer, "Text" ), "int", -1, "struct*", $tRect, "uint", $DT_WORD_ELLIPSIS ) ; _WinAPI_DrawText ; Paint second part of the text line DllStructSetData( $tRect, "Top", DllStructGetData( $tRect, "Top" ) + 12 ) ; Top margin Local $tBuffer2 = DllStructCreate( "wchar Text[" & 4096-$iPos-2 & "]", $pBuffer + 2 * $iPos + 2 ) ; Buffer for second part of the text DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", DllStructGetData( $tBuffer2, "Text" ), "int", -1, "struct*", $tRect, "uint", $DT_WORD_ELLIPSIS ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch Case $NM_KILLFOCUS If $fListViewHasFocus Then GUICtrlSendMsg( $idListView, $LVM_REDRAWITEMS, 0, $iItems - 1 ) $fListViewHasFocus = 0 EndIf Case $NM_SETFOCUS If Not $fListViewHasFocus Then _ GUICtrlSendMsg( $idListView, $LVM_REDRAWITEMS, 0, $iItems - 1 ) $fListViewHasFocus = 2 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ; WM_ACTIVATE message handler Func WM_ACTIVATE( $hWnd, $iMsg, $wParam, $lParam ) #forceref $iMsg, $lParam If $hWnd = $hGui Then _ $fListViewHasFocus = BitAND( $wParam, 0xFFFF ) ? 1 : 0 Return $GUI_RUNDEFMSG EndFunc Func _GUICtrlListView_SetItemHeightByFont( $hListView, $iHeight ) ; Get font of ListView control ; Copied from _GUICtrlGetFont example by KaFu ; See https://www.autoitscript.com/forum/index.php?showtopic=124526 Local $hDC = _WinAPI_GetDC( $hListView ), $hFont = _SendMessage( $hListView, $WM_GETFONT ) Local $hObject = _WinAPI_SelectObject( $hDC, $hFont ), $lvLOGFONT = DllStructCreate( $tagLOGFONT ) _WinAPI_GetObject( $hFont, DllStructGetSize( $lvLOGFONT ), DllStructGetPtr( $lvLOGFONT ) ) Local $hLVfont = _WinAPI_CreateFontIndirect( $lvLOGFONT ) ; Original ListView font _WinAPI_SelectObject( $hDC, $hObject ) _WinAPI_ReleaseDC( $hListView, $hDC ) _WinAPI_DeleteObject( $hFont ) ; Set height of ListView items by applying text font with suitable height $hFont = _WinAPI_CreateFont( $iHeight, 0 ) _WinAPI_SetFont( $hListView, $hFont ) _WinAPI_DeleteObject( $hFont ) ; Restore font of Header control Local $hHeader = _GUICtrlListView_GetHeader( $hListView ) If $hHeader Then _WinAPI_SetFont( $hHeader, $hLVfont ) ; Return original ListView font Return $hLVfont EndFunc I'll admit it would have been easier with some kind of UDF. I'm working on that.
    1 point
  10. RTFC

    Help on SSL TCP/IP

    You're welcome, argumentum, and you're very lucky to have trancexx as your guiding star. Re. getting your feet wet with C++, you may find this thread of interest. Best of luck. RT
    1 point
  11. cres

    [SOLVED] InetGet error 13!

    Hi, Try adding HttpSetUserAgent HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0") Local $iInetRet = InetGet("https://www.autoitscript.com/autoit3/pkgmgr/sqlite/SQLite.dll.au3", @TempDir & "\SQLite.dll.au3", 9) ConsoleWrite("!Error: " & @error & @CRLF) I also got error code 13 without it.
    1 point
  12. Just a fast hack for next Thursday. Maybe too early but who cares... Source: ;coded by UEZ build 2016-01-08 ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "BassConstants.au3" #include "Bass.au3" _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iFrames = 0, $iShowFPS = 0, $fTimer, $bExit, $aAudio Global Const $iW = @DesktopWidth, $iH = @DesktopHeight, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Simple Firework by UEZ" Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $iMaxParticles = 51, $iFireworks = 10, $iParticleSize = 4 Global $iElements = 9, $aCoords[$iFireworks][$iElements + $iMaxParticles * 4 - 3] ;don't touch these values AutoItSetOption("GUIOnEventMode", 1) GDIPlus_SimpleFirework() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_SimpleFirework() $bExit = False $hGUI = GUICreate($sTitle & 0, $iW, $iH, 0, 0, $WS_POPUP) GUISetState(@SW_SHOW, $hGUI) WinSetTrans($hGUI, "", 0xF8) GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFFE0E0E0), _ $hBrush_Clr = _GDIPlus_BrushCreateSolid(0x70000000), _ $hBrush_Txt = _GDIPlus_BrushCreateSolid(0x10202020), $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xA0505050), _ $hFormat = _GDIPlus_StringFormatCreate(), $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily = _GDIPlus_FontFamilyCreate("Impact"), $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont = _GDIPlus_FontCreate($hFamily, $iH / 4.5), $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH), $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 150, 32) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $iX, $iY, $j = -2^32 + 1, $bAudio = True ;init sound _BASS_STARTUP() _BASS_Init(0, -1, 44100, 0, "") If @error Then $bAudio = False Local $aAudio[$iFireworks][2], $hAudio_Whoa, $hAudio_BgNoise For $iY = 0 To $iFireworks - 1 ;generated firework particles GenCoordinates($iY, $aCoords, 1.5, 3.5, 1, 5.5) If $bAudio Then $aAudio[$iY][0] = _BASS_StreamCreateFile(False, @ScriptDir & "\" & Random(1, 7, 1) & ".mp3", 0, 0, 0) $aAudio[$iY][1] = 0 EndIf Next $hAudio_Whoa = _BASS_StreamCreateFile(False, @ScriptDir & "\ApplauseWoah.mp3", 0, 0, 0) $hAudio_BgNoise = _BASS_StreamCreateFile(False, @ScriptDir & "\BgNoise.mp3", 0, 0, 0) _BASS_ChannelPlay($hAudio_BgNoise, True) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $iAlpha, $iCounterFX = 0, $iCounterParticles = 0 $fTimer = TimerInit() Do DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, _ "float", $iW, "float", $iH) ;erase canvas background _GDIPlus_GraphicsDrawStringEx($hCanvas, "Happy new year 2016", $hFont, $tLayout, $hFormat, $hBrush_Txt) ;draw background message text For $iY = 0 To $iFireworks - 1 ;calculate and draw firework particles If $aCoords[$iY][1] > $aCoords[$iY][4] Then ;draw rocket only until explosion $aCoords[$iY][0] += $aCoords[$iY][2] ;x vector $aCoords[$iY][1] -= Abs($aCoords[$iY][3] * 10) ;y vector should be in upper direction only _GDIPlus_BrushSetSolidColor($hBrush, 0x60909090) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", $aCoords[$iY][0], "float", $aCoords[$iY][1], "float", 2, "float", 2) $iCounterParticles += 1 For $iX = $iElements To UBound($aCoords, 2) - 5 Step 4 $aCoords[$iY][$iX] = $aCoords[$iY][0] ;copy x position $aCoords[$iY][$iX + 1] = $aCoords[$iY][1] ;copy y position Next Else For $iX = $iElements To UBound($aCoords, 2) - 5 Step 4 $aCoords[$iY][$iX] += $aCoords[$iY][$iX + 2] ;x coordinate $aCoords[$iY][$iX + 1] += $aCoords[$iY][$iX + 3] + $aCoords[$iY][8] ;y coordinate $aCoords[$iY][$iX + 2] *= 0.98 ;neg. accelaration of x vector $aCoords[$iY][$iX + 3] *= 0.98 ;neg. accelaration of y vector $iAlpha = $aCoords[$iY][6] > 0xFF ? 0xFF : $aCoords[$iY][6] Switch $aCoords[$iY][7] ;choose color mode Case 0 To 3 _GDIPlus_BrushSetSolidColor($hBrush, Int($iAlpha) * 0x1000000 + $aCoords[$iY][5]) Case Else Switch Mod($j, 3) Case 0 _GDIPlus_BrushSetSolidColor($hBrush, Int($iAlpha) * 0x1000000 + 0x10000 * Random(0xD0, 0xFF, 1) + 0x100 * Random(0xD0, 0xFF, 1) + Random(0xD0, 0xFF, 1)) Case Else _GDIPlus_BrushSetSolidColor($hBrush, Int($iAlpha) * 0x1000000 + 0x10000 * Random(0x40, 0xA0, 1) + 0x100 * Random(0x40, 0xA0, 1) + Random(0x40, 0xA0, 1)) EndSwitch $j += 1 EndSwitch ;draw only visible particles If BitAND($aCoords[$iY][$iX] > -1, $aCoords[$iY][$iX] < $iW, $aCoords[$iY][$iX + 1] > -1, $aCoords[$iY][$iX + 1] < $iH) Then DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hCanvas, "handle", $hBrush, _ "float", $aCoords[$iY][$iX], "float", $aCoords[$iY][$iX + 1], _ "float", $iParticleSize, "float", $iParticleSize) ;draw firework particles $iCounterParticles += 1 EndIf Next $aCoords[$iY][6] *= 0.933 ;decrease alpha channel $aCoords[$iY][8] *= 1.075 ;gravity accelaration (y axis) -> earth's gravitational force simulation If Not $aAudio[$iY][1] And $bAudio Then ;play audio fx _BASS_ChannelPlay($aAudio[$iY][0], False) $aAudio[$iY][1] = 1 $iCounterFX += 1 EndIf If $aCoords[$iY][6] < 0x08 Then ;reset firework elements $aAudio[$iY][1] = 0 GenCoordinates($iY, $aCoords) EndIf EndIf Next If $iCounterFX > 2 Then _BASS_ChannelPlay($hAudio_Whoa, False) EndIf _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS & @CRLF & "Particles: " & $iCounterParticles, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw background message text _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI $iCounterFX = 0 $iCounterParticles = 0 $iFPS += 1 $iFrames += 1 If $bExit Then ExitLoop Until Not Sleep(10) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_Txt) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC, $DC_obj) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) If $bAudio Then For $iY = 0 To $iFireworks - 1 _BASS_ChannelStop($aAudio[$iY][0]) Next _BASS_ChannelStop($hAudio_Whoa) _BASS_ChannelStop($hAudio_BgNoise) _BASS_Free() EndIf EndFunc ;==>GDIPlus_SimpleFirework Func GenCoordinates($iY, ByRef $aCoords, $fVXmin = 2.5, $fVXmax = 15.5, $fVYmin = 1.5, $fVYmax = 5.5) Local $aColors[7] = [0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF7514, 0xFFFFFF, 0x40E0D0] $aCoords[$iY][0] = $iWh ;x coordinate (x coordinate of starting point) $aCoords[$iY][1] = $iH ;y coordinate (y coordinate of starting point) $aCoords[$iY][2] = Random($fVXmin, $fVXmax) * (Random(0, 1, 1) = 0 ? -1 : 1) ;x vector (direction of rocket) $aCoords[$iY][3] = Random($fVYmin, $fVYmax) * (Random(0, 1, 1) = 0 ? -1 : 1) ;y vector (direction of rocket) $aCoords[$iY][4] = Random($iH * 0.15, $iH * 0.35) ;area of detonation ;~ $aCoords[$iY][5] = 0x10000 * Random(0x40, 0xE0, 1) + 0x100 * Random(0x40, 0xE0, 1) + Random(0x40, 0xE0, 1) ;random color $aCoords[$iY][5] = $aColors[Random(0, 6, 1)] ;random color $aCoords[$iY][6] = 0x250 ;alpha channel value $aCoords[$iY][7] = Random(0, 8, 1) ;value for color mode $aCoords[$iY][8] = 0.15 ;gravity accelaration (y axis) initial value Local $iX, $fSpeed, $fRadius, $iFX = Random(1, 20, 1), $e = Random(5, 25), $h = 0, $g = 360 / ($iMaxParticles - 1), _ $j = 360 / 10, $jj = $j, $k = Random(0.5, 1.5), $kk = Random(1, 3.5), $l = 0 For $iX = $iElements To UBound($aCoords, 2) - 5 Step +4 Switch $iFX Case 1 To 3 $fSpeed = Cos($g * $iFX * $e * $iX) * $e $fRadius = $fSpeed / 2 Case 4 To 6 $fSpeed = Sin($iX / 7.85) * $e ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 7 To 9 $fSpeed = Tan($iX / 2) + $e ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 10 To 12 $fSpeed = Cos($iX / 2.5) + $e ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 13 To 15 ;create circular effect $fSpeed = Random($e, $e + 0.333333) ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 16 To 18 $fSpeed = $e $fRadius = $k $h = $jj $jj += $j If $jj > 360 Then $jj = $j - $l $k += $kk $l += Random(1, 15) EndIf Case Else $fSpeed = Random(5, 25) ;particle speed (explosion strength) $fRadius = $fSpeed / 2 EndSwitch $aCoords[$iY][$iX + 2] = ($fSpeed + Cos($h * $fRad) * $fRadius) - $fSpeed ;x vector particle speed $aCoords[$iY][$iX + 3] = ($fSpeed + Sin($h * $fRad) * $fRadius) - $fSpeed ;y vector particle speed $h += $g ;next angle Next EndFunc ;==>GenCoordinates Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS & " / Ø " & Round($iFrames / TimerDiff($fTimer) * 1000, 4) $iFPS = 0 EndFunc ;==>CalcFPS Sound FX and other files are in the archive only! Sounds best with earphones Speed: ~17 FPS on Intel Core i5 4300U @ 2.6 GHz CPU (1600x900). If it is too slow on your machine decrease the values for $iMaxParticles and $iFireworks. Download available in download section. Use e.g. 7-Zip to open archive. Happy new year...
    1 point
  13. Glad we were able to help!
    1 point
  14. Damein

    StreamHelper

    1: I did not set the images, the images get downloaded only if the people you are following are playing that specific game. That is included in the StreamHelper.au3 in this section starting on line 171 $FilePath = @ScriptDir & "/Imgs/" & $sGame & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGame & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGame $StreamCount += 1 2: As for the no images until you close / re-open I don't recall this happening and cannot test at the moment. Might be a bug that I didn't encounter, not sure. 3: The file in question would be the StreamHelperGUI.au3 For the making the GUI larger, just simply adjust the Width & Height found on line 23. But know that if you do that you will have to adjust everything else too. If this is something you really want and aren't sure how to accomplish it let me know and I can adjust the script for you. 4: Never used the word paginate before but if you are referring to how it aligns the images / decides how many to input that's done in a couple different ways. Step 1: Found in StreamHelper.au3 on line 193 and 212 (Depending on an IF/Else statement) it adds +1 to a variable (GameCount) to determine how many different types of games are being played (IE: How many different images we need to produce) Step 2: Found in StreamHelperGUI.au3 on line 34 is a For statement going from 0 to X depending on how many games we found in StreamHelper.au3. It goes up +1 each time (Obviously) and then adds +250 to the X axis until it reaches 3 (Currently how many games are shown per row) and then resets the X axis to 40 (Starting Point) and sets a new Y axis to +320 to account for a new row. It then adds +300 to the variable X which is used to determine the length of the Scrollbar needed to view all of the images which is found on line 56 in StreamHelperGUI.au3 still. Hope that clears it all up. If anything isn't clear let me know and I'll try to rephrase or anything.
    1 point
  15. If you create a fake GUI and never set it to @SW_SHOW and set your real GUI to the child of the fake, the task bar button will never show up. #include <GUIConstants.au3> Global $frmFakeGUI = GUICreate("Fake GUI", 0, 0) Global $frmRealGUI = GUICreate("Real GUI", 200, 100, -1, -1, -1, -1, $frmFakeGUI) Global $lblMsg = GUICtrlCreateLabel("This is a GUI without a task bar icon", 10, 10, 180, 40) GUICtrlSetFont($lblMsg, 12) GUISetState(@SW_SHOW, $frmRealGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit 0 EndSwitch WEnd
    1 point
  16. With the iuiautomation thread in examples you can see you can control .NET and WinForms from AutoIT
    1 point
  17. I thought the same thing at first, but after re-reading the OP, he said his first part of code works...to my surprise. I haven't had much chance/opportunity to interact with .NET applications/controls, but I don't remember it being that easy before. I'm suppose it compatible as it's calling WinForms--which is what the standard controls are I believe AutoIt supports I believe--instead of WPF or some other UI toolset. Anyways, sounds like he sorted it out with 32 vs 64.
    1 point
  18. Try this instead of using ClickItem and sending {space} _GUICtrlTreeView_SetChecked($idTreeView, $hItemFound)Does that work?
    1 point
  19. Here you can find what I'm talking about. Here Jon describes how it works with strings.
    1 point
  20. I went from C and derivatives to VB then to AutoIt, and saw it, and still do, as an advance in programming. P.S. No need for anyone to point out the value of C etc, I already know, so I'm just saying. We are empowered by what we can efficiently use, not by what is a powerful tool alone. Understanding is all!
    1 point
  21. RTFC

    Changing languages (Visual C)

    Hi McLEMUR, A decent starting point with lots of simple examples is http://www.cplusplus.com/doc/tutorial/, or try https://www.learncpp.com/ Two other reference sites I've found useful in the past are http://en.cppreference.com/w/cpp and http://www.java2s.com/Tutorial/Cpp/CatalogCpp.htm But coming from AutoIt, diving into C++ will be an uphill struggle (if you'll forgive me the metaphor mixing ). There is a lot of basic functionality that you'd expect any sophisticated language to have (*cough* garbage collection *cough*), that you'll either have to add yourself or find a good library for. An immense help for me has been the (free!) Boost libraries, see http://www.boost.org/, (and tutorials I found here, although I didn't use these much myself). Boost has really saved me acres of time, and it's quite intuitive to use. You'll need plenty of perseverance though, and think of your C++ compiler as simultaneously retarded and autistic. Every typo will likely crash your code, and the error messages you get may have nothing whatsoever to do with what actually went wrong, or be so generic that they don't help you. Of course, there's always http://stackoverflow.com/ if when you get stuck, but in my experience, some C++ forum members take on some of the same attributes as C++ compilers, i.e., being unforgiving towards beginners. Just google "I hate C++" to get an idea of what people run up against in your position. On second thought, maybe you'd better not, to remain motivated. Personally, I use C++ only for tasks that require speed and a reasonably high-level of complexity (CUDA interfacing in parallel computing, matrix computing with Eigen), but user-friendly it ain't, nor will it ever be. Can't really tell you much about the transition from AutoIt, because I started from the other end (Assembly), so it was more a question of mapping the concepts used there onto the C++ framework. I fear that coming from AutoIt, it'll be much harder. As far as compilers are concerned, CodeBlocks is much easier to start with, but at some point you'll run into situations where you'll need the extra control of literally hundreds of compiler/linker settings that MSVC offers. So you either start easy and have the extra pain of switching later, or bite the bullet now (although these newer versions of MSVC are more user-friendly than the earlier stuff). Hope it works out for you (but please do not PM me if you get stuck, okay? )
    1 point
×
×
  • Create New...