How can I run some code whent he program starts?

Started by Patrick Harvey, August 07, 2005, 01:21:17 PM

Previous topic - Next topic

Patrick Harvey

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

TechSupport

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".

Patrick Harvey


Anonymous

Slightly different...

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

Thanks!

John

TechSupport

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