Don't retrieve !D.Y_VSIZE too quickly [message #81982] |
Sat, 03 November 2012 18:59 |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
For the second time this week, I found a need to repeat an IDL command for it to take full effect. Below is the sample program on my Mac
pro testwin
print,getprimaryscreensize()
window,xsize=870,ysize=870,retain=2
print,!D.y_size,!D.y_vsize
print,!D.y_size,!D.y_vsize
return
end
The output is
IDL> testwin
1440 878
870 870
856 856
So when I first ask to print !D.y_vsize it returns 870, but when I immediately ask again it returns 856.
This problem is avoided if I put any sort of wait statement after opening the window. It appears to take a finite time, after I ask IDL to open a window with a Ysize of 870 pixels, to realize that the toolbar is using up 22 pixels and adjust !Y.V_SIZE accordingly.
This delay is what may have caused the difficulty in getting the Mac useful screen size
( http://www.idlcoyote.com/code_tips/goldilocks.html ). My solution for getting the useful Mac screen size would now be the following:
function getmacsize
xy = get_screen_size()
window,xsize=xy[0],ysize=xy[1],/free
wait,0.01
out = [!D.x_vsize,!D.Y_vsize]
wdelete,!D.window
return,out
end
Of course, this will give flashing but at least it will give the right answer.
Cheers, -Wayne
|
|
|