PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Petrus Vorster on July 05, 2015, 05:23:48 PM

Title: Tab control & create form event
Post by: Petrus Vorster on July 05, 2015, 05:23:48 PM
I have several forms in numerous tabs.
When the forms open the first time i have placed a procedure under the WM_create to fill a combo or a listview.
I want the user to make changes in another tab (EG settings) and when the other tab is opened, it must reload like the first time and run the procedure again as if it is the first time.
Since the forms does not "unload" again, where does one place startup procedures in a TAB-child form?

-Peter
Title: Re: Tab control & create form event
Post by: Nathan Durland on July 05, 2015, 08:36:04 PM
I usually define a user-defined message.  %WM_USER is predefined in the Win32 API as the beginning of a block of message values that our program can define and post to controls.  An old, but relevant post here:  https://powerbasic.com/support/pbforums/showthread.php?t=8096 (https://powerbasic.com/support/pbforums/showthread.php?t=8096).

Something Like So:

%WM_USER_FORMSTART = %WM_USER + 1

Function FormFill() As Long

  Ff_Control_Settext HWND_FORM1_TEXT1, "Hello There"

End Function

'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         Byval UserData As Long _  ' optional user defined Long value
                         ) As Long

    Local xLoop      As Long

    Postmessage HWND_FORM1, %WM_USER+Formstart, 0, 0
   

End Function

'--------------------------------------------------------------------------------
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


  If wMsg = %WM_USER_FORMSTART Then
    FormFill
  End If


End Function


'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long

  Postmessage HWND_FORM1, %WM_USER_FORMSTART, 0, 0

End Function



Hope this helps






Title: Re: Tab control & create form event
Post by: Petrus Vorster on July 08, 2015, 03:05:56 PM
Thanks Nathan!
I am going to try this JUST NOW!