好文档 - 专业文书写作范文服务资料分享网站

Intel Visual Fortran窗口程序设计 - 图文

天下 分享 时间: 加入收藏 我要投稿 点赞

个数之后的项目列表被自动删除。 下面是一个综合示例。用户填入基本资料后单击“确定”按钮,此时用户的资料被自动汇总在“个人简介”编组框中(程序中用更新静态文本框内容放入方法实现)。程序创建过程为: 首先创建资源文件。打开对话框编辑器,按照图5.17所示在对话框上创建各种控件。 图5.16 对话框运行图 需要注意两点:一是将下拉列表框的有效列表范围绘制足够大;二是在图5.17中夹点的范围内需要创建静态文本框。 除了一些可以忽略的控件ID(如两个编组框和显示描述性文字的静态文本框)之外,按照从左到右、从上到下的顺序,其它控件的ID分别为:IDC_EDIT1、IDC_RADIO1、IDC_RADIO2、IDC_COMBO1、IDC_COMBO2、IDC_COMBO3和IDC_STATIC1。至于各个控件的代号,请务必保证和资源编辑器生成的代号相同。 其次,编写程序代码驱动对话框及其控件。将下面的代码加入项目工程: #001 ! Example 5-4 #002 module CONTROLS #003 integer, parameter :: IDD_DIALOG1 = 101 #004 integer, parameter :: IDC_EDIT1 = 1000 !姓名 #005 integer, parameter :: IDC_RADIO1 = 1001 !男 #006 integer, parameter :: IDC_RADIO2 = 1002 !女 #007 integer, parameter :: IDC_COMBO1 = 1004 !年 #008 integer, parameter :: IDC_COMBO2 = 1005 !月 #009 integer, parameter :: IDC_COMBO3 = 1007 !日 #010 integer, parameter :: IDC_STATIC1 = 1009 !简介 #011 end module CONTROLS #012 #013 program main #014 USE IFQWIN #015 implicit none #016 integer( kind=4 ) :: results #017 logical(kind=4)::res #018 type (qwinfo) :: winfo #019 type (windowconfig) :: wc #020 - 46 - #021 winfo%type = QWIN$MAX #022 res = GETWINDOWCONFIG(wc) #023 ! 最大化子窗口 #024 results = SETWSIZEQQ (0, winfo) #025 results = SETEXITQQ (QWIN$EXITPERSIST) #026 do while (.true.) #027 enddo #028 end program main #029 #030 LOGICAL(4) FUNCTION INITIALSETTINGS( ) #031 USE IFQWIN #032 implicit none #033 integer( kind=4 ) :: results #034 logical(kind=4)::res #035 type (qwinfo) :: winfo #036 external:: Dialoginput #037 #038 winfo%w = 800 #039 winfo%h = 600 #040 winfo%type = QWIN$SET #041 results = SetWSizeQQ( QWIN$FRAMEWINDOW, winfo ) #042 res = appendmenuqq(1, $MENUENABLED, '文件'C, NUL) #043 res = appendmenuqq(1, $MENUENABLED, '个人资料...'C,Dialoginput) #044 INITIALSETTINGS= .true. #045 return #046 END FUNCTION INITIALSETTINGS #047 #048 subroutine Dialoginput(checked) #049 USE IFWIN #050 USE IFLOGM #051 USE CONTROLS #052 implicit none #053 integer( kind=4 )::results #054 logical( kind=4 )::retlog,checked #055 type( dialog )::datadlg #056 external:: dialogbasedApply #057 #058 ! 初始化对话框 #059 retlog = DLGINIT(IDD_DIALOG1, datadlg) #060 ! 初始化第一个下拉列表 #061 retlog = DlgSet ( datadlg, IDC_COMBO1, 3, DLG_NUMITEMS ) #062 retlog = DlgSet ( datadlg, IDC_COMBO1, \, 1 ) #063 retlog = DlgSet ( datadlg, IDC_COMBO1, \, 2 ) #064 retlog = DlgSet ( datadlg, IDC_COMBO1, \, 3 ) #065 ! 初始化第二个下拉列表 #066 retlog = DlgSet ( datadlg, IDC_COMBO2, 3, DLG_NUMITEMS ) #067 retlog = DlgSet ( datadlg, IDC_COMBO2, \, 1 ) #068 retlog = DlgSet ( datadlg, IDC_COMBO2, \, 2 ) #069 retlog = DlgSet ( datadlg, IDC_COMBO2, \, 3 ) #070 ! 初始化第三个下拉列表 #071 retlog = DlgSet ( datadlg, IDC_COMBO3, 3, DLG_NUMITEMS ) #072 retlog = DlgSet ( datadlg, IDC_COMBO3, \, 1 ) #073 retlog = DlgSet ( datadlg, IDC_COMBO3, \, 2 ) #074 retlog = DlgSet ( datadlg, IDC_COMBO3, \, 3 ) #075 ! 设置“确定”按钮的回调子程序 #076 retlog = DlgSetSub(datadlg, IDOK, dialogbasedApply) #077 results = DLGMODAL (datadlg) #078 call DLGUNINIT (datadlg) - 47 - #079 end subroutine Dialoginput #080 #081 subroutine dialogbasedApply( dlg, id, callbacktype ) #082 !DEC$ ATTRIBUTES DEFAULT :: dialogbasedApply #083 USE IFLOGM #084 USE CONTROLS #085 implicit none #086 type(dialog) dlg #087 logical*4 results,pushed_state #088 integer(kind=4):: id, callbacktype #089 character(len=10)::name,sex,year,month,day #090 character(len=100)::text1 #091 #092 sex = \女\#093 ! 取出姓名,提取性别单选钮 #094 results = DlgGet(dlg,IDC_EDIT1,name) #095 results = DlgGet(dlg,IDC_RADIO1,pushed_state) #096 if(pushed_state == .true.)then #097 sex = \男\#098 endif #099 ! 读取下拉列表的当前值 #100 results = DLGGET (dlg, IDC_COMBO1, year) #101 results = DLGGET (dlg, IDC_COMBO2, month) #102 results = DLGGET (dlg, IDC_COMBO3, day) #103 ! 将所有的资料汇总 #104 write(text1,*)\我叫\,trim(adjustl(name)), & #105 \,\,trim(adjustl(sex)),\,出生于\, & #106 trim(adjustl(year)),\年\,trim(adjustl(month)), & #107 \月\,trim(adjustl(day)),\日。\#108 ! 改写静态文本框的内容 #109 results = DlgSet(dlg,IDC_STATIC1,text1) #110 end subroutine dialogbasedApply 运行程序,对话框界面如图5.17所示。 图5.17 Example 5-4运行结果 ■ 滚动条 为了在有限的范围内容纳更多的内容,经常用到滚动条。滚动条通过中间的滑块来确定位置,所以滑块有一个可滑动的范围,这个范围的确定方法为: USE IFLOGM type ( dialog ) :: dlg - 48 - logical( kind=4 ):: retlog retlog = DLGSET (dlg, IDC_SCROLLBAR1, 0, DLG_RANGEMIN) retlog = DLGSET (dlg, IDC_SCROLLBAR1, 200, DLG_RANGEMAX) 滚动条使用中,用户或者用鼠标单击两端的箭头实现中间滑块的滑动,这种情况下,滑块的步长为1;或者用鼠标单击滑块和箭头之间的空白区域实现滑块的滑动,这时可用下面的方法设置滑块的步长: USE IFLOGM type ( dialog ) :: dlg logical( kind=4 ):: retlog retlog = DLGSET (dlg, IDC_SCROLLBAR1, 20, DLG_BIGSTEP) 如果需要设置或者获取滚动条的当前位置,则应借助于函数DLGSET 和DLGGET来实现: retlog = DLGSET (dlg, IDC_SCROLLBAR1, 50, DLG_POSITION) retlog = DLGGET (dlg, IDC_SCROLLBAR1, slide_position, DLG_POSITION) ■ 进度条 如果程序中有较长时间的等待,建议使用进度条。进度条仅仅是输出控件,所以本身不支持任何的回调函数。为了使用进度条,程序设计者只需指定进度条的有效范围和位置。具体方法为: USE IFLOGM type ( dialog ) :: dlg logical( kind=4 ):: retlog retlog = DLGSET (dlg, IDC_PROGRESS1, 0, DLG_RANGEMIN) ! 最小范围 retlog = DLGSET (dlg, IDC_PROGRESS1, 200, DLG_RANGEMAX) ! 最大范围 retlog = DLGSET (dlg, IDC_PROGRESS1, 50, DLG_POSITION) ! 设定位置 ■ 滑动条 可通过滑动改变或者调节数值的大小。跟前面的两个控件很像,程序设计者首先应指定滑动条的范围和当前位置: USE IFLOGM type ( dialog ) :: dlg logical( kind=4 ):: retlog retlog = DLGSET (dlg, IDC_SLIDER1, 0, DLG_RANGEMIN) ! 最小范围 retlog = DLGSET (dlg, IDC_SLIDER1, 200, DLG_RANGEMAX) ! 最大范围 retlog = DLGSET (dlg, IDC_SLIDER1, 50, DLG_POSITION) ! 设定位置 retlog = DLGGET (dlg, IDC_SLIDER1, slide_position, DLG_POSITION) ! 读取位置 同时,当键盘方向键按下时,这样设置滑块的步长: retlog = DLGSET (dlg, IDC_SLIDER1, 10, DLG_SMALLSTEP) 或者响应“PAGE UP”、“PAGE DOWN”以及当鼠标单击滑道时的步长: retlog = DLGSET (dlg, IDC_SLIDER1, 10, DLG_BIGSTEP) 或设置滑动条上的刻度间距: retlog = DLGSET (dlg, IDC_SLIDER1, 20, DLG_TICKFREQ) - 49 - 下面的示例给出了这三种控件的用法。程序中,当用户移动滚动条或滑动条其中之一时,其它两个控件的位置随之改变,达到同步互动的效果。项目创建过程为: 首先创建对话框。打开资源编辑器,按照图5.18所示创建对话框且绘制控件。创建完成后单击“保存”按钮完成该资源文件的保存。 图5.18 对话框资源文件 其次,编写程序及对话框驱动程序。将下面的代码添加到工程: #001 ! Example 5-5 #002 module CONTROLS #003 integer, parameter :: IDD_DIALOG1 = 101 #004 integer, parameter :: IDC_SCROLLBAR1 = 1000 #005 integer, parameter :: IDC_SLIDER1 = 1001 #006 integer, parameter :: IDC_PROGRESS1 = 1002 #007 end module CONTROLS #008 #009 program main #010 USE IFQWIN #011 implicit none #012 integer( kind=4 ) :: results #013 logical(kind=4)::res #014 type (qwinfo) :: winfo #015 type (windowconfig) :: wc #016 #017 winfo%type = QWIN$MAX #018 res = GETWINDOWCONFIG(wc) #019 ! 最大化子窗口 #020 results = SETWSIZEQQ (0, winfo) #021 results = SETEXITQQ (QWIN$EXITPERSIST) #022 do while (.true.) #023 enddo #024 end program main #025 #026 LOGICAL(4) FUNCTION INITIALSETTINGS( ) #027 USE IFQWIN #028 implicit none #029 integer( kind=4 ) :: results #030 logical(kind=4)::res #031 type (qwinfo) :: winfo #032 external:: Dialoginput #033 #034 winfo%w = 800 #035 winfo%h = 600 - 50 -

Intel Visual Fortran窗口程序设计 - 图文

个数之后的项目列表被自动删除。下面是一个综合示例。用户填入基本资料后单击“确定”按钮,此时用户的资料被自动汇总在“个人简介”编组框中(程序中用更新静态文本框内容放入方法实现)。程序创建过程为:首先创建资源文件。打开对话框编辑器,按照图5.17所示在对话框上创建各种控件。图5.16对话框运行图需要注意两点:一是将下拉列表框的有效列表范围绘制足够大;二是在图5.17中夹点的范围内需要
推荐度:
点击下载文档文档为doc格式
3hbyy7eayt5nd0e7mk29
领取福利

微信扫码领取福利

微信扫码分享