Hi. I'm having some fun trying to get a %gr control to completely fill a resizeable window. The %gr follows a %pv and has the user_resize option, and the window also contains menu, toolbar and a status bar. This is a program that has been around for years, but the advent of 4k and high-dpi displays has highlighted a problem.
Up until now the %gr has been given a size that makes it the widest control, so the window sets its width based on the gr. I'm now finding there is a gap to the right of the gr when Windows font scaling (dpi) is increased. I guess this is because the fonts used in the status bar, title etc. have increased in size and make the title and status bar wider than the gr, hence the gap. The quick-fix is to increase the size of the gr, but I can't just have a fixed number any more as the range of possible screen resolutions & dpi settings is too large. I've fudged it for the moment by scaling the gr width based on the system dpi value, but I'm not entirely happy with that. Is there any way to tell the gr to fill the window, or maybe a way to set the gr width after the window has been created so ClearWin can lay out all the other controls first?
Here's a small example - running this at normal Windows '100%' scaling (96dpi) the gr fills the window. Up the Windows scaling to '125%' and a gap appears between the gr and the window edge:
winapp
use mswin
integer i
character*48 title ! length affects window width
external draw
title = '%gr User Resize Test'
i = winio@('%ww[no_border]&')
i = winio@('%ca@&', title)
i = winio@('%pv%^gr[blue,user_resize,rgb_colours]&',500L,500L,draw)
i = winio@('%ob[status]%`48rs%cb', title)
end
integer function draw()
use mswin
integer x,y,resize
resize=clearwin_info@('GRAPHICS_RESIZING')
if(resize .eq. 1)then
x=clearwin_info@('GRAPHICS_WIDTH')
y=clearwin_info@('GRAPHICS_DEPTH')
call draw_line_between@(10,10,x-10,y-10,rgb@(255,0,0))
endif
draw=2
end function draw