Danyfirex Posted September 14, 2014 Posted September 14, 2014 Hi. can some GDI man show me the best way to draw over a listview control. saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Luigi Posted September 14, 2014 Posted September 14, 2014 (edited) I want see that it too... Have some ideas, not beauty yet... Iknow... that is not you want... but, it is a simple idea... put brain to work. expandcollapse popup#include-once #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> Opt('GUIOnEventMode', 1) Opt('GUIEventOptions', 1) Opt('ExpandVarStrings', 1) Opt('MustDeclareVars', 1) Global $ACTIVE = True Global $iLine = 0, $iCol, $iRev = 1 Global $hGui[2], $aGuiSize[2] = [800, 600], $sGuiTitle = 'Título' Global $hGraphic, $hPen, $hBitmap, $hBackbuffer, $aGraphics[4] = [10, 10, 400, 300] Global $hButton $hGui[0] = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1, Default, Default) GUISetOnEvent($GUI_EVENT_CLOSE, '_quit') $hButton = GUICtrlCreateButton('botão', 22, 22, 80, 26) GUICtrlSetOnEvent($hButton, '_button') GUISetState(@SW_SHOWNORMAL, $hGui[0]) $hGui[1] = GUICreate(0, 400, 300, 10, 10, $WS_CHILD, Default, $hGui[0]) GUISetState(@SW_SHOWNORMAL, $hGui[1]) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui[1]) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($aGraphics[2], $aGraphics[3], $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsClear($hBackbuffer) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) AdlibRegister("line", 25) While Sleep(10) ACTIVE() WEnd Func _button() ConsoleWrite('botão' & @LF) EndFunc ;==>_button Func ACTIVE() If WinActive($hGui[0]) And Not $ACTIVE Then _update() $ACTIVE = True ElseIf Not WinActive($hGui) And $ACTIVE Then $ACTIVE = False EndIf EndFunc ;==>ACTIVE Func _quit() _exit() EndFunc ;==>_quit Func _exit($input = 0) ; end functions... _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGui[0]) Exit EndFunc ;==>_exit Func line() $iLine += 10 $iCol += 10 * $iRev If $iCol > 370 Then $iRev *= -1 If $iCol < 0 Then $iRev *= -1 If $iLine > 300 Then $iLine = 0 EndFunc ;==>line Func _update() _GDIPlus_GraphicsClear($hBackbuffer, 0xFFD4D0C8);D4D0C8 _box($hBackbuffer, $iCol, 50, 30, 30) _GDIPlus_GraphicsDrawLine($hBackbuffer, 0, $iLine, 400, $iLine, $hPen) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, $aGraphics[0], $aGraphics[1], $aGraphics[2], $aGraphics[3]) EndFunc ;==>_update Func _box($hToGraphic, $xx, $yy, $ll, $aa, $color = 0xFF000000) ; _box2 Local $aBox[5][2] $aBox[0][0] = 4 $aBox[1][0] = $xx $aBox[1][1] = $yy $aBox[2][0] = $xx + $ll - 1 $aBox[2][1] = $yy $aBox[3][0] = $xx + $ll - 1 $aBox[3][1] = $yy + $aa - 1 $aBox[4][0] = $xx $aBox[4][1] = $yy + $aa - 1 If $color Then _GDIPlus_PenSetColor($hPen, $color) _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox, $hPen) Else _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox) EndIf EndFunc ;==>_box Edited September 14, 2014 by Detefon Visit my repository
Solution Danyfirex Posted September 14, 2014 Author Solution Posted September 14, 2014 (edited) Well this is I got. Need to be improve. But I hope it helps someone. expandcollapse popup#include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Global $iColor = 0xFF40BD Global $Grosor = 1 Global $Gui = GUICreate("Test", 450, 400) GUISetBkColor(0xFFFFFF) Global $hListView = GUICtrlCreateListView("Prueba|Prueba|Prueba|Prueba", 25, 25, 400, 300) GUICtrlSetBkColor(-1,0xFFFFFF) Global $oBoton = GUICtrlCreateButton("Agregar", 180, 350, 80, 30) _GUICtrlListView_SetColumnWidth($hListView, 0, 98) _GUICtrlListView_SetColumnWidth($hListView, 1, 98) _GUICtrlListView_SetColumnWidth($hListView, 2, 98) _GUICtrlListView_SetColumnWidth($hListView, 3, 98) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $oBoton for $i= 1 to 30 _GUICtrlListView_AddItem($hListView, "Hi World") Next EndSwitch Sleep(10) WEnd Exit Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case ControlGetHandle("", "", $hListView) Switch $iCode Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any item-related drawing operations Case $CDDS_ITEMPREPAINT Local $hDC = DllStructGetData($tNMLVCUSTOMDRAW, "HDC") Local $hPen = _WinAPI_CreatePen($PS_SOLID, $Grosor, $iColor) Local $o_Orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, 0, DllStructGetData($tNMLVCUSTOMDRAW, "top") - 1, DllStructGetData($tNMLVCUSTOMDRAW, "Right"), DllStructGetData($tNMLVCUSTOMDRAW, "top") - 1); horizontal left _WinAPI_DeleteObject($hPen) Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) Local $hDC = DllStructGetData($tNMLVCUSTOMDRAW, "HDC") Local $hPen = _WinAPI_CreatePen($PS_SOLID, $Grosor, $iColor) Local $iX = DllStructGetData($tNMLVCUSTOMDRAW, "left") Local $iY = DllStructGetData($tNMLVCUSTOMDRAW, "top") Local $iX1 = DllStructGetData($tNMLVCUSTOMDRAW, "right") Local $iY1 = DllStructGetData($tNMLVCUSTOMDRAW, "Bottom") $o_Orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $iX - 1, $iY, $iX - 1, $iY1) _WinAPI_LineTo($hDC, $iY1, $iY1) _WinAPI_DeleteObject($hPen) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Saludos Edited September 14, 2014 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now