Jump to content
Tuts 4 You

Listview questions


LCF-AT

Recommended Posts

Posted

Hi again,

I made a listview with seven columns and used LVS_EX_GRIDLINES.I also did subclass the listview.If I now add much entrys then I get a VScrollbar to see which I can move.If I now press on the bar free parts (not slider itself) then the slider jumps up or down etc and the problem now I get is that the GRIDLINES are doube to see in each line = the entrys itself are crossed out and its looks very bad and in this case I have to do any refresh.In my subclass I added now WM_VSCROLL message and added..

.if uMsg == WM_VSCROLL 
invoke InvalidateRect,hWnd,NULL ,FALSE
invoke UpdateWindow,hWnd

...and the listview gets updated and the representation looks good again BUT only the for columns  I added.So in this case I added 7 columns and the last one number 8 will not updated and does still show crossed out GRIDLINES.Thats one problem.I also could change the flag for InvalidateRect to TRUE then all columns getting updated also the 8 one but then I get a lot of flickering if I do scroll the bar with mouse up / down.The question is how to fix that problem?How to get the last column which is not from me also updated without flickering.

greetz

Posted (edited)

Any Executable or code to test it?

Edited by ragdog
Posted

Hi raggy,

ok I made a quick example code for testing.Just check this out and try to remove the flicker stuff on moving / scrolling + updating the grindlines so that nothing gets overlapped etc you know.Thanks.

Listview test.rar

Posted

Try It i hope it help.

		invoke CreateWindowEx,WS_EX_CLIENTEDGE,chr$("SysListView32"),NULL,WS_CHILD or LVS_REPORT or WS_VISIBLE or  WS_TABSTOP or LVS_SHOWSELALWAYS \
		                                               ,50,50,50,50,hWnd,0,hInstance,NULL        
       	 mov	hListView,eax		
		invoke	SendMessage,hListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES or  LVS_EX_DOUBLEBUFFER


;remove this lines <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		;invoke SetWindowLong,hListView,GWL_WNDPROC, addr LISTVIEWPROC
		;mov OLDLISTVIEWPROC, eax
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<		
		mov	lvc.imask,LVCF_TEXT+LVCF_WIDTH
		mov	lvc.pszText,offset Header1
		mov	lvc.lx,100	
		invoke	SendMessage,hListView, LVM_INSERTCOLUMN,0,addr lvc
		or	lvc.imask,LVCF_FMT
		mov	lvc.fmt,LVCFMT_LEFT
		mov	lvc.pszText,offset Header2
		mov	lvc.lx,100
		invoke	SendMessage,hListView, LVM_INSERTCOLUMN, 1 ,addr lvc
		or	lvc.imask,LVCF_FMT
		mov	lvc.fmt,LVCFMT_LEFT
		mov	lvc.pszText,offset Header3
		mov	lvc.lx,100
		invoke	SendMessage,hListView, LVM_INSERTCOLUMN, 2 ,addr lvc
		
		
;remove this lines<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;		mov    eax, LVS_EX_FULLROWSELECT or LVS_EX_HEADERDRAGDROP or LVS_EX_GRIDLINES
;		invoke   SendMessage, hListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, eax	
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

  • 4 weeks later...
Posted

Hi again,

short question.So yesterday I found a problem running my Listviews in Win 7 I did created in the past on XP.So there is any drag & drop problem.Now if I select any line in LV and move it to other position then I only see the image and no text anymore.Next on the image I can see the place holder for the text which is just a white square of the first entry.So I do remember on XP was working all fine and also all was to see I mean all text entrys,If I got for example 3 entrys with text on one row then the entire text was shown on draging etc.Strange problem again.I made a quick example for testing to see it what I mean and maybe you can find out what the problem could be and why its not working same as on XP.A solution to fix this issue for Win 7 would be nice.

Thank you

Listview test2.rar

Posted

Hi again,

and did somebody test?Seems to be any Win 7 issue.I also checked the Listview with drag & drop made by member simple and there I get same trouble.Only see a white square.

MasmGui.rar
https://forum.tuts4you.com/topic/36791-how-to-control-cmd-console/?do=findComment&comment=172838

Maybe someone can test this file / code too maybe also simple itself.

greetz

Posted

Hi again,

one more question.Now I tried to use a alternativ method to show the text during drag & drop and used TextOut API on MOUSEMOVE MSG but the problem in that case is that the text will painted like in a paint app without to disapear so long till I release it.I also tried to use InvalidateRect what works but with that the Text does flicker like hell.Does anyone know a solution for this problem?So it happens if I use CreateFont + SelectObject.

greetz

Posted

Hi again,

so I have test it again just using TextOut API on mousemove MSG in the LISTVIEW and its just smuge the text inside the LV so long till I release the mouse.If I use InvalidateRect then it does flickering to much.So what can I do now in that case to prevent this smudge problem so I dont wanna paint anything you know. :)

.elseif	uMsg == WM_MOUSEMOVE    
.if (bDragging == TRUE)
invoke GetDC,hWnd
mov DCHANDLE, eax
invoke SetBkMode,   DCHANDLE,TRANSPARENT
invoke SetBkColor,  DCHANDLE,TRANSPARENT
invoke SetTextColor,DCHANDLE,Red
invoke TextOut,DCHANDLE,.....

Come on guys I need some help. :)

Thank you

Posted (edited)

Hey LCF-AT,

have you considered trying to use double buffing?
I've made a small code snipped which works so far using this guide (Flicker-free Drawing)

Spoiler

The variables I've defined:


hDragging			db ?
mPoint				POINT <>
hdc					DD ?
hdcMem				DD ?
hbmMem				DD ?
hOld				DD ?
ps					PAINTSTRUCT <>
r					RECT <>
win_w				DD ?
win_h				DD ?

And the code snipped from the WndProc


.elseif eax == WM_ERASEBKGND
		mov eax, 1
		ret
	.elseif eax==WM_MOUSEMOVE
		.if hDragging == TRUE
			invoke InvalidateRect, hWnd, 0, FALSE
			invoke BeginPaint, hWnd, addr ps
			mov hdc, eax
			
			invoke GetWindowRect, hWnd, addr r
			mov ebx, r.right
			sub ebx, r.left
			mov win_w, ebx
			mov ebx, r.bottom
			sub ebx, r.top
			mov win_h, ebx
			
			invoke CreateCompatibleDC, hdc
			mov hdcMem, eax
			invoke CreateCompatibleBitmap, hdc, win_w, win_h
			mov hbmMem, eax
			
			invoke SelectObject, hdcMem, hbmMem
			mov hOld, eax
			
			invoke SetBkMode, hdcMem, TRANSPARENT
			invoke SetTextColor, hdcMem, 0FF0000h
			invoke GetCursorPos, addr mPoint
			invoke ScreenToClient, hWnd, addr mPoint
			invoke TextOut, hdcMem, mPoint.x, mPoint.y, addr ClassName, 8 ;Replace ClassName with your text.
			
			invoke BitBlt, hdc, 0, 0, win_w, win_h, hdcMem, 0, 0, SRCCOPY
			
			invoke SelectObject, hdcMem, hOld
			invoke DeleteObject, hbmMem
			invoke DeleteDC, hdcMem
			
			invoke EndPaint, hWnd, addr ps
			
		.endif
	.elseif eax == WM_LBUTTONDOWN
		mov hDragging, TRUE
		
	.elseif eax == WM_LBUTTONUP
		mov hDragging, FALSE

 

 

Regards,

Castor
 

Edited by Castor
  • Like 1
Posted

Tach Castor,

God bless somebody is talking to me. :) First thank you for posting some code for testing etc.So I have test it and it dosent work so the Listview gets filled with black color and I also see flickering on the colomns if I move the mouse during dragging.So just download my 2 examples above and there you can see I do subclass my Listview.If possible then check my code and use it in WinASM / MASM if you have and try to edit them to get anything working good and send the results back to on this topic.

One more thing.Normaly I would like to use the normal dragging code you can find in Listview test2 I did attached above but isnt working same on Win 7 like on XP.Yesterday I also found out that there is a problem using ImageList_Create with paramter ILC_COLOR32 and using icons.If you change ILC_COLOR32 to lower value ILC_COLOR24 etc then you will get a black transparent background if you drag any listview entry.On XP the background was transparent and text color was same as in LV and I also did see all entrys of all comlumn line entrys during dragging.My maingoal is it to get it working like on XP again or if this is not possible then I would switch to Textout but here I get the smudge problem if I dont use InvalidateRect but with this API I get this flickering problem what also sucks.

No idea how to fix this problems so I tried all what came in my mind and I am tired to google anymore to find any solution for this problem. :( If you check for example the Windows Explorer then you can see also no fickering on scrolling or draging.So somehow it must work but how is the question.

Remember that I wanna drag items in a Listview only and its subclassed.Not outside of it etc.Maybe you can check this again or build something what does work later.Thanks again so far Castor.

greetz

Posted

Hello LCF-AT,

I have tested both Listview test.rar and Listview test2.rar and here is the status:

Listview test.rar

  • Windows XP Service Pack 3 - scroll bug happens (see the attached image).
  • Windows 7 Ultimate 64 bits - the problem does not happen.
  • Windows 8.1 Pro - the problem does not happen.
  • Windows 10 - the problem does not happen.

Listview test2.rar

  • Windows XP Service Pack 3 - drag and drop shows only the image, not text (see the attached image).
  • Windows 7 Ultimate 64 bits - same as Windows XP.
  • Windows 8.1 Pro - same as Windows XP.
  • Windows 10 - same as Windows XP.

As for the solution, I have no clue since the software behaves different in each OS.

Regards,

James

 

listviewbug.JPG

listviewbug2.jpg

  • Like 1
Posted (edited)

Moin ;)

So first of all I had to download WinASM since I'm using RADAsm for coding with Assembler but that was not problem I just have to get a bit used to it.

So after researching a bit I've figured out what the problem is:
Since the code I've posted is creating a Bitmap and blitting that onto the DC there will be no transparency. The solution is to create a "Transparent" Bitmap which filters out a specific color (I would use Magenta or Fuchsia).

So since you want to create a text which is following the cursor have you considered creating something like a Tooltip?? MSDN even made an article about that.

The transparent color thing is also a problem I've discovered after researching a bit.Since I don't exactly know what the ILC_COLOR24 (24 Bit colors) does, is there a specific reason you use that or why don't you stick to the 32Bit? (Just an assumption: COLOR32 uses 32 Bit for a color which should be RGBA where the A = Alpha Key, COLOR24 uses 24Bit where the Alpha Key isn't present could that be a reason?)

 

Edited by Castor
  • Like 1
Posted

Hi guys,

thanks for your answers so far.Also for testing on lot diffrent systems. :) Yes thats all really strange that it will work only for some or not so this sucks like hell.Scroll problems / drag problem etc so why is that so.Just can shake my head.Strange that you cant see text on XP SP3 what I also have and there its to see.Hmm.Maybe any visual settings thing etc.

Ok listen Castor.It would be very nice if you maybe could create any example files / sources with a subclassed listview + draging function what does show icon / image with entire text of one line (all comumns etc you know) if I drag.Just need any working example codes to see how I have to write the code right which I then can also use in future without to get any trouble anymore like now.Would be cool if you could build something.Good draging and no flickering etc.So I used ILC_COLOR32 for the icon I used and then the background during a drag is transparent.So on XP I got transparent and also see entire text next the icon....

Icon  Test00       Test         Test

....maybe you can do something oder ich werde noch verrückt mit der ganzen Scheiße hier! :) Oh so tooltip is not so my thing so if I remember right then there I got also trouble with that on diffrent systems etc.Not so sure anymore but the main thing is that I dont wanna check each time what I did code on other systems whether its working there correctly like dragging etc so thats just uhhhm big boring cheese you know.

Thanks again guys.

Posted

Hi guys,

does anyone know whether its possible to make a screenshot of the selected entire line in a listview and to show this during a drag?You know like in browser if you select a tab and move it.

PS: A little bit more help would be welcome guys.Where are all the coders if you need them.

Thanks

Posted

Hey!
I will code an example for you but I am currently really busy because of my university exams. I'll try and finish it until friday or the end of the weekend.

I will do my best to implement 3 ideas I have:

- ToolTips

- Drawing with transparent Bitmaps (But not sure If I can do that)

- Fake-ToolTip using a Label or creating an extra Dialog for it.

 

About the screenshot idea: Could be possible yeah but anything overlapping it or resized columns would be shown incorrectly.
 

 

Posted (edited)
12 minutes ago, Castor said:

Hey!
I will code an example for you but I am currently really busy because of my university exams. I'll try and finish it until friday or the end of the weekend.

I will do my best to implement 3 ideas I have:

- ToolTips

- Drawing with transparent Bitmaps (But not sure If I can do that)

- Fake-ToolTip using a Label or creating an extra Dialog for it.

 

About the screenshot idea: Could be possible yeah but anything overlapping it or resized columns would be shown incorrectly.
 

 

These solutions are too dirty i guess...

Mainly because scroll will be not posible.

Edited by Reasen
Posted

Why wouldn't it be possible to scroll? Am I missing out something?

Posted
57 minutes ago, Castor said:

Why wouldn't it be possible to scroll? Am I missing out something?

If i undertand correctly you want to make a Fake-ListView, so you will need to make the function for scroll into the list-objects from 0 also.

Posted

No the ListView only gets subclassed, I just create fake ToolTips.

Posted

Hi again,

so today I did test my Listview2 on XP and here two pics I made..

32.png

16.png

So if I change the color sheme on Win 7 from 32 bit to 16 bit then I get not same results like on XP.But its also strange that you get to see all text entrys on XP 16 bit color and not also with 32 bit color.Has anyone a idea why this happens?

PS: Ok sounds good Castor,just try to get anything working what I could use later for the dragging operation.Thanks again.

Yesterday I found some code on net which I used on mousemove in my LV subclass proto....

	.elseif	uMsg == WM_MOUSEMOVE    
		.if (bDragging == TRUE)
			LOWORD lParam
			mov lvhti.pt.x,eax 
			HIWORD lParam
			mov lvhti.pt.y,eax	
		    
		    invoke GetDC,hWnd
		    mov wDC,eax
		    invoke CreateCompatibleBitmap,wDC,30,30
		    mov hbmImage,eax
		    invoke ReleaseDC,hWnd_main,wDC
		    invoke GetDC,hWnd
		    mov wDC,eax
		    invoke CreateCompatibleDC,wDC
		    mov bdc,eax
		    invoke SelectObject,bdc,hbmImage	
		    mov bOld,eax	    
		    invoke BitBlt,wDC,lvhti.pt.x,lvhti.pt.y,30,30,bdc,0,0,SRCCOPY
		    invoke SelectObject,bdc, bOld
		    invoke DeleteDC,bdc
		    invoke ReleaseDC,hWnd,wDC
		    invoke DeleteObject,hbmImage		    
		    ret

.....now it does paint a square but smudges everything...

121212.png

...and looks so.If I use InvalidateRect on mousemove in subclass then it does flickering again like hell.

greetz

Posted

I think I wouldn't rely on drawing rather than using a Label or another Dialog to do the job. Would be even easier I think because you could easily set the text and change the position.

I've downloaded some random D&D-Demo Code and tried to drag the entries (which works) but 1) It flickers like hell when moving the cursor 2) sometimes when I stop moving my mouse the text will partial disappear behind the listview. So I think it's a Problem of windows rather of programming. (Using W10 x64)

Posted

Hi again,

as I said I just need something whats working (icon + all text entrys would be best if possible).Transparent text of all entrys on a line would be also ok if it dosent smudge and if I can set the draging text to half visible / transparent etc you know.Also dont wanna have the flicker issue of the text itself if I drag it like with using invalidateRect so that just bad.

So the flicker issue of Listview itself can be disabled by using LVS_EX_DOUBLEBUFFER so this works under Win 7.Teddy told this before on other topic here but there I did still used XP and wasnt working as now on Win 7.

Other idea.So I see the icon and if I dont use ILC_COLOR32 then I also see the first text entry in white color and a black transparent background.So I could also use this maybe also if its not this what I want but the problem in that case is that I only see the first text entry (line counter) and not all.If I would see all then it would also be better but no idea how to do this.Thats really pitty (Platsch). :)

greetz

Posted

YOu have only a problem with your imagelist you can test it change your imagelist to

invoke    ImageList_Create, 16, 16, ILC_MASK or ILC_COLOR24, 10,0

 

Raggy

Posted

Just read all posts about that issue on this topic.Just to switch to ILC_COLOR24 is not enough and also not same and brings trouble with icon representation.Just test it.

greetz

Posted

Hi guys,

I have just one question (dont wanna create new topic).Can anyone tell me how to make a app / dialog transparent?So I remember there was any Olly plugin I think where you got a fader to make Olly transparent from 0 - 100 % or so.Just wanna know how to do this to make my app 50 % transparent etc you know.

Thanks

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
×
×
  • Create New...