Re: Win32Lib bug?

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

Hi Brian,
I've been away on business, so sorry for the slow response.

>
> Question: Does 'create' still process flags?

Yes it does. In fact it works the same for all control types now. The
previous versions treated create() flags one way for Window controls and
another for other types. For Window, it used to replace the default flags
with any you might have specified, for others, it combined supplied flags
with the defaults. Now, Window works like the other controls.

> This works on version .50:
>
> constant
>   NoSizeWin = or_all( {WS_DLGFRAME,
>                        WS_SYSMENU,
>                        WS_MINIMIZEBOX} )
>
> constant
>   Win = create( Window, "Win", 0, 0, 0, 640, 480, NoSizeWin )
>
> -- Win is a Window that cannot be resized
>
> This no longer works in the latest release.  I don't have time to track it
> down because there have been so many changes lately...
>

To allow people complete flexibility when dealing with more complex flag
combinations, a new function, classDefaults() was set up. This function
allows you to set the default flags for a given control type. This can set
both the normal style flags and the extended style flags.

Given your example above, there are two basic ways to achieve what you want
to do.

1) --------------------
  sequence oldFlags
  atom NoSizeWin

  NoSizeWin = or_all( {WS_DLGFRAME,
                          WS_SYSMENU,
                          WS_MINIMIZEBOX} )
  -- Set default flags for Window to NoSizeWin
  oldflags = classDefaults(Window, {{CCflags, NoSizeWin} })

  -- Create a window using the (new) defaults
  Win = create( Window, "Win", 0, 0, 0, 640, 48, 0)

2) -------------------
  sequence oldFlags
  atom NoSizeWin

  NoSizeWin = or_all( {WS_DLGFRAME,
                          WS_SYSMENU,
                          WS_MINIMIZEBOX} )
  -- Set defaults for Window to zero (no flags at all)
  oldflags = classDefaults(Window, {{CCflags, 0}} )

  -- Create a window combining defaults (zero) with NoSizeWin
  Win = create( Window, "Win", 0, 0, 0, 640, 480, NoSizeWin)


To make this commonly used functionality easier to use, I'm packaging some
of the more useful Window flag combinations into reserved Win32Lib words.

David Cuny wants me to use these new words as Control Types but I would
rather them being used as Style Flags. So I'm very tempted to do both,
unless persuaded otherwise.

David's method:
   Win = create(NoSizeWindow, "Win", 0, 0, 0, 640, 480, 0)

Derek's method:
   Win = create(Window, "Win", 0, 0, 0, 640, 480, w32NoSizeWin)

My reasoning is that the first create() parameter describes a basic
behaviour, whereas the flags parameter describes a basic interface. Also,
having a "new" control type is adds more complexity in the library that I
don't think is justified for things that are essentially the same. For
example, there are many places in the library that does this sort of thing
...

  if window_type[id] = Window then ....

this might have to be changed to ...

  if find(window_type[id], {Window, NoSizeWindow, ...}) != 0 then ....

or maybe ...

  if and_bits(classAttr[window_type[id]], w32IsWindow) != 0 then ...


however, if we use these new words as predefined Window styles, the current
code is unchanged except in the create() function, with something like ...

   if equal(styleflag, w32NoSizeWin) then
       flags = or_bits(....)
   elsif ...
   else
       flags = or_bits(defaultflags, styleflags)
   end if

What does anybody else think?

------
Derek Parnell
Melbourne, Australia
(Vote [1] The Cheshire Cat for Internet Mascot)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu