I don’t normally use an external monitor with my laptop, and I received some feedback from a user who does.
The following program creates a %gr region and has some controls to the right of this.
There is a menu item “To clipboard” which copies the whole window to the clipboard.
This works so long as the user has not moved the window onto a second display i.e. large monitor.
If the window is on the large monitor, the “To clipboard” operation does not capture the correct parts of the monitor display i.e. EXPORT_WINDOW_IMAGE@ fails in this scenario.
Is there a simple fix to this?
module test
use clrwin
implicit none
real*8 :: pi=4.0*atan(1.d0)
integer :: tmp_gr_handle = 1000
integer(7) :: plot_window_handle
contains
integer function g()
integer :: iw
iw = winio@('%hw&',plot_window_handle)
iw = winio@('%mn[Exit]&','exit')
iw = winio@('%mn[To clipboard]&',to_clipboard_cb)
iw = winio@('%2.1ob&')
iw = winio@('%gr[red]%cb&',900,620)
iw = winio@('Pi = %`rf&',pi)
iw = winio@('%cb&')
iw = winio@('')
g = 1
end function g
integer function to_clipboard_cb()
! Call back function to copy current client area of active window to windows clipboard
integer :: i, width, height, nbbp, ercode
integer(2):: ercode1
i = EXPORT_WINDOW_IMAGE@(plot_window_handle, 'tmp.jpg', 1)
call GET_DIB_SIZE@('tmp.jpg', width, height, nbbp, ercode)
i = CREATE_GRAPHICS_REGION@(tmp_gr_handle,width,height)
i = IMPORT_IMAGE@('{tmp.jpg}',1,1)
i = GRAPHICS_TO_CLIPBOARD@(1,1,width-3,height-3) !Trim edges
i = DELETE_GRAPHICS_REGION@(tmp_gr_handle)
CALL ERASE@('tmp.jpg',ercode1)
to_clipboard_cb = 2
end function to_clipboard_cb
end module test
program main
use test
i = g()
end program main