!  LessonA35.f90 
!
!  FUNCTIONS:
!	LessonA35      - Entry point of console application.
!
!	Example of displaying 'Hello World' at execution time.
!

!****************************************************************************
!
!  PROGRAM: LessonA35
!
!  PURPOSE:  Entry point for 'Hello World' sample console application.
!
!****************************************************************************

	program LessonA35

	implicit none

	double precision, external :: MyFieldFcn

	interface
        integer function CreatePopupChartWndGlobal(hwnd, charttype, title, x, y, cx, cy)
          !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?CreatePopupChartWndGlobal@Classless@@YAPAUHWND__@@PAU2@HPADHHHH@Z'::CreatePopupChartWndGlobal
          !DEC$ATTRIBUTES VALUE::hwnd, charttype, title, x, y, cx, cy
		  integer hwnd, charttype, title, x, y, cx, cy
		end function CreatePopupChartWndGlobal

		integer*1 function SetType(chartType)
          !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?SetType@Classless@@YA_NH@Z'::SetType
		  !DEC$ATTRIBUTES VALUE::chartType
		  integer chartType
		end function SetType

		subroutine SetFieldFcn(fieldFcn)
		  interface
		    double precision function fieldFcn(x, y)
			  !DEC$ATTRIBUTES VALUE::x,y
			  double precision x, y
			end function fieldFcn
		  end interface
          !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?SetFieldFcn@Classless@@YAXP6GNNN@Z@Z'::SetFieldFcn
		end subroutine SetFieldFcn

		subroutine SetPlotRange(x1, x2, y1, y2)
		  !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?SetPlotRange@Classless@@YAXNNNN@Z'::SetPlotRange
		  !DEC$ATTRIBUTES VALUE::x1, x2, y1, y2
		  double precision x1, x2, y1, y2
		end subroutine SetPlotRange

		subroutine SetTitle(title)
		  !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?SetTitle@Classless@@YAXPBD@Z'::SetTitle
		  !DEC$ATTRIBUTES VALUE::title
		  integer title
		end subroutine SetTitle

		subroutine ReDraw()
		  !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?ReDraw@Classless@@YAXXZ'::ReDraw
		end subroutine ReDraw

		integer function SimpleMsgLoop()
          !DEC$ATTRIBUTES DLLIMPORT,ALIAS:'?SimpleMsgLoop@NsCChart@@YAHXZ'::SimpleMsgLoop
		end function SimpleMsgLoop
    end interface 

	print *, 'Hello World'

	print *, "创建弹出窗口..."
	call CreatePopupChartWndGlobal(0, 0, LOC("窗口标题"C), 50, 50, 600, 450)

	print *, "设置绘图类型..."
	call SetType(6)

	print *, "设置标题"
	call SetTitle(LOC("Fortran等高线云图"C))

	print *, "设置场函数..."
	call SetFieldFcn(MyFieldFcn)

	print *, "设置绘图数据范围"
	call SetPlotRange(-3.0, 3.0, -2.0, 2.0)

	print *, "重绘..."
	call ReDraw()

	print *, "建立消息循环..."
	call SimpleMsgLoop()

	end program LessonA35

	double precision function MyFieldFcn(x, y)
	  !DEC$ATTRIBUTES VALUE::x, y
	  double precision x, y
	  MyFieldFcn = 1.0/(x*x+y*y+1.0)
	  return
	end function MyFieldFcn	
	


