win32lib event handling question

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

Hi All

I've created a window dynamically with win32lib and then created
child windows in that 'parent' window.

My problem is that the dynamically created windows don't seem to receive
events of any kind (w32HClick, w32HMouse, etc).

Is this a feature of win32lib? :)

I'm trying to track the position of the child windows in the event handler
(not shown in the code since it doesn't even get called).

Any ideas?

Example:
--/begin childtest.ew
-- testing win32lib event handling of dynamically created windows
-- win32lib v0.60.6

include win32lib.ew

-- globals
constant launchwin = create(Window, "Launcher", 0,
           Default, Default, 320, 240, 0),
         Button1 = create(Button, "Launch", launchwin,
           5, 5, 50, 20, 0),
         Status = create(StatusBar, "", launchwin, 
                    0, 0, 0, 0, 0)

-- 'positions' indices
constant NAME = 1,
         XPOS = 2,
         YPOS = 3

constant positions = {{"ONE", 10,10},
                      {"TWO", 110, 10},
                      {"THREE", 110, 110}}

-- support routines
procedure create_parent_and_children()
   atom parent, child
   sequence name
   atom x, y

   parent = createEx(Window, "Parent", launchwin,
              Default, Default, 640, 480, 
              w32or_all({WS_THICKFRAME, WS_SYSMENU}),
              w32or_all({WS_EX_DLGMODALFRAME}) )
   setHandler(parent, w32HMouse, routine_id("child_onMouse"))
   openWindow(parent, Modal)

   for i = 1 to length(positions) do
       name = positions[i][NAME]
       x = positions[i][XPOS]
       y = positions[i][YPOS]
       child = create(Window, name, parent,
         x, y, 100, 100,
         {WS_CHILD, WS_CLIPSIBLINGS, WS_BORDER, WS_CAPTION} )

       -- this should set handler for when mouse activity occurs?
       setHandler(child, w32HMouse, routine_id("child_onMouse") ) 
       openWindow(child, Normal)   
   end for
end procedure

procedure child_onMouse(integer self, atom event, sequence params)
    atom evt, shift

    evt = params[1]
    shift = params[4]

    setText(Status, "Mouse event in " & getText(self))
end procedure
-- handler set dynamically

setHandler(launchwin, w32HMouse, routine_id("child_onMouse") ) -- test

-- launch window control events
procedure Button1_onClick(integer self, atom event, sequence params)
    create_parent_and_children()
end procedure
setHandler(Button1, w32HClick, routine_id("Button1_onClick") )

-- start
setText(Status, sprintf("Win32Lib version %d.%d Patch#%d, %s",
                            Win32LibVersion))
WinMain(launchwin, Normal)
--/end childtest.ew


--(I hope Privoxy doesn't mangle it)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu