Startup Function rather than Startup Form?

Started by Art Araya, May 21, 2005, 02:59:32 PM

Previous topic - Next topic

Art Araya

Does FF allow for a startup function rather than a startup form?  I am looking for something like VB's Sub Main in FF.  I even notice that in the Project Properties there is a drop down list labelled 'Startup Form/Function'.  Does this mean that the capability that I am looking for is possible in FF?  If so, how do I do this?

TIA

Art

TechSupport

Place your startup code in the special message function "FF_WinMain" found in the Explorer in the FireFly Workspace.

Your defined startup form will not show until the code in FF_WinMain is completed.

Art Araya

Cool - that may work.  But I'd still rather not have any Startup form pre-defined.  Here's my scenario:  There are three situations I'd like to check for in this FF_WinMain function.

1) Is user registered?  If not, show Nag Screen
2) If user is registered, show Main window
3) If user has passed in command line parameters, run without showing any GUI.

So, you see - i desire to be able to specify either No Startup form, or Nag screen is startup form, or Main window is startup form.  Is this possible from within FF_WinMain?

TIA

Art

TechSupport

(The following is written on-line, but I hope it will work).

I think the best approach would be to set the WS_VISIBLE style of the main Form to FALSE.

In the main Form's WM_CREATE message handler, check if the user is registered. If not registered then PostMessage a user-defined message that will show the nag screen.

i.e.
(place at top of main Form)
%WM_USER_SHOWNAG = %WM_USER + 1000

In the WM_CREATE:
PostMessage hWndForm, %WM_USER_SHOWNAG, 0, 0

In the CUSTOM of the main Form:

If wMsg = %WM_USER_SHOWNAG Then
  frmNag_Show hWndForm, %TRUE
  'now show the main Form when the nag closes
  'set it to visible
  FF_CONTROL_SHOW hWndForm
End IF


If the person is registered and a command line was passed, then simply post a different message from your WM_CREATE to do the processing based on the COMMAND$ value.

The reason for PostMessages is that you need for the WM_CREATE message to finish processing or your message pump will not kick in. If you used SendMessage then the call would wait until it returned. With PostMessage the message will get processed after WM_CREATE completes.

Art Araya

Thanks for the detailed response Paul.  I'll give this a try but I think there may be a 'gotcha' in your approach.  What you are proposing is similar to something I had tried already.  I think that were it will fail is in the Command Line mode where no GUI is displayed but the form is in fact loaded.  I won't be able to shutdown the app...

There's no way to terminate a startup form from within its own WM_CREATE message.  But again, this is off of the top of my head.  I'll have to try your idea out.