State property of a Form

Using (or providing) components based on the "Win32" framework
Post Reply
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

State property of a Form

Post by paulmansour »

Consider the following function:

Code: Select all

 
z←foo;f
 'f'⎕WC'Form'('Coord' 'Pixel')
 f.State←2
 z←f.Posn f.Size


Executing this produces a different result than tracing. I assume because the State property really does not take affect until a wait state happens, sure enough:

Code: Select all

z←foo2;f
 'f'⎕WC'Form'('Coord' 'Pixel')
 f.State←2
 f.onClose←1
 ⎕NQ f'Close'
 f.Wait
 z←f.Posn f.Size


gives the "correct" result.

First question: is this behavoir of Form.State a bug or a feature?

Second question: the reason I am doing this is to determine the position and dimensions of the monitor the form happens to reside on, which is not necessarily the same as the DevCaps property. Is there some other all-Dyalog (non []NA) way to do it?

Finally, I can do the above work around, no problem, with a slight modification to avoid a flashing, temporary visible form:

Code: Select all

z←foo3;f
 'f'⎕WC'Form'('Coord' 'Pixel')
 f.AlphaBlend←0
 f.State←2
 f.onClose←1
 ⎕NQ f'Close'
 f.Wait
 z←f.Posn f.Size


If you are wondering why I am not using the Visible property, try it and find out!

Thanks for any comments or suggestions.
Vince|Dyalog
Posts: 439
Joined: Wed Oct 01, 2008 9:39 am

Re: State property of a Form

Post by Vince|Dyalog »

Hi Paul,

It's not a bug. The state property doesn't take effect until we get a chance to send it to windows. You can do this by calling the flush method or inserting a small call on ⎕DL.

When you are tracing line by line, we are waiting for input after each line. So the processing of windows messages happens continuously while we are waiting.

Code: Select all

 z←goo;f
 'f'⎕WC'Form'('Coord' 'Pixel')
 f.State←2
⍝ 2 ⎕NQ'.' 'flush'
⍝ ⎕DL 0.1
 z←f.Posn f.Size


I think you can only use ⎕NA .net to get the information you want.

Regards,

Vince
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

Re: State property of a Form

Post by paulmansour »

Vince,

Thanks, I forgot about the Flush method! That cleans it up a bit.
Post Reply