PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Patrick Harvey on August 07, 2005, 01:21:17 PM

Title: How can I run some code whent he program starts?
Post by: Patrick Harvey on August 07, 2005, 01:21:17 PM
Hello, in VB you can enter in some code to run under form/load that will start running when the program first loads....  is there a way to do this with pb/firefly...?

Patrick
Title: How can I run some code whent he program starts?
Post by: TechSupport on August 07, 2005, 02:52:06 PM
Look on the tab called "Explorer" in the "FireFly Workspace" window. There is a branch in the tree there called "Special Functions". Add your code to the function called "FF_WinMain".
Title: Thanks! it worked great!
Post by: Patrick Harvey on August 07, 2005, 05:01:32 PM
Thanks!  it worked great!
Title: How can I run some code whent he program starts?
Post by: Anonymous on August 08, 2005, 03:48:40 PM
Slightly different...

Where should you put code you want to start -after- the window has been displayed?

Thanks!

John
Title: How can I run some code whent he program starts?
Post by: TechSupport on August 08, 2005, 04:05:35 PM
Post a user defined message during the WM_SHOWWINDOW message. This message fires just before the window is shown. By using a PostMessage we ensure that the window gets shown (SendMessage would wait until the user message returns... we don't want that.).



%USRMSG_WINDOWISDISPLAYED = %WM_USER + 1000

'------------------------------------------------------------------------------------------------------------------------
Function FORM1_CUSTOM ( _
                     hWndForm      As Dword, _  ' handle of Form
                     wMsg          As Long,  _  ' type of message
                     wParam        As Dword, _  ' first message parameter
                     lParam        As Long   _  ' second message parameter
                     ) As Long


  Select Case wMsg
     Case %WM_SHOWWINDOW
        If wParam = %TRUE Then  'window is about to be shown
           PostMessage hWndForm, %USRMSG_WINDOWISDISPLAYED, 0, 0
           Exit Function
        End If
       
     Case %USRMSG_WINDOWISDISPLAYED
        ' the window should now be visible... do whatever you like.      
        'MsgBox "user message has fired"
     
  End Select

End Function