Jump to content
Tuts 4 You
Sign in to follow this  
LCF-AT

Listview issues

Recommended Posts

LCF-AT

Hi guys,

I have again some small questions about listview re-arragne issues.So in the past I changed my LV that only a seclected lines does switch the content with the hitted line during a drag.Now i wanted to change that again so that all selected lines gets inserted to hitted line below but here I have some trouble.

Example:

Some LV entrys.
----------------------------
123
456
789
101112
----------------------------

I want the selected lines insert to hitted line exactly like the selection was.So I got it working if I move the selected lines below to a line but above its exactly else.How can I do it to make it match like I did secleted the lines?I am just getting confused again with that entire insert / delete line process.

		invoke	SendMessage,LISTVIEW,LVM_HITTEST,0,addr lvhti
		.if (lvhti.iItem!=-1)
			@@:
			invoke	SendMessage,LISTVIEW,LVM_GETNEXTITEM,-1,LVIS_SELECTED ;or LVIS_FOCUSED
			mov	iSelected,eax     ; vom select
			mov	ebx,lvhti.iItem   ; vom Hit
			mov HIT, ebx
			.if iSelected!=-1 ;|| iSelected!=ebx
			    
			    mov iNewItem, ebx  ; HIT
			    
			    invoke  RtlZeroMemory,addr lvi2,sizeof LV_ITEM
			    invoke  RtlZeroMemory,addr lvi2A,sizeof LV_ITEM			    
			    invoke	SendMessage,LISTVIEW, LVM_GETHEADER, 0, 0
			    mov	hHeader,eax
			    invoke	SendMessage,eax,HDM_GETITEMCOUNT ,0,0
			    mov	iColumnCount,eax			    
			    
			    
			    xor ebx,ebx			    
                mov     lvi2.imask,LVIF_TEXT or LVIF_IMAGE
			    mov     lvi2.cchTextMax,MAX_PATH
			    lea     eax, szBuffer
			    mov     lvi2.pszText,eax			    
			    mov	    lvi2.iSubItem,ebx
			    mov eax, iSelected
			    mov	    lvi2.iItem,eax
			    invoke SendMessage,LISTVIEW,LVM_GETITEM,0,addr lvi2			    
			    
		    			    
			    
			    mov     lvi2.imask,LVIF_TEXT or LVIF_IMAGE
			    mov     lvi2.cchTextMax,MAX_PATH
			    lea     eax, szBuffer
			    mov     lvi2.pszText,eax
			    mov	    lvi2.iSubItem,ebx
			   
			   
			    mov edx, iNewItem
			    .if iSelected <= edx
			        inc edx
			        mov iNewItem, edx
			   .endif
			    mov eax, iNewItem ; hit
			    mov	    lvi2.iItem,eax
			    invoke SendMessage, LISTVIEW, LVM_INSERTITEM, 0, addr lvi2	
			    mov iRetv, eax
			    
                nop
                nop
                xor edx, edx
                mov edx, iSelected
                .if iRetv <= edx
                    inc edx
                    inc iSelected
                .endif
                
			.if iRetv > edx
			    mov edx, iRetv
				dec edx
				mov Highlight, edx
			.elseif
                mov edx, iRetv               
				mov Highlight, edx
			.endif
 

                
                
                xor ebx,ebx
                .while (ebx<iColumnCount)
                mov     lvi2.imask,LVIF_TEXT or LVIF_IMAGE
			    mov     lvi2.cchTextMax,MAX_PATH
			    lea     eax, szBuffer
			    mov     lvi2.pszText,eax			    
			    mov	    lvi2.iSubItem,ebx
			    mov	    lvi2.iItem,0
			    invoke SendMessage, LISTVIEW, LVM_GETITEMTEXT, iSelected, addr lvi2
			    invoke SendMessage, LISTVIEW, LVM_SETITEMTEXT, iRetv, addr lvi2
			    inc	ebx
			    .endw
			    
			    invoke SendMessage, LISTVIEW, LVM_DELETEITEM, iSelected, 0
                jmp @B                          

A another problem I have is how to set the new selected highlights of the inserted items.So I cant do this on fly (endless loop).Has anyone a idea how to handle that part to have all moved items selected again after the drag?Maybe you can help again a little to make that parts working correctly.

Thanks

Share this post


Link to post
Share on other sites
LCF-AT

Hi guys,

I wrote a code to handle that issue more or less.I got it not finished perfect but better than nothing so far.

Now I wanted to handle another older problem I didnt fixed yet about dragging in a listview.My goal is it to show all selected lines during a drag with the listview image & text too.On internet I found a small code how it should work and after long testing I got it work so far to see all selected line images during a drag but the problem is the text now of the entrys so this is shown in white color (almost not visible) and also just the text from first entry / line and not the complete text line.In the past we talked about that text issue without to find a solution.

Now I would like to ask whether and how its possible to add the text manually after the image during a drag since windows 7 dosent show it anymore as on XP?The code I used for a multible image drag I got from here..

https://forum.powerbasic.com/forum/user-to-user-discussions/source-code/23917-multiple-drag-images-for-listview

...and if I do it so then I get this results to see....

LV1.png.2c1fac5261402ae7528bc3e0f58e7782.png

....you see its just black shadow stylish.After checking the code I found the problem at API ImageList_Draw using ILD_MASK flag = result above.If I change the flag to 0 then its transparent....

LV2.png.bea6d3a876f6e3c83fbe338bbb3aaa2a.png

.....but you also cant see the text which is white and only numbers are too see.At the API ImageList_Create I used ILC_COLOR32 flag to show icons as above and like they should also shown.If I change the flag to lower ILC_COLOR24 then I get black shadows and icons are looking bad....

LV3.png.2f28bea067b980d8a452c679df12cc17.png

...dosent look like I want.Now I just wanna ask how to do it right?I wanna have transparent icons in my LV and also during a drag + whole text of entire lines (icon 1     some text 1) without a shadow + using a visible text color and not same as LV background is.Maybe anyone can help again with that issues and or checking my code for that.I do attach the code files below (WinASM / MASM).

PS: If you drag a item and keep left mouse pressed down and you do scroll up & down and move the mouse around then you can see some paint issues.Not sure how to prevent this at the moment.Do you know?By the way,the code is just a example to check that drag issues so dont wonder if it looks a bit messy. :)

Thank you

DragDrop_listview_items3.rar

Share this post


Link to post
Share on other sites
LCF-AT

Hi again,

one good news.After long testing & checking I got it working to make a re-arange as I wanted but it was really a bad thing to code that (no idea why I got such problems with that).First I need to read all selected lines above the hittet line and insert them at hitted line + 1 (next line after hittet) and then I need to read all selected lines after hittet line from last selected to above till hittet line and insert them directly at hittet line + also deleting the selected lines of course.Its very confusing (for me of course) but now it works as you can see at the gif animation below. :) For setting the re-selections on the moved items I did used first number row and did set on all moved lines a * inside which I do search at the end again to re-select them.No good solution of course but at the moment I have no better clue how to handle that but its no big problem so normaly I always use a number counter row in my listviews which I then update each time after any item move.

Video_2018-01-13_193934.gif.e141c9e055f31d3a5672a200278c5a7b.gif

Only problem I still have is that icon / image / text dragging.No idea how to set the text after the image during a drag which is also visible.Maybe you have any ideas how to make that.

A other problem was that paint issue during a drag + using the mousewheel.Only way to prevent that was to send a WM_MOUSEMOVE message after WM_MOUSEWHEEL but also in this case I dont see the drag image/s anymore just after a wheel and only get it back after another mouse move.Its also no good solution of course but maybe you have also a hint for that too.

greetz

Share this post


Link to post
Share on other sites
LCF-AT

Hi guys,

still fighting with that smudge painting issues during a dragging.It looks pretty bad and I dont find a way to do any paint update without to get any flickering. :(

Video_2018-01-16_152934.gif.bbd4bb39e2d9fc3d3bcc23e92863ad8d.gif

So what can I do to prevent that bad smudge issues if it scrolls up & down?Just wanna show the icons on same way if I not scroll.Has anyone of you any listview / drag example app in any language where it works correctly without painting issues or flickering during dragging?

greetz

Share this post


Link to post
Share on other sites
LCF-AT

Hi again,

short another question.I would like to create a autoscrolling during a drag starting from the last / prelast hittet line below or top.On MSDN I find a message called LVM_GETCOUNTPERPAGE to get the result of all visible items at the moment.Now I have that result and the hittet item.The question is now how to find out whether the hittet line is the last / prelast from below or top?

1
2
3
---------- middle point
4
5 <--- selected / drag start down = should start to scroll down because its prelast visible line
6
------------------------- above visible area
7
8
9
10
....

How can I calc this out now?I have the result of 6 from LVM_ISITEMVISIBLE and result of hittet item index of 4.

greetz

Share this post


Link to post
Share on other sites
LCF-AT

Hi again,

found a listview with drag / drop example on this site too.

https://www.developer.com/net/cplus/article.php/628271/A-Drag-and-Drop-List-Control.htm

But also this example file you can download there does also flicker like hell and if you scroll during a drag then you see the same problems like I post above.Smudge all over also during mousemove and drag image not to see anymore during a mousewheel on drag.This example file is in cpp so maybe anyone of you can check that and find out how to prevent this stupid smudge / flicker trash.I cant beleive that there is no solution out there for that problem.Is nobody around who has some experiences with listviews with drag drop etc?

greetz

Share this post


Link to post
Share on other sites
LCF-AT

Hi,

still found no solution.At the moment I use now ImageList_DragShowNolock True & false to show drag image during mousemove and not during any scrolling or key scrollers etc.Looks so now...

Video_2018-01-18_204635.gif.e9e4495012e5c5dc60bd16cc7ca9a5ea.gif

...not perfect as I wanted but better than before with that whole smudge & flickering issues.

greetz

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×