PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: John Messingham on October 08, 2007, 02:51:46 PM

Title: Passing Data to a tab control form.
Post by: John Messingham on October 08, 2007, 02:51:46 PM
Hi All,

I have a form with a tab control and one of the tabs has a grid. I need to pass a parameter from the main form to the tab child form in order to populate the grid.

What is the best way o do this please?
Title: Re: Passing Data to a tab control form.
Post by: TechSupport on October 08, 2007, 03:04:00 PM
How about using SendMessage to send a user defined message to the TabControl form?


%MSG_POPULATE_GRID = %WM_USER + 100   


' In the main form, send the message to the TabControl child form using wParam and lParam values that
' make sense based on what you want to achieve.
SendMessage HWND_FRMTABCHILD, %MSG_POPULATE_GRID, 1234, 0    ' e.g. 1234 could be a customer ID

' In the CUSTOM message handler for the TabControl child form intercept and act on the message
Function FRMTABCHILD_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 %MSG_POPULATE_GRID
         ' wParam holds the customer id
   End Select

End Function



Title: Re: Passing Data to a tab control form.
Post by: TechSupport on October 08, 2007, 03:05:21 PM
... if this must occur when your Form is initially loading then it would be better to use PostMessage instead of SendMessage.
Title: Re: Passing Data to a tab control form.
Post by: John Messingham on October 08, 2007, 04:51:49 PM
Cheers Paul.

All sorted.