Win32Lib dynamic controls

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

While working on eWinHelp, I found a need to create and destroy controls =
in the middle of the program.  Following is the code for creating =
controls dynamically, although I haven't had a chance to write the =
destruction procedure yet.  I apologize to David Cuny for modifying =
Win32Lib slightly as noted in the comments.  The code is about 55 lines =
long.

------ Tested code -------

-- Dynactrl.ew
-- Dynamic control module for Win32Lib.
-- Append to the END of Win32Lib or make the following variable/routine =
names
-- global:

-- Line 1182 of alpha-10: global sequence className, classType, ...
-- Line 1420 of alpha-10: global atom WndProcAddress
-- Line 1621 of alpha-10: global atom buffer1, buffer2
-- Line 1682 of alpha-10: global sequence window, window_handle, =
window_func,...

-- Written by Michael J. Sabal on August 27, 1998

global function addControl(integer typeOf, sequence title, atom owner,
    atom x, atom y, atom xSize, atom ySize, atom styleFlags)

    atom ctrlID
   =20
    window =3D append(window,
        {owner,typeOf,title,x,y,xSize,ySize,styleFlags})
    ctrlID =3D length(window)

    poke(buffer1,className[typeOf]&0)
    poke(buffer2,title&0)
    styleFlags =3D or_bits(classStyle[typeOf],styleFlags)
   =20
    window_handle =3D append(window_handle, c_func(xCreateWindow, {
            0,
            buffer1,
            buffer2,
            styleFlags,
            x,
            y,
            xSize,
            ySize,
            window_handle[owner],
            NULL,
            0,
            NULL}))
    window_func =3D append(window_func, c_func(xSetWindowLong,
        {window_handle[ctrlID],GWL_WndProc,WndProcAddress}))
    window_class =3D append(window_class, classType[typeOf])
    if and_bits(WS_TABSTOP,styleFlags) then
      window_tab[owner] =3D append(window_tab[owner],ctrlID)
    end if
    window_owner =3D append(window_owner, owner)
   =20
    return ctrlID

end function

---------------------

Michael J. Sabal
mjs at osa.att.ne.jp
http://home.att.ne.jp/gold/mjs/index.html

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

Search



Quick Links

User menu

Not signed in.

Misc Menu