RE: Win32Lib idea - custom controls

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

> -----Original Message-----
> From: Greg Haberek [mailto:g.haberek at comcast.net]
> Subject: Win32Lib idea - custom controls
>
>
>
> 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.

Yes, this is a reasonable starting position. However, there are a number of
internal variables and routines that would have to be managed as well. For
example, consider the setText() routine. In order for this to act upon the
custom control, it currently needs to know what type of control it is so it
can perform the appropriate calls and processing to set the controls text or
caption.

What I'm proposing is that an extensible API be created so that all
controls, 'built-in' controls and user-defined controls, will support. Then
Win32lib can simply manage environments and controls, and provide programmer
ease-of-use tools.

> 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 --

This is fine so long as custom controls are only to be based on a single
built-in control. But this will not work well for a new control type such as
a grid or chart.

I wish to work towards enabling programmers to create new control types as
seemless add-ons to the library.

--
Derek

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

Search



Quick Links

User menu

Not signed in.

Misc Menu