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?
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
... if this must occur when your Form is initially loading then it would be better to use PostMessage instead of SendMessage.
Cheers Paul.
All sorted.