Hi Jeff,
I would like to add a file/open menu to main window of resize (just as an example of the potential use of the open file dialog).
I've successfully added 'File/saveimage', 'File/open', and 'File/quit' sub-menus to the window.
The File/saveimage and File/quit options work just fine, but the File/open dlgopenfile() option causes the system to 'hang-up'.
Do you have any suggestions on the proper use and way to add a file open dlgopenfile() menu to a main window?
Below is the code of your resize program with my revisions labeled to add menu options.
I look forward to any suggestions you or others may have to resolve this issue.
Frank
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
appprogram resizing
use appgraphics
implicit none
integer::myscreen
integer::mybutton
logical::quit
!--------------Added-------------------------------------\/
integer::root_menu, file_menu, item_temp
!--------------------------------------------------------/\
myscreen = initwindow(320, 240, closeflag=.TRUE.)
mybutton = createbutton(270, 210, 40, 20, "Close", handle_button)
!--------------Added-------------------------------------\/
root_menu = addmenu("", MENU_FOR_WINDOW)
file_menu = addmenu("File", root_menu)
item_temp = addmenuitem("Save Screenshot...", file_menu, savescreen)
item_temp = addmenuitem("Open", file_menu, openfile)
item_temp = addmenuitem("Quit", file_menu, quitwndo)
!--------------------------------------------------------/\
quit = .FALSE.
call enableresize(handle_resize)
do while(.NOT. quit)
call draw_window()
call loop()
end do
call closewindow(myscreen)
contains
subroutine draw_window()
use appgraphics
implicit none
integer::w,h
integer::tw
character(100)::info
w = getmaxx()
h = getmaxy()
call setbuttonposition(mybutton, w-50, h-30, 40, 20)
write(info, '(A5,1X,I5,A1,I5)') "Size:", w, "x", h
call setviewport(0, 0, w, 40, .FALSE.)
call clearviewport()
tw = textwidth(trim(info))
call outtextxy( (w/2-tw/2), 5, trim(info))
end subroutine draw_window
subroutine handle_button()
use appgraphics, only: stopidle
implicit none
quit = .TRUE.
call stopidle()
end subroutine handle_button
subroutine handle_resize()
use appgraphics
implicit none
call stopidle()
end subroutine handle_resize
!--------------Added-------------------------------------\/
subroutine openfile()
USE appgraphics, ONLY: dlgopenfile
implicit none
CHARACTER(255) :: input_file_name
! Appgraphics function dlgopenfile (filename, maskdesc, mask, title)
input_file_name= repeat(' ', 255)
IF( dlgopenfile( &
input_file_name, 'Data', '*.raw', 'Enter data file') ) THEN
Print *, "You've selected "//trim(input_file_name)
ELSE
Print *, "No file was selected"
END IF
input_file_name = TRIM(input_file_name)
end subroutine openfile
subroutine savescreen()
use appgraphics, only: writeimagefile
implicit none
! This call will open a file dialog since we haven't
! specified a filename
call writeimagefile()
end subroutine savescreen
subroutine quitwndo()
use appgraphics, only: stopidle
implicit none
quit = .TRUE.
call stopidle()
end subroutine quitwndo
!--------------------------------------------------------/\
end program resizing
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~