1. RE: COMING REAL SOON !

you know, i was pretty sure one of you would say i was pulling an MTS 
when i mentioned my new virtual machine.
<shameless plug>
btw, it's almost done. i just need some more instructions, have to fix 
up the assembler, and figure out a way to add protected memory to the 
emulator(like x86 protected mode, except all references are already 
32-bit grin)
</shameless plug>

cense at mail.ru wrote:
> 
> I think too many people remember MTS too well on this list, Bernie.

new topic     » topic index » view message » categorize

2. RE: COMING REAL SOON !

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 message » categorize

3. RE: COMING REAL SOON !

Bernie Ryan wrote:
 
> -- 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 ")
 
CORRECTION THIS CODE SHOULD HAVE READ

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



Bernie

new topic     » goto parent     » topic index » view message » categorize

4. RE: COMING REAL SOON !

euman at bellsouth.net wrote:
> cosider this listview.ew file

I still think your missing the point 

All the following constants are already
predefine in w32engin.ew
------------------------------------  FROM HERE
> 
> global constant
>     LVS_REPORT = 1,
>     LVS_SHOWSELALWAYS = 8,
>     LVIF_TEXT = #0001,
>     LVIF_PARAM = #0004,
> 
>     LVIS_SELECTED  = #0002,
>     LVNI_FOCUSED = 1,
> 
>     LVCF_FMT = 1,
>     LVCF_WIDTH = 2,
>     LVCF_TEXT = 4,
>     LVCF_SUBITEM = 8,
>     LVCF_ORDER = 20,
>     LVCFMT_LEFT = 0,
>     LVM_INSERTCOLUMN = 4123,
>     LVS_SHAREIMAGELISTS = 40,
>     LVM_SETITEM = 4102,
>     LVM_INSERTITEM = 4103,
>     LVM_GETNEXTITEM = 4108,
> 
>     LVM_SETBKCOLOR = 4097,
>     LVM_SETTEXTBKCOLOR = 4134,
>     LVM_SETTEXTCOLOR = 4132,
>     LVM_SETEXTENDEDLISTVIEWSTYLE = 4150,
>     LVS_EX_GRIDLINES = 1,
>     LVS_EX_TRACKSELECT = 8,
>     LVS_EX_HEADERDRAGDROP = 10,
>     LVS_EX_FULLROWSELECT = 20,
>     LVS_EX_ONECLICKACTIVATE = 40
> 

----------------------------------- TO HERE


> constant
>     lvcol_mask = 0,

------------------------- THESE CONSTANTS ARE NOT
>     lvcol_fmt = 4,      NEEDED in w32engin.ew 
>     lvcol_cx = 8,
>     lvcol_pszText = 12,
>     lvcol_cchTextMax = 16,
>     lvcol_iSubItem = 20,
>     lvcol_iOrder = 24,
>     sizeof_lvcol = 28
> 
> global constant
>     lvitem_mask = 0,
>     lvitem_iItem = 4,
>     lvitem_iSubItem = 8,
>     lvitem_state = 12,
>     lvitem_stateMask = 16,
>     lvitem_pszText = 20,
>     lvitem_cchTextMax = 24,
>     lvitem_iImage = 28,
>     lvitem_lParam = 32,
>     lvitem_iIdent = 36,
>     sizeof_lvitem = 40
> 
--------------------------------- TO HERE
--------------------------------- THESE ARE NOT NEED
> global constant
>     LVN_COLUMNCLICK = -108,
>     NM_CLICK = -2,
>     LVM_GETITEM = 4101,
>     LVM_GETITEMSTATE =  4140,
>     LVM_GETSELECTEDCOUNT  = 4146
> 

-- This creates a LVITEM structure 
lvitem = struc(
"mask       :uint    : 1 "&
"iItem      :int     : 1 "&
"iSubItem   :int     : 1 "&
"state      :uint    : 1 "&
"stateMask  :uint    : 1 "&
"pszText    :pointer : 1 "&
"cchTextMax :int     : 1 "&
"iImage     :int     : 1 "&
"lParam     :dword   : 1 "&
"iIndent    :int     : 1 ")

You will NOTICE that this is along
text string ( SEQUENCE ).

The function struc() will automatically
read this text string ( SEQUENCE ) and build a
structure in memory and automatically calculate
all the offsets by the sizes that used in your definition
and intialize it to all zeros.
The pointer returned allows you to manipulate the structure by
using JUST THE NAMES that you used in your definition.

-- Insert 12345 in "lParam" -- NOTICE A NAME
-- in the LVITEM structure pointed to by lvitem
-- AND WILL automatically check that your using a DWORD
put(lvitem,"lParam",12345)

-- return the "stateMask" LVITEM structure pointed to by lvitem
grab(lvitem,"stateMask")

-- This would print size in bytes of the structure
? sizeof(lvitem)

-- If the structure is already PREDEFINED in the library
-- You can do declare it like this.
lvitem = struc("LVITEM")
-- Or you can also declare and initialize it 
-- Create a RECT structure and initialize at the same time
-- to some values
rect =  struc({"RECT",{0,0,200,300}})
-- clone a structure
another_rect = dups(rect)
-- Print the size of a PREDEFINED structure by name
? sizeof("RECT")
-- or use the rect pointer
? sizeof(rect)

ALSO it can use ARRAYS of STRUCTURES
etc ...............

NO NEED TO CALCULATE OFFSETS
AND THE struc() function can do this
with ANY structure that you describe
to the library.

This is only some of the structure features
in w32engin.ew.

Bernie

new topic     » goto parent     » topic index » view message » categorize

5. RE: COMING REAL SOON !

euman at bellsouth.net wrote:
>   poke4( tvstruct + TVINSERTSTRUCTITEM_iImage,0)
>   poke4( tvstruct + TVINSERTSTRUCTITEM_iSelectedImage,1)
> 
> there is no difference in the two languages as for functioning code 
> (sorta)
> 
> Are you going to take this into consideration, there is a catch in 
> notifying
> the control owner and this is where the second structure come into play.
> 
>               if iMsg = TVN_SELCHANGED then --NM_CLICK then -- TreeView
> 
>                    count = c_func(SendMessage,{id, TVM_GETCOUNT, 0, 0})
>                    item = c_func(SendMessage,{id,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)
> 
> note that the structure used here for the treeview notification is not 
> the same
> as the first
> used to create the treeview, it's the second because of its 8 bytes 
> offset. A
> question
> I recently asked the list about and its pretty straight forward. How 
> will your
> engine account
> for this? Will it be faster than what I already have?

I think your talking about the UNION in the 
TVINSERTSTRUCT structure.

I would do this:

sequence def

def = 
  "hParent:      pointer: 1 "&
  "hInsertAfter: pointer: 1 "
   if WIN32_IE >= #400 then -- union DUMMYUNIONNAME
     def &= "itemex : pointer: 1 "&
     def &= "item   : pointer: 1 "
   else                     -- single pointer
     def &= "item   : pointer: 1 "
   end if

-- Create the structure WIN32_IE  
LP_TVINSERTSTRUCT = struc(def) 

Bernie

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu