
DavidStark
Members-
Posts
11 -
Joined
-
Last visited
DavidStark's Achievements

Seeker (1/7)
0
Reputation
-
DavidStark reacted to a post in a topic: ListView CustomDraw highlighted row that stays when no selection is made
-
You sir, are amazing. I've been messing with this for a while trying all sorts of junk.... For some reason GetItemFocused never occurred to be the answer!
- 2 replies
-
- listview
- customdraw
-
(and 3 more)
Tagged with:
-
Hey guys, After much searching and reading I Siao's example script from the below link is the closest to what I need to do. I have a ListView that is populated with the names of different configurations. When a Listview item is selected, a form is populated with that items data. Right now I have a column that shows which item's data is shown in the form, but it would be much cleaner to just have the current item highlighted. My problem is this - The highlighting in Siao's example works great, but inside the Listview when you select in the "empty" space to essentially deselect everything the highlighting disappears. How can I keep the last selected item highlighted when clicking in this empty space? Also - I do not understand enough about Windows notifications to understand if we could utilize SendMessage to initiate a custom draw.... It seems to me that you could specify an item and then invoke the DLL function to redraw the item that you specified with the colors that you specified.... That's the idea I get when I read the MSDN documentation on it: https://msdn.microsoft.com/en-us/library/windows/desktop/ff919573(v=vs.85).aspx Siao's Example modified for latest AutoIt: #Include <GuiConstantsEx.au3> #Include <GuiListView.au3> #include <WindowsConstants.au3> #cs ;custom draw constants Global Const $CDDS_ITEM = 0x10000 Global Const $CDDS_MAPPART = 0x5 Global Const $CDDS_POSTERASE = 0x4 Global Const $CDDS_POSTPAINT = 0x2 Global Const $CDDS_PREERASE = 0x3 Global Const $CDDS_PREPAINT = 0x1 Global Const $CDDS_SUBITEM = 0x20000 Global Const $CDDS_ITEMPOSTERASE = BitOR($CDDS_ITEM, $CDDS_POSTERASE) Global Const $CDDS_ITEMPOSTPAINT = BitOR($CDDS_ITEM, $CDDS_POSTPAINT) Global Const $CDDS_ITEMPREERASE = BitOR($CDDS_ITEM, $CDDS_PREERASE) Global Const $CDDS_ITEMPREPAINT = BitOR($CDDS_ITEM, $CDDS_PREPAINT) Global Const $CDIS_CHECKED = 0x8 Global Const $CDIS_DEFAULT = 0x20 Global Const $CDIS_DISABLED = 0x4 Global Const $CDIS_FOCUS = 0x10 Global Const $CDIS_GRAYED = 0x2 Global Const $CDIS_HOT = 0x40 Global Const $CDIS_INDETERMINATE = 0x100 Global Const $CDIS_MARKED = 0x80 Global Const $CDIS_SELECTED = 0x1 Global Const $CDIS_SHOWKEYBOARDCUES = 0x200 Global Const $CDRF_DODEFAULT = 0x0 Global Const $CDRF_NEWFONT = 0x2 Global Const $CDRF_NOTIFYITEMDRAW = 0x20 Global Const $CDRF_NOTIFYPOSTERASE = 0x40 Global Const $CDRF_NOTIFYPOSTPAINT = 0x10 Global Const $CDRF_NOTIFYSUBITEMDRAW = 0x20 Global Const $CDRF_SKIPDEFAULT = 0x4 #ce ;fonts for custom draw example ;bold Global $aFont1 = DLLCall("gdi32.dll","int","CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 700, _ "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _ "dword", 0, "str", "") ;italic Global $aFont2 = DLLCall("gdi32.dll","int","CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 400, _ "dword", 1, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _ "dword", 0, "str", "") $GUI = GUICreate("Listview Custom Draw", 400, 300) $cListView = GUICtrlCreateListView("", 2, 2, 394, 268, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($cListView) _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100) ; Add items For $i = 1 To 30 _GUICtrlListView_AddItem($hListView, "Row" & $i & ": Col 1", $i-1) For $j = 1 To 2 _GUICtrlListView_AddSubItem ($hListView, $i-1, "Row" & $i & ": Col " & $j+1, $j) Next Next GUICtrlCreateInput("", 50, 275, 100, 15) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DLLCall("gdi32.dll","int","DeleteObject", "hwnd", $aFont1[0]) DLLCall("gdi32.dll","int","DeleteObject", "hwnd", $aFont2[0]) Exit Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _ 'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _ 'dword clrText;dword clrTextBk;int SubItem;' & _ 'dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText[4];int Align', _ ;winxp or later $lParam), $iDrawStage, $iItem, $iSubitem, $hDC, $tRect, $iColor1, $iColor2, $iColor3 $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage') Switch $iDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT Return $CDRF_NOTIFYSUBITEMDRAW Case $CDDS_ITEMPOSTPAINT Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) $iItem = DllStructGetData($tCustDraw, 'ItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'SubItem') If _GUICtrlListView_GetItemSelected($hWndFrom, $iItem) Then $hDC = _WinAPI_GetDC($hWndFrom) $tRect = DllStructCreate('long;long;long;long') If $iSubitem = 0 Then DllCall('user32.dll','int','SendMessage', 'hwnd',$hWndFrom, 'uint',$LVM_GETSUBITEMRECT, 'wparam',$iItem, 'lparam',DllStructGetPtr($tRect)) DllStructSetData($tRect, 1, 2) DllCall('user32.dll', 'int', 'FillRect', 'ptr', $hDC, 'ptr', DllStructGetPtr($tRect), 'int', _WinAPI_GetStockObject(4)) EndIf DllStructSetData($tRect, 1, 2) DllStructSetData($tRect, 2, $iSubitem) DllCall('user32.dll','int','SendMessage', 'hwnd',$hWndFrom, 'uint',$LVM_GETSUBITEMRECT, 'wparam',$iItem, 'lparam',DllStructGetPtr($tRect)) Local $sText = _GUICtrlListView_GetItemText($hWndFrom, $iItem, $iSubitem) DLLCall("gdi32.dll","int","SetTextColor", "ptr", $hDC, "int", RGB2BGR(0xffff00)) DLLCall("gdi32.dll","int","SetBkMode", "ptr", $hDC, "int", 1) DllStructSetData($tRect, 1, DllStructGetData($tRect, 1)+2) _WinAPI_DrawText($hDC, $sText, $tRect, 0x8000) ;; $DT_END_ELLIPSIS _WinAPI_ReleaseDC($hWndFrom, $hDC) Return $CDRF_SKIPDEFAULT EndIf Switch $iItem Case 0 To 9 ;for rows 1-10 lets do this $iColor1 = RGB2BGR(0xFBFFD8) $iColor2 = RGB2BGR(-1) $iColor3 = RGB2BGR(0xFF0000) If Mod($iSubitem, 2) Then ;odd columns DllStructSetData($tCustDraw, 'clrTextBk', $iColor1) DllStructSetData($tCustDraw, 'clrText', 0) Else ;even columns DllStructSetData($tCustDraw, 'clrTextBk', $iColor2) DllStructSetData($tCustDraw, 'clrText', $iColor3) EndIf Case 10 To 19 ;for rows 11-20 lets do this $iColor1 = RGB2BGR(0xFBFFD8) $iColor2 = RGB2BGR(0x3DF8FF) $hDC = DllStructGetData($tCustDraw, 'hdc') If Mod($iItem, 2) Then If Mod($iSubitem, 2) Then DllStructSetData($tCustDraw, 'clrTextBk', $iColor1) Else DllStructSetData($tCustDraw, 'clrTextBk', $iColor2) EndIf DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $hDC, "hwnd", $aFont1[0]) ;select our chosen font into DC Else If Mod($iSubitem, 2) Then DllStructSetData($tCustDraw, 'clrTextBk', $iColor2) Else DllStructSetData($tCustDraw, 'clrTextBk', $iColor1) EndIf DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $hDC, "hwnd", $aFont2[0]) EndIf Case 20 To 29 ;for rows 21-30 lets do this $iColor1 = RGB2BGR(0xFBFFD8) $iColor2 = RGB2BGR(-1) If Mod($iItem, 2) Then ;odd rows DllStructSetData($tCustDraw, 'clrTextBk', $iColor2) Else DllStructSetData($tCustDraw, 'clrTextBk', $iColor1) EndIf EndSwitch Return $CDRF_NEWFONT Case BitOR($CDDS_ITEMPOSTPAINT, $CDDS_SUBITEM) Case Else EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF) EndFunc Source:
- 2 replies
-
- listview
- customdraw
-
(and 3 more)
Tagged with:
-
Just to recap: These functions were much easier. Not that they saved lines or space, but are much simpler and more readable. I am not too familiar yet with using command-line interfaces. This worked, you can now use any path. I SplashTextOn() before starting the render to tell the path thats going to be rendered and show the command-line string..... I guess this was more for debugging and I could take it out now. I also added a checkmark for multiprocessing and to make a sound when the render is finished. Added a column for progress on the list, showing which one it is currently on, and the time it took to render the finished projects. I want to work on something where you could maybe choose the output module and path for each project, like have a different listview with the information of the selected project. Not sure how I would do this though. THANK YOU ALL FOR YOUR HELP! Any more suggestions? Check out the new one I've uploaded...
-
Ok I will try the quotes first.... This means that I have to double quote inside of the RunWait() correct? For example "-project ""C:my project.aep""" I want to avoid having to process each line and place a in front of it.... Rather than do that I would probably just do a FileMove() where I move and rename the file to something without spaces in it. It would keep all of the same attributes as the original file, it would just be a temporary that I use to render. Seems like that would be much easier. How do you mean check if the path is good? Just have it display the path and make sure there are not any extra spaces or characters?
-
Hmm, it was only today that I figured out how to use and control List and ListView. I will check into those functions tommorow.... Will they reduce the size of some of the lines? I feel like the functions used easily get me the desired result, but again, I will look into it. aerender.exe is a command line interface for After Effects, when you pass aerender.exe a path with spaces in it it cannot correctly parse it and results in a syntax error. It looks at the space as another parameter. Do you know of a way around this? I dont.... Thanks for the input!
-
This is for people who use Adobe After Effects a lot. You can queue up multiple projects and have it render them all for you at once. I am using it because I have 5 projects that each take an hour to render, so I will just leave it at work overnight rendering. I wrote it pretty quickly.... Haven't added many features just what I need to use it for. Feel free to download it, or request any features. *******NOTES ON USAGE******** 1. You MUST have the render queue set up for each project BEFORE you click the run button on the batch renderer. 2. All paths to the .aep projects, including the name of the .aep project, can NOT have spaces in them otherwise aerender.exe will fail. 3. The path for the script to run aerender.exe is the default path when installing After Effects. If for some reason aerender.exe cannot be found you may have to manually change this path. I can add the option to browse for the aerender.exe path though. *********** Let me know what you think! After Effects Batch Renderer.au3
-
Hey guys, I have a small program which has two different background pictures displayed at two different times. I have requireadmin turned on in the script, so it does the UAC prompt. Now for testing purposes i have the .au3, .exe, and both .jpgs all in the same folder. When running the .au3 the program finds the pictures and everything works as planned, when running the .exe the program cannot find the pictures. I believe this is due to the UAC, when running the .au3 it runs a verified script published by jonathan something. When i run the .exe it is an unknown program. Anything i am not seeing? Any way around this? Thanks, David
-
Pictures inside EXE's and hard to close EXE's
DavidStark replied to DavidStark's topic in AutoIt General Help and Support
Melba, Turns out there is a registry key that disables task manager, i think that i may just use this as it will be an easy work around. Her kids are not that old yet so hopefully they don't know other tricks -
Pictures inside EXE's and hard to close EXE's
DavidStark replied to DavidStark's topic in AutoIt General Help and Support
Mmmk, can you think of a different simple way to keep them from accessing it? Like is there anything in windows that puts restrictions on task manager? Awesome! I'm going to check that out. Thanks! David -
Hey guys, I'm new to these forums as a poster but have found a lot of help here before. I have two issues for you. I am building a small program for a friend that only allows her kids to have a certain amount of time on the computer before it locks them out, she then has to type in a password and it unlocks the computer, she can grant them more time or exit the program or whatever. So you understand how the lock works, all it does is throw up a GUI that is the exact size of the screen, it runs through a loop that continuously makes sure that the GUI is on top and active and waits for a password. I have the whole program written and working great but i realized one problem, if the kids know how to access task manager then they can just close desktoplock.exe and they won't get locked out! So I searched the forums for a way to make it hard to close an EXE that's running, but people were accusing other of writing viruses and such so i figured i'd make my own new topic. So the question is: Is there an easy way to make it so either they can't see it in task manager, or they need some kind of permission to run task manager, or they need permission to close it, something so the kids can't close the EXE before it locks them out. Can you guys think of any solutions? Second, the aforementioned desktop lock program has pictures as backgrounds in all of the UI windows. I would really like to be able to compile these pictures into the EXE, that way I can just paste the EXE in her computer and be done with it, instead of making sure the pictures are in the right directory and all that crap. It would just be really nice if there was an easy way to compile the EXE with pictures included. I realize that there is probably some desktop lock or child lock applications out there, but I am trying to learn how to create more complex GUI's and was talking to this friend and decided to take on a little project to help me learn. Thanks for the help. David