Current issue

Vol.26 No.4

Vol.26 No.4

Volumes

© 1984-2024
British APL Association
All rights reserved.

Archive articles posted online on request: ask the archivist.

archive/15/4

Volume 15, No.4

This article might contain pre-Unicode character-mapped APL code.
See here for details.

Hackers’ Corner: Don’t Clip my Children!

by Adrian Smith (adrian@cgsl.demon.co.uk)

Motivation

“The great storm of computer progress moves on, leaving behind many puddles, in which teem interesting life…” (Ted Nelson, Stanford, 1991)

Somewhere between October 1998 and January 1999 the great storm of computer progress swept through Basingstoke, leaving behind it a subtle change to the Dyadic interpreter which few people noticed, but which had some rather bizarre consequences for one particular application which just happened to be dominating my life at the time. It also upset the children, whose ‘Mystro’ adventure puzzle game developed strange rectangular ‘windows’ to the desktop (or File Manager or whatever else was underneath at the time) – something funny was going on, and I was going to have to find out what it was!

Investigation

Obviously the first thing to do was to find out what I was doing to trigger this strange behaviour, and then to make up a sample function to illustrate the problem. It turned out that my problem was caused by exploiting a very useful (undocumented) feature of the interpreter which allows you to set a subform as ('BCol' Ð) – this completely prevents it from painting, but it still registers mouse events, and it has a ‘Cursor’ property. This is exactly what you need if you have a pictorial adventure game where various areas on the picture are marked as ‘hot spots’ which either jump to another picture, or run some kind of challenge where you need to type in the right code to proceed. More immediately relevant, it lets you simulate ‘active desktop’ with illuminating shortcuts where the icon labels magically change on mouse-over.

Here is the sample function, and if you turn the page, you can see the weird effect it produces ...


     ’goo
[1]   'ff'ŒWC'form'
[2]   'ff.sub'ŒWC'subform' ''(10 10)(80 80)('bcol' Ð)
     ’

screenshot

The problem is that not only has Dyalog (correctly) left the subform unpainted, but it has carefully avoided painting the underlying form too! After several conversations with the Basingstoke helpline it turned out that they had added a ‘ClipChildren’ style to the ‘Form’ object, apparently to reduce flicker when Windows98 or NT users set ‘Show contents while dragging’ in Display Properties. This also explained another effect I had become aware of – forms with lots of child controls were being drawn with holes cut out under the controls, which were then drawn over the holes. Running on a black desktop with a (fairly) slow graphics card, you really notice this.

The Solution


     ’setwdw obj;gwl;swl;hdl;bits
[1]   © Zap the 'Clipchildren' style on parent object 
[2]    'gwl'ŒNA'U user32.C32|GetWindowLongA I I'
[3]    'swl'ŒNA'U user32.C32|SetWindowLongA I I U'
[4]    hdl„obj ŒWG'HANDLE'
[5]    Œ„bits„(32½2)‚gwl hdl ¯16
[6]    (7œbits)„0
[7]    {}swl hdl ¯16(2ƒbits)
[8]    Œ„bits„(32½2)‚gwl hdl ¯16  © Debugging code - remove
     ’

The 7th bit is the one that you need to zap to reverse the change and get back to the old settings. Zapping various of the other bits has bizarre and unpredictable effects, and is not recommended. Simply run this function, passing it the name of your main form after creation and your children will no longer be clipped.


     ’goo
[1]   'ff'ŒWC'form'
[2]    setwdw'ff'
[3]   'ff.sub'ŒWC'subform' ''(10 10)(80 80)('bcol' Ð)
     ’

script began 3:40:02
caching off
debug mode off
cache time 3600 sec
indmtime not found in cache
cached index is fresh
recompiling index.xml
index compiled in 0.1826 secs
read index
read issues/index.xml
identified 26 volumes, 101 issues
array (
  'id' => '10008830',
)
regenerated static HTML
article source is 'HTML'
source file encoding is 'UTF-8'
URL: hack154.gif => trad/v154/hack154.gif
completed in 0.2024 secs