source:http://blog.sina.com.cn/s/blog_483ac0ab0100gq8t.html~type=v5_one&label=rela_nextarticle 对于fortran的程序界面方面,也简单做一个罗列: 1.混合编程: 用fortran做核心计算,然后利用VB、VC等做界面,这是大家认可的。具体的可以参考彭国伦、唐章宏等人写的书; 2.利用fortran的扩展功能 在上面的帖子里面已经给出例子,在QUICKWIN模式下可以利用原有的菜单,也可以自己订制菜单和对话框,如果程序仅仅需要一些简单的菜单和对话框的话,这个是不错的选择;唯一不足的就是缺少工具条的制作,当然如果调用API函数的话应该能够实现吧(探讨)。 3.利用API函数做界面 下面给出一个简单的例子,形成简单的菜单和模态对话框。从程序看,这个方法需要的代码比较多,相比较QUICKWIN工程中利用fortran的扩展功能而言,这个方法做界面就复杂一些。 module hh integer hInst integer hDlg end module hh integer function WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinMain' :: WinMain !DEC$ ENDIF !包含有用的模块 use user32 use dfwin use hh USE clipinc integer hInstance integer hPrevInstance integer nCmdShow integer lpszCmdLine !***************************************************************** interface integer*4 function MainWndProc ( hwnd, mesg, wParam, lParam ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_MainWndProc@16' :: MainWndProc !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : 'MainWndProc' :: MainWndProc !DEC$ ENDIF integer*4 hwnd integer*4 mesg integer*4 wParam integer*4 lParam end function end interface !****************************************************************** type (T_WNDCLASS) type (T_MSG) integer character*100 lpszClassName,lpszAppName,lpszMenuName COLOR=9 !这个用来改变窗口的背景颜色 lpszCmdLine = lpszCmdLine nCmdShow = nCmdShow lpszClassName ="Generic"C lpszAppName ="窗口程序,非模态对话框"C lpszMenuName="menumenu"C if(hPrevInstance .eq. 0) then end if hWnd = CreateWindowEx( |