The tab control just works fine until I want to close one tab and focus on another tab, what am I doing wrong here?
Case WM_LBUTTONDOWN
' Get the position of the hit and determine if the CLOSE icon was clicked.
GetCursorPos( @pInfo.pt )
ScreenToClient( HWND_FRMMAIN_TAB, @pInfo.pt)
nCurSel = TabCtrl_HitTest(HWND_FRMMAIN_TAB, @pInfo)
' Was the close icon pressed
If pInfo.flags = TCHT_ONITEMICON Then
Dim as long CurFocus = TabCtrl_GetCurFocus(HWND_FRMMAIN_TAB)
if CurFocus = 0 then
TabCtrl_SetCurFocus( HWND_FRMMAIN_TAB, nCurSel )
? "hide the control "
Elseif CurFocus = nCurSel then
TabCtrl_SetCurFocus( HWND_FRMMAIN_TAB, nCurSel - 1)
TabCtrl_DeleteItem( HWND_FRMMAIN_TAB, nCurSel)
elseif CurFocus < nCurSel then
TabCtrl_DeleteItem( HWND_FRMMAIN_TAB, nCurSel)
elseif CurFocus > nCurSel then ' Why cant i select the lastTab ?
TabCtrl_DeleteItem( HWND_FRMMAIN_TAB, nCurSel)
dim as integer lastTab = TabCtrl_GetItemCount(HWND_FRMMAIN_TAB) - 1 ' Returns the number of items if successful, or zero otherwise
TabCtrl_SetCurSel( HWND_FRMMAIN_TAB, lastTab) why can't I select the last tab ?
TabCtrl_SetCurFocus( HWND_FRMMAIN_TAB, lastTab) 'why can't I select the last tab ?
end if
AfxRedrawWindow( HWND_FRMMAIN_TAB )
end if