Win32Lib idea - custom controls

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

I just had an idea on how to implement custom controls (like xControls) in
Win32Lib without changing more than a few lines. Basically, I changed the
first parameter to createEx and create, pControl to an object. If pControl
is an integer, it works normally. If pControl is a sequence, it should be 1
element, that element being a routine id to a function that returns a valid
Win32Lib id.

Here's what needs changing:

global function createEx( object pControl, sequence caption, atom pOwner,
-- pControl is now an object
    object x, object y, object cx, object cy,
    object styleFlags, object exFlags )

    -- (code commented out due to length)

    if integer( pControl ) then

        -- all normal createEx() code goes here
        -- (code commented out due to length)

    else    -- sequence
        if length( pControl ) = 1 then
            id = call_func( pControl[1], {caption, pOwner, x, y, cx, cy,
styleFlags, exFlags} )
        else
            -- quit
            abortErr( {"createEx: Invalid routine id in pControl", 999} )
        end if
    end if

    return id
end function

global function create( object pControl, sequence caption, atom pOwner,
-- pControl is now an object
    object x, object y, object cx, object cy,
    object styleFlags, object exFlags )

    -- (code commented out due to length)

end function



here's an example on how it works:

-- begin demo --
include Win32Lib.ew
without warning

function iPopupWindow( sequence caption, integer pOwner, object x, object y,
object cx, object cy, object styleFlags, object exFlags )
    return createEx( Window, caption, pOwner, x, y, cx, cy, {WS_POPUP}, 0 )
end function
global constant PopupWindow = {routine_id("iPopupWindow")}    -- sequence

constant MyWin = create( PopupWindow, "test", 0, Center, Center, 0.75, 0.75,
0 )

WinMain( MyWin, Normal )
-- end demo --


~Greg

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

Search



Quick Links

User menu

Not signed in.

Misc Menu