Originally posted by: Maciek
Everythink work fine with standard CTabCtrl, but when I want to have tab buttons down (BOTTOM setting in More Styles), dialogs on tabpages are not displayed :( Can anyone fix that problem? Thanks,
Maciek
ReplyOriginally posted by: Bill G
I must've beaten my head against MSDN for six hours before becoming completely frustrated.
This article (and associated code - thanks muchly for that as well) made it clear in less than an hour.
Again, THANKS!!
ReplyOriginally posted by: Gregory Kaufman
One way I have found to get the data from all the tab controls to my main dialog window is the following. (This allows me to have only one OK, CANCEL, APPLY button for my program)
In the Main Dialog (Ex:CMyTabExampleDlg) create function for APPLY Button. Then cast the CMyTabCtrl m_tabPages to each of the your tab classes(CTabOne,CTabTwo, etc...).
Example code:
void CMyTabExampleDlg::OnBnClickedApply()
{
UpdateData();
CTabOne* t1dlg = (CTabOne*)m_tabMyTabCtrl.m_tabPages[0];
CTabTwo* t2dlg = (CTabTwo*)m_tabMyTabCtrl.m_tabPages[1];
//then access data in each class
int d1 = t1dlg->m_mydataOne;
int d2 = t1dlg->m_mydataTwo;
int sec = t2dlg->GetSeconds;
//etc.....
}
Reply
Originally posted by: Tsuyoshi Moriyama
------- 8< -------- 8< -------- 8< -------- 8< ---------
m_tabPages[0]->Create(IDD_PAGE_ONE, this);
for ( int nCount = 0; nCount < m_nNumberOfPages; nCount++ )
SetRectangle(nInitFocus);
void CMyTabCtrl::SetRectangle(int nInitFocus)
int nX = itemRect.left;
m_tabPages[nInitFocus]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
Since it didn't seem to catch any key or mouse event in
the tab pages, I modified the code. Also, I wanted to activate a particular page when initialized.
void CMyTabCtrl::Init(int nInitFocus)
{
m_tabCurrent = nInitFocus;
m_tabPages[1]->Create(IDD_PAGE_TWO, this);
{
if ( nCount != nInitFocus ) m_tabPages[nCount]->ShowWindow(SW_HIDE);
m_tabPages[nCount]->EnableWindow(); // added
}
m_tabPages[nInitFocus]->ShowWindow(SW_SHOW);
}
{
CRect tabRect, itemRect;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
int nY = itemRect.bottom + 1;
int nXc = tabRect.right - itemRect.left - 1;
int nYc = tabRect.bottom - nY - 1;
for ( int nCount = 0; nCount < m_nNumberOfPages; nCount++ )
{
if ( nCount != nInitFocus ) m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
}
Originally posted by: SRF
Here is a fix to the Return & ESC problem, just add this code to all your dialogs that use the control.
BOOL HeaderTab::PreTranslateMessage(MSG* pMsg)
if(pMsg->wParam == VK_RETURN )
return CDialog::PreTranslateMessage(pMsg);
Done...
See ya
Has anyone been able to pass variables from dialogs to the main dialog when using this control (MyTabCrtl). Any ideas ?
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->wParam == VK_ESCAPE )
{
return TRUE;
}
{
return TRUE;
}
}
Originally posted by: G MAN
On Win XP it is blasting over the nice drawing effects of the tab control... any ideas?
Reply
Originally posted by: Annette
I know the following is easy, but it took me a moment to
To take into account the fact, that buttons may be placed
if (GetStyle() & TCS_BOTTOM)
This should be extended for buttons on the left or the
Thanks for this nice class!
figure out, why this class didn't work for me ... so maybe
this pointer can save this time for somebody else ...
at the bottom, I suggest the following modification to
CMyTabCtrl::SetRectangle
{
nX = itemRect.left;
nY = tabRect.top + 1;
nXc = tabRect.right-itemRect.left-1;
nYc = itemRect.top - 1 - nX;
}
else
{
nX = itemRect.left;
nY = itemRect.bottom + 1;
nXc = tabRect.right - itemRect.left - 1;
nYc = tabRect.bottom - nY - 1;
}
right side, but since I don't need it at the moment ....
Originally posted by: Sacha
I would like to pass a CString value from the Tab dialog, to the Main dialog. I don't have a clue how to do this, since I'm relatively new to the Visual C++ Programming environment. Any help would be greatly appreciated.
Originally posted by: [hjd_uk]
This is the tab swapping code i now use.
void CMyTabCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult)
I was having trouble swapping the tab "pages" until i swapped the OnLButtonDown for the OnSelchange In the CTabCtrl class. This was mentioned by someone else in the comments before me.
{
if(m_tabCurrent != GetCurFocus())
{
m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
m_tabCurrent=GetCurFocus();
m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
m_tabPages[m_tabCurrent]->SetFocus();
}
*pResult = 0;
}
Reply
Originally posted by: Bj�rn
Great work. Tutorial was easy to understand and very usefull. Thanx!