End program from modal form

Started by Mark Strickland, July 13, 2007, 03:56:10 PM

Previous topic - Next topic

Mark Strickland

I am building a wizard where there is a main screen then subsequent NEXT/NEXT/etc screens.  I want to make each screen a stand alone form to encapsulate the logic for that step in a single form.  I pass TOP/LEFT position in globals as well as CALLING FORM HANDLE so moving back and forward is fairly easy.  Moving forward I simply HIDE the current form and open the next one as modal so only the new form appears.  If I want to go PREVIOUS I destroy the current form and in the destroy event I SHOW the previous one.  Passing the position allows me to CREATE forms in the position of the previous one that just was HIDDEN.

MY QUESTION

If I am on some form beyond the first how can I kill the whole application if I want to CANCEL?

If I simply just force FF to close the first form from the 2nd/3rd/etc form it disappears from the screen but it leaves the process running.





TechSupport

Hi Mark,

Can you show me how you are initiating the close from the 2nd or 3rd form? Example: Say you are on the 3rd form, more than likely, you are using FF_CloseForm( HWND_FRMMAIN) on the 3rd form. Sure, that will close the main form but it will leave the 3rd form running (because that form has its own message loop because it is modal).

Maybe a good approach would be the following just before you want to end the program from the 3rd form:

- Use PostMessage (e.g. %MSG_USER_QUIT = %WM_USER + 100) to post a user defined message to HWND_FRMMAIN (which will be acted on in the CUSTOM handler).

- Immediately call FF_CloseForm(HWND_FORM3)

- In the CUSTOM handler for FRMMAIN, catch the user message:
Select Case wMsg
   Case %MSG_USER_QUIT
       FF_CloseForm HWND_FRMMAIN
End Select

That should work. I'm doing this off of the top of my head so please let me know if you are successful.


Mark Strickland

Paul,

As usual -- quick reply.

Yes you got it.  I need to cancel FORM3 that will close FORM2 THEN FORM1.  I will probably just put something in the CUSTOM function of each form to recognize the same message and they will all close independently.  Too bad the message must be posted form specific.

After a brief test I found that I have to do a SENDMESSAGE -- POSTMESSAGE is never received (verified with my little console debug module that opens and prints to a console screen when called) -- not sure why.

I am trying to build a template first.  The template will only have 2 forms.  MAIN and SECOND.  If you need more Wizard Steps just copy the SECOND form as many times as you need and then modify.  Most of the code is generic enough for NEXT and PREVIOUS that there is no hard code that must be fixed for the copied form.

When I get the template working I will post it on the FF Source Code section and some instructions how to create extra Wizard Pages.

I suppose I could do this on a single form and simply disable one set of controls and enable another but that seemed very messy.

Thanks for the help.

Mark

TechSupport

If it were me... I would create the wizard by using one parent form as a "container" and then create "child forms" to display the wizard pages. Simply set the WS_CHILD style of the child forms. This is how the child pages of the tab control's display. This is also how the various child pages of FireFly's own Environment Options works. You simply need to show/hide the child forms as needed. They are non-modal so you never run into the problem that you're experiencing. I swear that I posted an example of that once..... let me check my stuff and see if I can find it.


Mark Strickland

Paul,

That technique does make more sense.  I "borrowed" some of your code and got it working.

I had never used any child forms and that makes screen "overlays" very easy.

Thanks,

Mark

Paul D. Elliott

Paul,

Sorry to jump in but I'm confused. You had posted this zip back when I asked about
"tab controls with no header" but I never got around to actually using it. Today I thought
I'd try in another of my programs. I want to put up another form over top of the main one
when the user clicks a button. the main form has 2 other buttons and several entry fields.
the new form has 5 buttons and several other entry fields. one of the buttons on the 2nd
form returns control back to the main form. Your sample seems simple to follow but allowed
bleed-thru of the fields/buttons from the main form ( meaning that if I kept hitting tab
then I went thru all the fields/buttons on both forms ).

I think I'm going to have to sit down and rethink what I want to happen.
Would I be better off having no buttons/fields on the main form and moving all entry fields
to the child forms? In the past when I needed something like this, I took the easy way out
and put a tab-control on the form that filled the whole form and went from there.

Sorry if this doesn't make much sense as it's been a long day. I'll sleep on it tonite and
check back in the morning.

TechSupport

I think that the best approach is to put all of your controls on separate child forms as needed. In your situation, the controls on the main form will "bleed through" when tabbed to because they are still visible (albeit another form is over top of it). You would have to FF_Control_Show %SW_HIDE each of those controls if you did not want that to happen. If you have many controls on your main form then you run into the problem of having to hide/show many controls. If they are on a separate child form then you simply need to show/hide the form itself. I use the child form show/hide effect a lot and it has always worked well.

Paul D. Elliott

#8
Ok, Thanks. That fixed it.

A minor annoyance still pops its head up. I added a new form and made it the start-up form
and made other changes to the other forms. When I told it to compile, FF saved my old changed
forms in the FF installation directory and not in the project directory that I was working in.
Matter of fact it saved my 2 old forms in the FF directory before it asked where to save the
new form and the default was the FF installation directory. They are on seperate drives.
This will be fixed in FF v3, right?   ???

TechSupport

Quote from: Paul D. Elliott on July 18, 2007, 09:55:45 AM
This will be fixed in FF v3, right?   ???
Definately. The form save folder for FF3 is sort of hard wired into FF# (much like Visual Studio, etc...). This makes it a hell of a lot easier to deal with project management and irritations like you describe.