News:

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

rookie problem with a listview

Started by dicky96, August 17, 2006, 09:14:08 PM

Previous topic - Next topic

dicky96

Not done a list view control before - and seem to be having a few teething problems........
               

                .data
           LOCAL lvc:LV_COLUMN
                Lv_Servername_hdr db 'Server Name',0


                .code
      invoke GetDlgItem,hWnd,IDC_LST_SERVERS
      mov hLstServers,eax
      mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
      mov lvc.pszText,offset Lv_Servername_hdr
      mov lvc.lx,320
      invoke SendMessage,hLstServers,LVM_INSERTCOLUMN,0,addr lvc      


Should that cause a column to appear in my list view (created using resource editor in RadAsm)  or do I need to do some other stuff first to initialise the listview control? Cos it ain't happenin'

On an aside - if I wanted to declare the lvc structure as a global variable in .data? section rather than a local one (no particular reason) what'e the correct syntax cos I can't seem to get it right.

Lastly is it just me or did everyone learning win32asm spend more time struggling with the API than they did writing the algorithms/code that do the real work in thier apps??  Cos that's where I seem to be  ::)

dicky

arafel

You also need to set the lvc.iSubItem index.

To define a global structure do: lvc LV_COLUMN <?>

Jackal

When inserting a column i dont believe you need do worry about subitems.. By putting LOCAL lvc:LV_COLUMN in the .data section looks to me like it might be the problem. Here is a function i use in one of my programs that uses a listview.



InsertColumn proc
    LOCAL lvc:LV_COLUMN

    mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
    mov lvc.pszText,offset Heading1
    mov lvc.lx,155
    invoke SendMessage,hList, LVM_INSERTCOLUMN, 0, addr lvc
    or lvc.imask,LVCF_TEXT+LVCF_FMT
    mov lvc.fmt,LVCFMT_RIGHT
    mov lvc.pszText,offset Heading2
    mov lvc.lx,75
    invoke SendMessage,hList, LVM_INSERTCOLUMN, 1 ,addr lvc
    or lvc.imask,LVCF_TEXT+LVCF_FMT
    mov lvc.fmt,LVCFMT_RIGHT
    mov lvc.pszText,offset Heading4
    mov lvc.lx,150
    invoke SendMessage,hList, LVM_INSERTCOLUMN, 2 ,addr lvc
    or lvc.imask,LVCF_TEXT+LVCF_FMT
    mov lvc.fmt,LVCFMT_RIGHT
    mov lvc.pszText,offset Heading3
    mov lvc.lx,90
    invoke SendMessage,hList, LVM_INSERTCOLUMN, 3 ,addr lvc
    ret
InsertColumn endp

ToutEnMasm

Hello,
The code seem a bit short to create a listview and see if it work.


dicky96

Ooops sorry  Ididn't put LOCAL lvc in the .data? section. it is at the start of my dlg procedure.   That's just as mistype here. sorry

One of the things I would like to know is how I should properly declare the lvc structure in the .data section asa global variable (or is that a global structure) if I wanted.

@toutenmasm
My code doesn't create the listview, I just dragged on onto the dialog screen in RadAsm resource editor, then get the handle to the control with GetDlgItem in my WM_INITDIALOG processing, then tried to add a column.  The listview just appears as an empty box at the moment.

I thought overnight that maybe I need to send a message to the control telling it to use report view, before I try to add the column, so I'm off to try that.............

ToutEnMasm


in this case you have just to define the columns titles and sizes without forgot this line

                       ToutEnMasm


mov     eax, LVS_EX_FULLROWSELECT or LVS_EX_HEADERDRAGDROP or\
LVS_EX_GRIDLINES
INVOKE     SendMessage, retour, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, eax


ToutEnMasm


i have just seen that the imask member is wrong for creating the columns


mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
mov lvc.pszText,addr title
mov lvc.lx,         ;the lenght of the title


Verify also that the other members of the structure in stack are not initialised randomly.
                                              ToutEnMasm

Jackal

One other thing that you will want to make sure of is that the listview is in report view other than the others. If it is not in report view i dont believe you will see any headers. Also arafel posted how to define it under .data?

Quote from: arafel on August 18, 2006, 03:44:54 AM
You also need to set the lvc.iSubItem index.

To define a global structure do: lvc LV_COLUMN <?>

dicky96

still not got it working yet... but working on it ;)   

this just causeed the empty box (which should be a list view) to greay out and not appear

mov     eax, LVS_EX_FULLROWSELECT or LVS_EX_HEADERDRAGDROP or\
LVS_EX_GRIDLINES
INVOKE     SendMessage, handle_to_listvcew, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, eax

@jackel
sorry missed that bit from arafel - perhaps watching porn does make you blind after all  :bdg  :bdg

@tout-en-masm
regards       mov lvc.lx,         ;the lenght of the title

all the documentation I can find says this is the width in pixels, not characters, if that is what you meant - i kinda guessed for a 11 char title 320 pixlels would do it, with room to spare

anyway still trying to get this thing working - thanks for the input so far

Jackal

put together an example of source code and attach it. Ill download it and see if i cant see what is wrong. You can also use the following line to make sure it is in report mode.


Invoke SetWindowLong, hLstServers, GWL_STYLE, LVS_REPORT or WS_CHILD or WS_VISIBLE


dicky96

OK I fixed it.   The reason it was not working is too embarrasing to post  :red

ToutEnMasm


Don't be embarrassed to explain why he didn't work.
Some other can be help with this.

For the lvs.lx , yes the size is in pixels.You have to get the internal size of the mother windows (in pixels with getclientrect) and divide this space for each column.
My prefered method for this is using % to save the look for each screen resolution.
                                                     ToutEnmasm

dicky96

Ahh well there was nothing wrong with the code - it did not work cos I thought it was a listview control I had put on the dialog window with the resource editor - but in fact it was a listbox control :eek   So I guess it just couldn't understand the messages I was sending to it and greyed itself out.

I now has a listview control, and the columns look just fine  :U