Silverfrost Forums

Welcome to our forums

Keeping user from clicking other buttons while opening file?

2 Sep 2010 4:47 #6883

I've written a program using Windows in FTN95 (WINAPP, and using 'include <windows.ins>' ). In it, the user can click a button whose callback function then calls the normal Windows 'open file' routine, that puts up a box letting the user see the files in a directory, pick one of them, and then open it by clicking the box's 'Open' button. It works correctly, and all is well.

Except... in the original calling program, that program had earlier put up several other functions with buttons that do other things. And I found by accident, that if the user first clicks the button to put up the open-file box, and then one of the buttons on the original window that do other things, the program gets messed up for various reasons.

Is there a way that, once the user clicks the button to bring up the open-file box, he can't do anything else besides the functions available in that box? Then, once he's navigated around, selected the file he wants, and clicked 'open' (or clicked the X in the upper right corner to cancel the box), and the box vanishes, afterward the functions in the original window now work normally again?

Hope that's clear. Sometimes my descriptions aren't. 😦

2 Sep 2010 8:07 #6885

One way would be to set a global variable before opening the dialog. When this variable is set, exit the problem callback(s) without doing any work.

2 Sep 2010 9:00 #6888

Quoted from PaulLaidler One way would be to set a global variable before opening the dialog. When this variable is set, exit the problem callback(s) without doing any work.

I'm sorry, Paul, I don't understand what this means. Guess I'm still a relative newbie to Salford and FTN95, I learn mostly by tripping over things.

1.) What is a 'global variable', and how do you set it? I assume it's not just any variable in blank Common. 2.) Would such a variable cause the original window to freeze until the file-open box is finished? 3.) Can you give me an example?

Sorry for the hassle, Little-Acorn

3 Sep 2010 7:06 #6893
  1. Yes I mean a variable in a common block for example.
  2. By 'set' I mean give it a value such as 1. Zero when the dialog has closed. The original window should freeze anyway. Let me know if it doesn't.

If the global variable is called Flag then in the main program

Flag = 1 open and close the dialog Flag = 0

In the callbacks....

integer function cb() common .... cb = 2 if(Flag == 1) return ....

5 Sep 2010 12:25 #6900

Paul's answer is, as usual, complete and simple. However, my suggestion will get you a much more 'standard' application.

If you have any menu item or toolbar buttons that you can't select (because it will mess up the sequence of operations you want to impose on the user) then what you should do is to 'grey-out' (or 'disable') those menu items and toolbar buttons. So, when your program starts, you can select 'Open' or 'New' in the file menu, or the corresponding toolbar buttons, but you shouldn't be able to select 'Save'. Following a successful 'Open', you may need to disable 'Open' and 'New', but to enable 'Save' and 'Save As' (for example). This basically means keeping all the grey codes (which are integers) in a COMMON block and at the end of every call-back function, go through the list setting or unsetting the codes before you RETURN - COMMON is the old-fashioned Fortran-77 way (I use it), you may prefer to use variables with global scope.

Some controls update instantly when you change the grey code,others need to be specifically updated.

The grey-out (disable) mechanism prevents the user from selecting any option you don't want him to select.

Eddie

Please login to reply.