Page 1 of 1

State property of a Form

Posted: Fri May 14, 2010 4:08 am
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.

Re: State property of a Form

Posted: Fri May 14, 2010 3:12 pm
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

Re: State property of a Form

Posted: Tue May 18, 2010 3:14 pm
by paulmansour
Vince,

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