Hi Paul
Tab Controls are a bit of a pain!! Anyway, I notice that if you want to switch page under program control, then there are no FF functions to do it! Anyway, I ripped out this code and bodged it into life! Can you add something like these to FF (only written properly :wink: )
Sub FF_TabControl_HideCurrent(ByVal hWndControl As Long)
Local TCITEM As TC_ITEM
Local FF_nResult As Long
' Hide the dialog on the tab control
FF_nResult = SendMessage(hWndControl, %TCM_GETCURSEL, 0, 0)
TCITEM.Mask = %TCIF_PARAM 'get the dialog's window
TabCtrl_GetItem hWndControl, FF_nResult, TCITEM
ShowWindow TCITEM.lParam, %SW_HIDE
End Sub
Sub FF_TabControl_SwitchToPage(ByVal hWndForm As Long, ByVal hWndControl As Long, ByVal nPage As Long)
Local TCITEM As TC_ITEM
Local FF_nResult As Long
Local FF_RECT As Rect
Local FF_TabRect As Rect
FF_TabControl_HideCurrent hWndControl
' Hide the dialog on the tab control
TCITEM.Mask = %TCIF_PARAM 'get the dialog's window
TabCtrl_GetItem hWndControl, nPage, TCITEM
'Show the needed dialog to display in the Tab Control
GetWindowRect hWndControl, FF_Rect
MapWindowPoints %HWND_DESKTOP, hWndForm, FF_Rect, 2
Call SendMessage(hWndControl, %TCM_GETITEMRECT, 0, VarPtr(FF_TabRect))
SetWindowPos TCITEM.lParam, %HWND_TOP, FF_Rect.nLeft+2, FF_Rect.nTop + FF_TabRect.nBottom + (GetSystemMetrics(%SM_CYBORDER) * 2) ,0,0, %SWP_NOZORDER Or %SWP_NOSIZE Or %SWP_SHOWWINDOW
Call SendMessage(hWndControl, %TCM_SETCURSEL, nPage, 0)
End Sub
Also, have a look at what happens when a TabControl is initially set to not visible! Is that fixable? :(
Cheers!
Quote from: Chris CullenTab Controls are a bit of a pain!!
It wouldn't be fun if they weren't painful. :lol:
Thanks for the code. I'll see if I can add them to the current list of FireFly Functions.
QuoteAlso, have a look at what happens when a TabControl is initially set to not visible! Is that fixable? :(
Done - fixed. The only "issue" will be when you set the TabControl back to visible. You will need to also display the child dialog - FireFly will not do it automatically.
Guys,
I may be missing something but the following line is all I've been using
to switch to a new tab in a tab-control. The next to last parameter is the
tab number to switch to. The only other thing I do is to set the active
control right after this. That might not be needed but it didn't hurt.
Further looking at the above code shows that some step has been overlooked.
When a new form is to be used for a tab, there are 2 steps. One is to
set TabControlChild to True for that form. The second is to add it under
the Custom option of the tabcontrol properties.
curTab = SendMessage(HWND_PTS_TABCONTROL1, %TCM_SETCURFOCUS, 2, 0)
Thanks Paul,
I haven't looked at any of this code yet so you may indeed be right on the money. I hope to figure it out tomorrow when I have more time.
Thanks!