ImageList_DragMove_() Refresh Problem

Windows specific forum
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

ImageList_DragMove_() Refresh Problem

Post 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
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Hmm - no noticable artifacts here.

What should I be looking for?

cheers
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Well, it shouldn't look like this:

Image

It happens when you hover about other items while in drag mode.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
thamarok
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 06, 2006 1:37 pm

Post 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?
Character
Enthusiast
Enthusiast
Posts: 337
Joined: Mon Aug 07, 2006 3:51 pm
Location: Netherlands

Post by Character »

Yip. Same poblem on my computer.
Cessante causa cessat effectus
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

No one?

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

[edit]
The offer is still valid!
[/edit]
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Post Reply