RE: COMING REAL SOON !

new topic     » goto parent     » topic index » view thread      » older message » newer message

euman at bellsouth.net wrote:
> Im almost finished with the same ("similar") thing.
> 
>     elsif iMsg = WM_NOTIFY then
>           id = peek4s(lParam + NMHDR_hwndFrom)
>           if id = ListView then
>              iMsg = peek4s(lParam + NMHDR_code)
>       if iMsg = LVN_COLUMNCLICK then -- ListView "could run a sort routine 
>       here"
>       elsif iMsg = NM_CLICK then -- ListView Item Clicked
>                    junk = c_func(SendMessage,{ListView1,LVM_GETNEXTITEM,-1,
> LVNI_FOCUSED})
>                    poke4(lvitem + lvitem_iItem,junk)
>                    poke4(lvitem + lvitem_iSubItem,0)
>                    poke4(lvitem + lvitem_mask,LVIF_TEXT)
>                    txtbuff = allocate(256)
>                    poke4(lvitem + lvitem_pszText,txtbuff)
>                    poke4(lvitem + lvitem_cchTextMax,256)
>                    cmd = c_func(SendMessage,{ListView1, LVM_GETITEM, 0,
>                    lvitem})
>                    lvtxt = peek_string(txtbuff)
>                    free(txtbuff)
>               end if
>           elsif id = TreeView then
>               iMsg = peek4s(lParam + NMHDR_code)
>               if iMsg = TVN_SELCHANGED then --NM_CLICK then -- TreeView
>                    count = c_func(SendMessage,{TreeView1, TVM_GETCOUNT, 0, 0})
>                    item = c_func(SendMessage,{TreeView1,TVM_GETNEXTITEM, 0,
> TVGN_ROOT})
>                    poke4(tvitem + tvitem_hItem,item)
>                    poke4(tvitem + tvitem_mask,TVIF_TEXT)
>                    poke4(tvitem + tvitem_stateMask, TVIS_SELECTED)
>                    txtbuff = allocate(256)
>                    poke4(tvitem + tvitem_pszText,txtbuff)
>                    poke4(tvitem + tvitem_cchTextMax,256)
>                    ok = c_func(SendMessage,{TreeView1, TVM_GETITEM, 0,
>                    tvitem})
>                    for i = 1 to count do
>                        cmd = peek4s(tvitem + tvitem_state )
>                        if and_bits(cmd, TVIS_SELECTED) then
>                           exit
>                        end if
>                        item = c_func(SendMessage,{TreeView1, TVM_GETNEXTITEM,
> TVGN_NEXTVISIBLE, item})
>                        poke4( tvitem + tvitem_hItem, item)
>                        ok = c_func(SendMessage,{TreeView1, TVM_GETITEM, 0,
> tvitem})
>                    end for
>           


Here is the same code using the w32engin.ew.
--
type LPITEM(atom d) return pointer(d) end type
--
-- declare pointer to a LPITEM structure
LPITEM lvitem

-- Second if I find no built-in description for LPITEM
-- structure in the library
-- I can add the structure discription to the library through
-- the piston.ew file Or I can create it immediately
-- just for this one program like this.
--
lvitem = struc(
  "uint    : mask       : 1 "&
  "int     : iItem      : 1 "&
  "int     : iSubItem   : 1 "&
  "uint    : state      : 1 "&
  "uint    : stateMask  : 1 "&
  "pointer : pszText    : 1 "&
  "int     : cchTextMax : 1 "&
  "int     : iImage     : 1 "&
  "dword   : lParam     : 1 "&
  "int     : iIndent    : 1 ")

-- declare pointer to a NMHDR structure
LPNMHDR lpnm
-- catch all variable
RESULT void

-- create text buffer
LPTSTR txtbuf
txtbuff = string(256)

elsif case = WM_NOTIFY then

  -- for clarity
  lpNM = lParam

  -- associate the lParam with NMHDR that Window's places in memory
  AssociatePtr(lpNM,"NMHDR")
  case = grab(lpNM,"hwndFrom")
  if case = ListView then
    case = grab(lpNM,"code")
      if case = LVN_COLUMNCLICK then
          ---- > ListView "could run a sort routine here"
      elsif case = NM_CLICK then
        index = SendMessageA({ListView1,LVM_GETNEXTITEM,
                                        -1,LVNI_FOCUSED})
        put(lvitem,"iItem", index)
        put(lvitem,"iSubItem",  0)
        put(lvitem,"mask", LVIF_TEXT )
        put(lvitem,"pszText", txtbuff )
        put(lvitem,"cchTextMax", sizeof(txtbuff) )
        void = SendMessageA({ListView1,LVM_GETITEM,0,lvitem})
        -- At this point you could use any of the
        --  "C" string functions in the library
        --  to manipulte the text in the buffer
        --  or you can convert to a Euphoria sequence
        lvtxt = str2seg(txtbuff)
        free_mem(txtbuff)
      elsif case = TreeView then
        case = grab(lpNM,"code")
        if case = TVN_SELCHANGED then
          count = SendMessageA({TreeView1,TVM_GETCOUNT,0,0})
          item  = SendMessage(TreeView1,TVM_GETNEXTITEM,0,TVGN_ROOT})
          put(tvitem,"hItem",item)
          put(tvitem,"mask",TVIF_TEXT)
          put(tvitem,"stateMask", TVIS_SELECTED)
          put(tvitem,"pszText",txtbuff)
          put(tvitem,"cchTextMax,sizeof(txtbuff))
          ok = SendMessageA({TreeView1,TVM_GETITEM,0,tvitem})
          for i = 1 to count do
            cmd = grab(tvitem,"state")
            if and_bits(cmd,TVIS_SELECTED) then
              exit
            end if
            item = SendMessage({TreeView1,TVM_GETNEXTITEM,
                                   TVGN_NEXTVISIBLE,item})
            put(tvitem,"hItem",item)
            void = SendMessageA({TreeView1,TVM_GETITEM,0,tvitem})
          end for
          -- You can use a library "C" string function
          -- while its still in the buffer
          txtlen = strlen(txtbuff)
          -- convert it 2 a sequence
          lvtxt = str2seq(txtbuff)

Bernie

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu