Re: Win32Lib SortedCombo

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

----- Original Message ----- 
From: "Wolf" <wolfritz at KING.IGS.NET>
To: <EUforum at topica.com>
Subject: Win32Lib SortedCombo


> 
> 
> I remember this 'subclassing' nightmare well enuf to stay away from it.
> 
> Antonio would like to know,
> ... how to capture the RETURN key,

  sequence temp
  temp = findChildren(sc)
setHandler(temp[1][1], w32HKeyPress,
  routine_id("KeyPress_SortedComboEditbox"))

> ... to use as a 'selector' from a list of items in a SortedCombo,

  setHandler(sc, w32HChange, routine_id("Change_SortedCombo"))

> ... to place the selected list item text elsewhere.

  setText( whatever, getItem(sc, 0) )


Here is an example program...

-------------
without warning
include win32lib.ew
constant win = create(Window, "Test", 0, 0, 0, 600, 400, 0),
         sb = create(StatusBar, "", win, 0, 0, 0, 0, 0),
         sc  = create(SortedCombo, "", win, 5, 5, 250, 350, 0)
object vTemp
integer sce
vTemp = findChildren(sc)
sce = vTemp[1][1]

sequence sc_list
sc_list = {
      "one", 
      "two",
      "three",
      "four",
      "five",
      "six",
      "seven",
      "eight",
      "nine",
      "ten"
    }
             
addItem(sc, sc_list)

procedure KeyPress_sc(integer self, integer event, sequence parms)
    -- Add item to the list if its not already there.
    sequence newitem
    integer lpos
    if parms[1] = VK_RETURN then
        newitem = getText(sce)
        lpos = findItem(sc, newitem, 1)
        if lpos = 0 then
            sc_list = append(sc_list, newitem)
            addItem(sc, newitem)
            setText(sb, sprintf("added '%s'", {newitem}))
        else
            setIndex(sc, lpos)
            setText(sb, sprintf("found '%s'", {newitem}))
        end if
    end if        
end procedure
setHandler(sce, w32HKeyPress, routine_id("KeyPress_sc"))

procedure Change_sc(integer self, integer event, sequence parms)
    setText(sb, getItem(sc,0))
end procedure
setHandler(sc, w32HChange, routine_id("Change_sc"))
        
WinMain(win, Normal)    


-- 
Derek

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

Search



Quick Links

User menu

Not signed in.

Misc Menu