Page 1 of 1

ImageList_DragMove_() Refresh Problem

Posted: Sun Oct 01, 2006 7:02 pm
by Fluid Byte
This code works fine so far but leaves artifacts on the screen when you move an item arround. What am I missing here?

Code: Select all

Declare ListWndProc(hWnd.l,uMsg.l,wParam.l,lParam.l)

Macro LOWORD(lParam)
	lParam & $FFFF
EndMacro

Macro HIWORD(lParam)
	lParam >> 16
EndMacro

Global lpPrevWndFunc.l
Global bDragInit.b
Global bDragging.b
Global bDblClick.b

Global *hwndListview.l

OpenWindow(0,0,0,400,300,"untitled",#WS_OVERLAPPEDWINDOW | #WS_VISIBLE | 1)

CreateGadgetList(WindowID(0))

ListIconGadget(0,5,5,390,290,"Name",250)

lpPrevWndFunc = SetWindowLong_(GadgetID(0),#GWL_WNDPROC,@ListWndProc())

For i=1 To 5
	AddGadgetItem(0,-1,"ListView Item #" + Str(i),LoadIcon_(0,#IDI_APPLICATION+i))
Next

SetGadgetState(0,0) : SetActiveGadget(0)

HideWindow(0,0)

; ------------------------------------------------------------------------------------------------------
; MAIN LOOP
; ------------------------------------------------------------------------------------------------------

Repeat 
	EventID = WaitWindowEvent()
	
	If EventID = #PB_Event_Gadget
		Select EventGadget()
			Case 0
			If EventType() = #PB_EventType_LeftDoubleClick
				bDblClick = #True
			Else
				bDblClick = #False
			EndIf
		EndSelect
	EndIf

Until EventID = 16

; ------------------------------------------------------------------------------------------------------
; FUNCTIONS
; ------------------------------------------------------------------------------------------------------

Procedure ListWndProc(hWnd.l,uMsg.l,wParam.l,lParam.l) 
    Select uMsg
        Case #WM_LBUTTONDOWN	
        bDragInit = #True

        Case #WM_MOUSEMOVE   
        If bDragInit = #True And wParam = #MK_LBUTTON And bDblClick = #False
        	bDragInit = #False

        	himlTrack = SendMessage_(GadgetID(0),#LVM_GETIMAGELIST,#LVSIL_SMALL,0)
        	
        	lvi.LV_ITEM
        	lvi\mask = #LVIF_IMAGE
        	lvi\iItem = GetGadgetState(0)
        	
        	SendMessage_(hWnd,#LVM_GETITEM,0,lvi)
        	
        	ImageList_BeginDrag_(himlTrack,lvi\iImage,0,0)
        	ImageList_DragEnter_(hWnd,0,0)
        	
    		SetCapture_(hWnd)
    		    		    		
			GetClientRect_(hWnd,crc.RECT)	
			GetWindowRect_(hWnd,wrc.RECT)					
    		OffsetRect_(crc,wrc\left + 2,wrc\top + 2)

    		ClipCursor_(crc) : ShowCursor_(0)
    		
			bDragging = #True	       	   
        EndIf
        
		If bDragging = #True
	       	SetGadgetItemState(0,(HIWORD(lParam)-20)/17,#PB_ListIcon_Selected)
	       	
	       	ImageList_DragMove_(LOWORD(lParam),HIWORD(lParam))
		EndIf 	      
	        
		Case #WM_LBUTTONUP
		If bDragging = #True
	 		ImageList_EndDrag_()
	 		ImageList_DragLeave_(hwnd)
	 	
	 		ClipCursor_(0) : ShowCursor_(1)
	 		
	 		bDragging = #False	 		
		EndIf
    EndSelect
     
    ProcedureReturn CallWindowProc_(lpPrevWndFunc,hWnd,uMsg,wParam,lParam)
EndProcedure

Posted: Sun Oct 01, 2006 7:54 pm
by rsts
Hmm - no noticable artifacts here.

What should I be looking for?

cheers

Posted: Sun Oct 01, 2006 8:17 pm
by Fluid Byte
Well, it shouldn't look like this:

Image

It happens when you hover about other items while in drag mode.

Posted: Sun Oct 01, 2006 8:26 pm
by thamarok
Confirmed. I get the same artifacts, but can't tell where lies the problem. Perhaps the bug is in the API code, or in your code.

Maybe it wasn't that good of an idea to post it to Bug Reports.. Coding Questions would go fine?

Posted: Mon Oct 02, 2006 8:28 am
by Character
Yip. Same poblem on my computer.

Posted: Mon Oct 02, 2006 1:52 pm
by Fluid Byte
Just to clear this up. That there are artifacts is normal! The programmer has to take care of redrawing by his self. I can easily insert a call to InvalidateRect_() or RedrawWindow_() but using these will make the screen flicker. I just don't know how to smoothly refresh the window.

Posted: Sun Oct 22, 2006 4:15 pm
by Fluid Byte
No one?

I offer free beer an tities as a reward! :!:

[edit]
The offer is still valid!
[/edit]