Silverfrost Forums

Welcome to our forums

winio@: Call back function response

6 Aug 2014 11:48 #14407

Hi

I have tried the following small function to display simple messages and to take the response based on [Ok] & [Cancel] Button. This works fine for pressing [Ok] button, but for [Cancel] button, it does not call the call back function. I have tried with ^bt[Cancel] also, but it is not call the func()

Here is the code

module test 

 contains 

 subroutine display_msg(title,message) 

   integer res, winio@ 
   character(len=*):: title, message 
   common res 
   res = winio@('%ca['//title//']&') 
   res = winio@('%il&',1,2147483647) 
   res = winio@(message//'%ta%^bt[OK]%ta%bt[Cancel]',func) 
   !res = winio@('%ta%bt[OK]%ta%bt[Cancel]',func) 
   print*, res 

 end subroutine display_msg 

 integer function func() 
 func = (-1) 
 print*, 'I am in function' 
 print*, func 
 print*, 'control returns to main' 
 end function 

 end module test 


 winapp 
 program main 
 use test 
 !external display_msg 
 character (len=50) :: title, message 
 integer :: res 
 common res 
 title='Format Error' 
 message ='Bus Data is a problem..Program stopping' 
 call display_msg(title,message) 
 if (res == 1) print*, 'Ok is pressed' 
 if (res == 2 ) print*, 'Cancel is pressed' 
 end program 

Can I request your quick help to debug this. I have tried all possibilities using EXTERNAL.. But not helping out for Cancel button. I may be doing something wrong. If you can help, that will be great.

The idea here is to have a generic routine to display the messages. So that I can call it as subroutine in my program. Suitable other ways of coding this are most welcome.

Thanks

6 Aug 2014 11:54 #14408

I have one more query as well. I like to display small icon showing the 'information' or 'error' symbol in the message display window. How do I do it

Pls. help

Thanks

6 Aug 2014 6:22 #14411

Here is your program suitably modified:

module test 
 contains 
 subroutine display_msg(title,message) 
   integer res, winio@ 
   character(len=*):: title, message 
   common res 
   res = winio@('%ca['//title//']&') 
   res = winio@('%si!'//message//'%ta%^bt[OK]%ta%^bt[Cancel]',func,func) 
   print*, res 
 end subroutine display_msg 

 integer function func() 
 func = (-1) 
 print*, 'I am in function' 
 print*, func 
 print*, 'control returns to main' 
 end function 

 end module test 

 winapp 
 program main 
 use test 
  character (len=50) :: title, message 
 integer :: res 
 common res 
 title='Format Error' 
 message ='Bus Data is a problem..Program stopping' 
 call display_msg(title,message) 
 if (res == 1) print*, 'Ok is pressed' 
 if (res == 2 ) print*, 'Cancel is pressed' 
 end program

RESOURCES
1  24 default.manifest

The standard info icon is generated with %si!. Both %bt buttons need the ^ modifier if you want a callback function and because there are two of them you need to specify 'func' twice. The RESOURCES section gives you a more modern looking style to your windows and buttons.

Read the appropriate sections in the online help There are dozens of format codes. There is also the 'enhancements' file that you will find in the DOC folder within FTN95.

Eddie

7 Aug 2014 12:28 #14414

Thank you Eddie for your suggestions here and to my other post in ClearWin+. I get the details. THanks a lot.

7 Aug 2014 12:31 #14415

Hi Eddie

But how to make the reference in the project for RESOURCES section

 RESOURCES 
 1  24 default.manifest

Thanks

7 Aug 2014 9:35 (Edited: 7 Aug 2014 5:56) #14417

There is no reference: this is a special feature of FTN95.

You can list all your resources in a resources section, OR you can put them in a separate file, typically with the extension .rc and compile that separately with SRC to resource compiler which generates an object file (type .obj) which you can link to the .obj files generated from Fortran, using SLINK.

However, for short resources lists, you can just put a RESOURCES section at the end of your Fortran code like I did.

Most of the resources things are straightforward, for example, some of mine (out of lists of sometimes hundreds!)

      PRINTER          ICON    'Printer.ICO'
      HOLMES          CURSOR   'Magnify.cur'
      ACCEPTB         BITMAP   'ACCEPT_BUTTON.BMP'
      CANCELB         BITMAP   'CANCEL_BUTTON.BMP'

This makes PRINTER the local name for an icon file named Printer.ico in my computer, and so on.

As for 1 24 default.manifest, this is to this day a bit of a mystery. However, a 'manifest' is a description of the style or theme of windows, and as far as I am aware, from Windows XP onwards the look of WIndows has been differentiated from the standard Windows 05 appearance by a manifest - this means that you can get the 'classic' appearance very simply if you want to.

Until you are ready to change cursors in your program, there is no point in having cursor resources, and so on for icons and bitmaps. But there is always some point in the manifest setting as it makes your program look modern.

Eddie

7 Aug 2014 5:37 #14421

Hi Edie Many thanks for your detailed explanation on the RESOURCES. I am sure you have been a Master in this. Thanks a lot.

Let me try all these Resources. Can I not use the FTN95 Express Visual studio to compile the RC files. Or should I have to go only with Command line compilers.. ?

Best Regards

7 Aug 2014 6:02 #14423

Hi Moorthy,

If I were you, I would stick to the simplest form of FTN95, which is to edit and compile your Fortran code in the integrated development environment called Plato.

Someone who has used FTN95 for a long time like me uses the strict command line form of FTN95, using my own editor, the MS DOS command prompt etc.

This can build you a Win-32 executable, with the full Windows interface called Clearwin+. Using Visual Studio (any version) gives you the facilities of .NET, but the chances are you don't need them at your stage.

Using Plato (which automatically invokes FTN95 and SRC and SLINK etc) is the method of use that conforms most closely to what is in the Help files, and should make it easier for you to find your own solutions in the documentation.

As for using Visual Studio to compile resources, then probably you need a different guru!

Eddie

7 Aug 2014 6:20 #14424

Hi Eddie

You are right. I had started with Plato only, it is simple and superb. I used my own editor, just compiled using Plato. It is excellent. But I could not do the single step debugging and viewing individual values while debugging at each step. This is the only reason which I moved to FTN95 Express VS. Otherwise, I am a big fan of Plato. Great

I have been using fortran since FortranIV from way back 1986 onwards. But the way how Silverfrost is repacked and given, is simply superb. :idea: the Big Salute to Silverfrost team. I am still exploring all of them.

Please login to reply.