News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

List View arrangement

Started by jckl, May 04, 2006, 08:45:18 AM

Previous topic - Next topic

jckl

I have a list view that i am using in report view. What iam tring to do is allow users to rearrange items by draging them up or down. I am completly sure how i would go about doing this so i am here asking for someone to point me in the right direction please. I am assuming i need to work with LVN_BEGINDRAG but like i said i am not sure how to go about this.

PBrennick

jckl,
As always, look it up on MSDN. I will give you the first helpful point (I am sure there will be others), make sure you are not using ListView_SortItems as it will defeat your (the user's) efforts.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

jckl

i have been looking on msdn and i am not using sorting of any kind.

PBrennick

Good, sometimes that flag can sneak in there when you are not looking.  Let us know how you make out.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

jckl

so far not so good.. i am still tring to figure out how i will make the item move up or down when someone is dragging it.

jckl

can anyone point me into what i need to look for in order to find the item number that my mouse is over and how i can move the current selected item to the position of the item i am hovering over?

jckl

ok so i finally found a few things that i am half way of getting to work after searching msdn for many many many hours..


invoke MakeDragList,hList
invoke RegisterWindowMessage, ADDR DLM


It seems to be the only way i can find to do this but i am worried i might run into a problem since i am using a listview in report view so i can use checkboxs. I dont know how or if you can use check boxs in a regular listbox. Anyway wish me luck as this has been about a 2 day task so far.

jckl

well looking into more of what i was thinking earlier on which i thought wouldnt have worked is i assume this could have been done with LVN_HOTTRACK. The thing is the definition for this on MSDN doesnt sound like i could is for this as it says it requires the extended style and when looking at that makes it sound like it is used to select an item when hovering over it. I didnt think that i could actually use it in this method.

So now i got ways i can play with this and see if i can get it to work how i want.

PBrennick

jckl,
I attached a project that I wrote for Ramon Sala a couple of years ago.  You can examine it to see what is done, how.  If you examine the following ...
ListBoxProc proc Uses Esi hCtl:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
;---------------------------------------
        LOCAL   IndexItem:DWORD
        LOCAL   Buffer[32]:BYTE
;
        .if uMsg == WM_LBUTTONDBLCLK
          jmp     DoIt
        .elseif uMsg == WM_CHAR
          .if wParam == 13
            jmp DoIt
          .endif
        .endif
        jmp     EndDo
DoIt:   invoke  SendMessage, hCtl, LB_GETCURSEL, 0, 0
        mov     IndexItem, eax
        invoke  SendMessage, hCtl, LB_GETTEXT, IndexItem, ADDR Buffer
        mov     eax, hList
        .if hCtl == eax
          lea     esi, rsCreateEditor
          invoke  lstrcmp, ADDR Buffer, chr$("rsCreateEditor")
          cmp     eax, 0
          je      found
          lea     esi, rsChangeControlColors
          invoke  lstrcmp, ADDR Buffer, chr$("rsChangeControlColors")
          cmp     eax, 0
          je      found

... this is just the first part of the ListBoxProc procedure.  The rest of the procedure gets repetitive and is nt need for what I want to show you.  As you can see, I am watching for the WM_LBUTTONDBLCLK message.  If this message shows up in the queue, then we know that the user has doubleclicked the mouse while hovering over an item in the listbox.  When that happens, execution jumps to the DoIt: label where we send the LB_GETCURSEL message to the listbox to get the index number.  We can then use that to send the LB_GETTEXT message to the listbox which will load the text of the item that was dubleclicked into the Buffer where you can use it in any way you choose.

Have fun,
Paul


[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

farrier

It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

jckl

ok i have got this working with the first method i came up with but i have one thing that i want to change. When i am dragging an item my mouse cursor changes to a circle with a line. I have tried to set my own cursor but it still replaces mine. Is there a way i can keep this from happening?

PBrennick

You need to load all your cursors as resources, first and then you can alter your program to use a different cursor at various times.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

jckl

I got that done and my app does change the cursor but then it get changed again to the cursor that indicates that it is not allowed drops. I am tring to figure out how to either keep the cursor from changing altogether or how to make it allow drops so that i do not get this cursor.

PBrennick

RU willing to post the project?  I can help you better that way.  When it comes to helping someone while working blind; I do a lousy job.  I wish I was better at it.  When I have the project, though, that is a different story.  I become VERY good.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

jckl

dont mind the bad coding habits or sloppy code in it as i am learning on my own. this is my entire project to this point. Also there is a lot of temp code and such in there that will be changed later.

http://www.joresources.com/other/lvdragdrop.zip