News:

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

Checkbox in LIstview

Started by newAsm, February 14, 2008, 01:07:49 AM

Previous topic - Next topic

newAsm

Hi,

I want to put a checkbox into the listview control and I have checked the Win32.hlp help and there is no information on how to do it in assembly. Does anyone has an example that allows one to insert a checkbox as well as capture the check flag? I know that Delphi supports this but I am trying out in assembly.

Thanks for reading...newAsm

donkey

You use the extended style LVS_EX_CHECKBOXES to enable check boxes. To set a listview extended style use the LVM_SETEXTENDEDLISTVIEWSTYLE message. To set or obtain the status of the check box you use LVM_GETITEMSTATE, this is because the check box that is created is simply a state image.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ragdog

hi

use this

invoke SendMessage, hList, LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT or LVS_EX_CHECKBOXES  ;// Set style


  invoke SendMessage, hList, LVM_GETITEMSTATE, edi, addr Item
         and eax, (3 SHL 12)
    .if(eax==(2 SHL 12))    ;

.yourcode get checked listview item

.endif

ragdog   

newAsm

Thanks ragdog,

for the information. I have implemented that. However, I have the problem. How do I detect whether the checkbox is checked or unchecked. I guess, you need to use WM_NOTIFY to do that. I implemented this code but not sure if it works:

   .elseif uMsg == WM_NOTIFY
      mov    edi,lParam
      mov      eax,[edi].NMHDR.code
      
      .if eax == NM_DBLCLK && [edi].NMHDR.idFrom == IDC_LSVPROFILE
         ;*====   Listview profile was double clicked   ====
         invoke    SendMessage,hlvwProfile,LVM_GETNEXTITEM,-1,LVNI_FOCUSED

         cmp      eax,-1
         je      noindex      

         mov      [iCurProf],eax
         invoke   show_Rec,hWin

         mov      eax,2                     ; set check
         shl      eax,12
         invoke    SendMessage,hlvwProfile,LVM_GETITEMSTATE,[iCurProf],eax
         
         .if   eax != 0
            mov      [bProfFlag],2            ; check
         .else
            mov      [bProfFlag],1            ; unchecked
         .endif
   noindex:
      .endif

Would you mind advising what ought to be the correct way of trapping or determine the state of the checkbox?

What if I want to check the checkbox state, the win32 help says use LVM_GETITEMSTATE, can you use it anytime to check the checkbox state.

Thanks for your help in advising...newAsm
sing_nep@yahoo.com

ragdog

i hope it helps you



DoCopy proc hWnd:DWORD
LOCAL Item :LV_ITEM
LOCAL PathBuff[256]:BYTE
LOCAL FileBuff[256]:BYTE
LOCAL szCopyBuff[256]:DWORD
LOCAL szDoCopy [256]:DWORD
     invoke SendMessage, hList, LVM_GETITEMCOUNT, 0, 0
     mov esi,eax
         xor edi, edi
         mov szCopyBuff,[0]
         mov szDoCopy ,[0]
  .while( esi )
     
     mov Item.iItem, edi
         mov Item.iSubItem, 0
         mov Item.imask, LVIF_PARAM or LVIF_STATE
         xor eax, eax
         mov Item.lParam, eax
         mov Item.state, eax
         invoke SendMessage, hList, LVM_GETITEMSTATE, edi, addr Item
         and eax, (3 SHL 12)
    .if(eax==(2 SHL 12))    ; If checked item
   
mov Item.iSubItem,0
    mov Item.imask,LVIF_TEXT
    lea eax,FileBuff
    mov Item.pszText,eax
    mov Item.cchTextMax,256
    invoke SendMessage,hList,LVM_GETITEM,0,addr Item

    mov Item.iSubItem,1
    mov Item.imask,LVIF_TEXT
    lea eax,PathBuff
    mov Item.pszText,eax
    mov Item.cchTextMax,256
    invoke SendMessage,hList,LVM_GETITEM,0,addr Item
    invoke lstrcat,addr szCopyBuff,addr PathBuff
    invoke lstrcat,addr szCopyBuff,addr szBksl
    invoke lstrcat,addr szCopyBuff,addr FileBuff
   
    invoke lstrcat,addr szDoCopy,addr szPathBuffer
    invoke lstrcat,addr szDoCopy,addr szBksl
    invoke lstrcat,addr szDoCopy,addr FileBuff
    invoke DeleteFile,addr szDoCopy
    invoke CopyFile, addr szCopyBuff, addr szDoCopy,0
   
        .if (eax)
         mov Item.iSubItem,2
         mov ebx,offset  szOk
             mov Item.pszText,ebx
             invoke SendMessage,hList,LVM_SETITEM,0,addr Item
          .else 
               mov Item.iSubItem,2                     
               mov ebx,offset  sznotOk
               mov Item.pszText,ebx
               invoke SendMessage,hList,LVM_SETITEM,2,addr Item
        .endif
   .endif
          inc edi
          dec esi
          mov szCopyBuff,[0]
          mov szDoCopy ,[0]
  .endw
ret
DoCopy endp

newAsm

Thanks ragdog,

Will implement what you suggest and will find out. Thanks for your advise..newAsm
s