Make your own free website on Tripod.com

6. Using generated FORTRAN codes and files with Compaq Visual Fortran 6.x.

Let consider this question using the project #10 "MoreControlsAndWallpaper" from
"5. Default projects ( templates ) included into GUI Generator package.". If you selected
"Generate FORTRAN Program" in "File" panel of VFC GUI Generator 3.01, then you'll
see the next files in \GUI Generator\FORTRAN PROGRAMS\MoreControlsAndWallpaper\ :

You have here all necessary files for CVF 6.x project creation. To create this project, you
must:
1. Create new empty project ( "Files" ->"New"->"Project"->"Fortran Windows Application"->...
    ...empty application... );
2. Insert next files into the created project:
    VFC_ButtonDefinedAction.f90
    VFC_User_On_Exit.f90
    VFC_User_On_Init.f90
    MSImg32.lib
    VFC.lib
    MoreControlsAndWallpaper.rc
3. Select type of the project as "Release";
4. Select "Project"->"Settings" and define application properties as "multithreaded dll"
    ( use "Fortran" and "C++" tabs for this );
5. Build exe-file...

After these standard steps you'll have some "executable template", which can be modified
now with respect to your needs.


First interesting subroutine - VFC_User_On_Init.f90:
!---------------------------------------------------------------------------------------
subroutine VFC_User_OnInit(hInstance,ireturn)
integer*4 hInstance,ireturn
!------------------------------------------------------------------
!
! Purpose : It allows user to perform some preliminary operations
!           ( open file(s) with initial data, read data etc.    )
!
! Parameters : hInstance - handle of application
!                      ireturn      - error code
!                                         = 0 - no error(s)
!                                         = 1 - error(s) appeared
!
!------------------------------------------------------------------
    ireturn = 0
    !------------------------------------------------
    !       Put your code below, please
    !------------------------------------------------
return
end
Its purpose is clear from the comments inside...

Second interesting subroutine - VFC_ButtonDefinedAction.f90
subroutine ButtonDefinedAction(WndNumber,ButtonNumber,ButtonHandle)
 integer*4 WndNumber,ButtonNumber,ButtonHandle
 !-------------------------------------------------------------------
 ! Purpose - handler for created button(s)
 ! Parameters:
 !             WndNumber    - current window number
 !             ButtonNumber - current button number
 !             ButtonHandle - current button handle
 !-------------------------------------------------------------------
    select case(WndNumber)
        case(1)
            select case(ButtonNumber)
                case(1)
                !--------------------------------------------------------
                !  Put here your handler/subroutine for button #1
                !  Button capture:
                !  <<Start>>
                !  Button description:
                !  == Default window button. Purpose - start calculations...
                !  == 
                !  == 
                !
                !--------------------------------------------------------
                case(4)
                !--------------------------------------------------------
                !  Put here your handler/subroutine for button #4
                !  Button capture:
                !  <<Exit>>
                !  Button description:
                !  == Exit Button
                !  == 
                !  == 
                !
                !  Remember, please, that this button will close
                !  application. But you can't do this manualy
                !--------------------------------------------------------
            end select
    end select
 return
 end
 !===================================================================
 ! Also you have static control(s) in your program.
 ! 
 !------------------------------------------------
 !  Window #1 Static #1
 !  Static control capture:
 !  <<Value of  A =>>
 !  Static control description:
 !  == Parameter A
 !  == 
 !  == 
 !
 !  You can use the next functions for control management :
 !      call SetVFCStaticCaption(1,1,text_string)
 !      call ClearVFCStaticCaption(1,1)
 !      call WriteRealToVFCStaticAsFormatted(1,1,value,fmt_string)
 !      call WriteRealToVFCStaticUnFormatted(1,1,value)
 !      call WriteDRealToVFCStaticAsFormatted(1,1,value,fmt_string)
 !      call WriteDRealToVFCStaticUnFormatted(1,1,value)
 !      call WriteIntegerToVFCStaticAsFormatted(1,1,value,fmt_string)
 !      call WriteIntegerToVFCStaticUnFormatted(1,1,value)
 !------------------------------------------------
 !  Window #1 Static #2
 !  Static control capture:
 !  <<>>
 !  Static control description:
 !  == Parameter A Value
 !  == 
 !  == 
 !
 !  You can use the next functions for control management :
 !      call SetVFCStaticCaption(1,2,text_string)
 !      call ClearVFCStaticCaption(1,2)
 !      call WriteRealToVFCStaticAsFormatted(1,2,value,fmt_string)
 !      call WriteRealToVFCStaticUnFormatted(1,2,value)
 !      call WriteDRealToVFCStaticAsFormatted(1,2,value,fmt_string)
 !      call WriteDRealToVFCStaticUnFormatted(1,2,value)
 !      call WriteIntegerToVFCStaticAsFormatted(1,2,value,fmt_string)
 !      call WriteIntegerToVFCStaticUnFormatted(1,2,value)
 !------------------------------------------------
 !  Window #1 Static #3
 !  Static control capture:
 !  <<Value of  B =>>
 !  Static control description:
 !  == Parameter B
 !  == 
 !  == 
 !
 !  You can use the next functions for control management :
 !      call SetVFCStaticCaption(1,3,text_string)
 !      call ClearVFCStaticCaption(1,3)
 !      call WriteRealToVFCStaticAsFormatted(1,3,value,fmt_string)
 !      call WriteRealToVFCStaticUnFormatted(1,3,value)
 !      call WriteDRealToVFCStaticAsFormatted(1,3,value,fmt_string)
 !      call WriteDRealToVFCStaticUnFormatted(1,3,value)
 !      call WriteIntegerToVFCStaticAsFormatted(1,3,value,fmt_string)
 !      call WriteIntegerToVFCStaticUnFormatted(1,3,value)
 !------------------------------------------------
 !  Window #1 Static #4
 !  Static control capture:
 !  <<>>
 !  Static control description:
 !  == Parameter  B  Value
 !  == 
 !  == 
 !
 !  You can use the next functions for control management :
 !      call SetVFCStaticCaption(1,4,text_string)
 !      call ClearVFCStaticCaption(1,4)
 !      call WriteRealToVFCStaticAsFormatted(1,4,value,fmt_string)
 !      call WriteRealToVFCStaticUnFormatted(1,4,value)
 !      call WriteDRealToVFCStaticAsFormatted(1,4,value,fmt_string)
 !      call WriteDRealToVFCStaticUnFormatted(1,4,value)
 !      call WriteIntegerToVFCStaticAsFormatted(1,4,value,fmt_string)
 !      call WriteIntegerToVFCStaticUnFormatted(1,4,value)
 !
!===================================================================

You could see, that the purpose of this subroutine - organize the interaction between control elements on
window and user's numerical algorithm. For users experienced in VB/VBA programming, it'll be very easy
to start working with the subroutine organized by such way. The only things you must do - create your own
subroutines and call them in the respective place of the provided handler.
Also, you can see here instructions how to use other "passive" elements ( now static controls only ) for
information output.

Third interesting subroutine -  VFC_User_On_Exit.f90.

!---------------------------------------------------------------------------------------
 
subroutine VFC_User_OnExit(ireturn)
 
integer*4 ireturn
 
!------------------------------------------------------------------
 !
 ! Purpose : It allows user to perform some operations on exit
 !                ( close file(s) with data etc. )
 !
 ! Parameters : ireturn   - error code
 !                                     = 0 - no error(s)
 !                                     = 1 - error(s) appeared
 !
 !------------------------------------------------------------------
    
ireturn = 0
 
    !------------------------------------------------
     !       Put your code below, please
     !------------------------------------------------
 
return
 end
 

This subroutine allows you to accomplish the work with resources opened for the work with your
numerical algorithms...


Back