|
Thank you very much for your sample, which is very useful for me.
Now, i can realy do what i wanted to do.
Thanks a lot.
|
|
|
|
|
Could you send me an example?
I tried to transfer data defined in the dialog to the main dialog and I can't have the new values of data but only the values defined by default in the dialog.
Thanks!!
|
|
|
|
|
give me your email
youssef
|
|
|
|
|
yadron@netcourrier.com
Thanks,
Yoann
|
|
|
|
|
Hi,
I have the same problem, I don't know how to transfert datas from a TabPage to another TabPage or from a TabPage to the Main Dialog.
Please, youssef or chhlud can you send me as well a sample about it?
Thanks a lot in advance,
fabio
|
|
|
|
|
This seems to be a common problem, is there someone that can provide something for us all to see? Perhaps post the e-mail on a website? That would be a big help. TIA
John
|
|
|
|
|
I've a problem in selecting tabs in menu command.
|
|
|
|
|
|
Since this is such a hot topic, could I get the sample project with the formview. It will be greatly appreciated. Thanks
Chris
|
|
|
|
|
I guess I get to be the "me too" guy on this, but can I get a copy of sample with FORMVIEW as well.
Thanks in advance
|
|
|
|
|
If your porgram is correct, then insert the sentence in "void YourFormView::OnInitialUpdate() "
/* CRect rect;
GetDlgItem(IDC_TAB_FIRST)->GetWindowRect(&rect);
GetDlgItem(IDC_TAB_FIRST)->SetWindowPos(NULL, 10, 40,
rect.Width(), rect.Height(),SWP_NOZORDER| SWP_NOACTIVATE);
*/
|
|
|
|
|
When adding new Dialog forms, they never appear on the same base dialog form. They always spawn new Dialog forms. Is there a way to make the new dialogs appear on the same form as the first two?
|
|
|
|
|
In the resource editor make the dialog forms have the child style. That should do the trick
|
|
|
|
|
I have tried without success to incorporate this class into an existing property sheet.
Is there a demo project available showing how to do so?
tia
|
|
|
|
|
This is an excellent class. It gave me a great starting point. I just wanted to mention three fixes that I made.
First, the class doesn't allow the parent to validate the tab when the user clicks on a new tab. I changed the ON_NOTIFY_REFLECT to ON_NOTIFY_REFLECT_EX, and return FALSE from OnSelchanging() (note that the MSDN says to return TRUE to allow the parent to handle the notification, but the MSDN is wrong!)
Second, the function SelectTab() handles all changing of tab by itself, and once again does not give the current tab a chance to validate itself. Instead of just changing the tab right
there, I modified this function to send the appropriate notification messages. The following shows my change:
BOOL CXTabCtrl::SelectTab(int iIndex)
{
.
.
if (m_arrayStatusTab[iIndex])
{
NMHDR nmhdr;
nmhdr.hwndFrom = m_hWnd;
nmhdr.idFrom = GetDlgCtrlID();
nmhdr.code = TCN_SELCHANGING;
if (GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), &nmhdr))
{
return FALSE;
}
SetCurSel(iIndex);
nmhdr.code = TCN_SELCHANGE;
GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), &nmhdr);
return TRUE;
}
.
.
}
This makes the tab change in the exact same way as if the user had clicked on the tab. The control will handle these notifications and the tab will change, as long as it validates.
The third change that I made is with the focus. I noticed that if the focus is set to an item on a page, and you switch tabs, the invisible item still has the focus. For example, in the sample app, highlight the "ID" edit box and type a number, then switch tabs and type another number, then return back to the first tab. The ID edit box still has focus and it shows both numbers that you typed (even though the window wasn't visible when you typed the second number).
To fix this, I added the following to the OnSelChange() handler:
void CXTabCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult)
{
.
.
pWnd->ShowWindow(SW_HIDE);
CWnd *pFocusWnd = GetFocus();
while (pFocusWnd)
{
if (pFocusWnd == pWnd)
{
::SetFocus(NULL);
pFocusWnd = NULL;
} else {
pFocusWnd = pFocusWnd->GetParent();
}
}
.
.
}
What this does is, if the focus is set to any window inside the CWnd that gets hidden, then it gets reset to NULL.
Hope these changes help somebody.
|
|
|
|
|
Your code does not compile.
|
|
|
|
|
I realize this response is over a year after the fact but I experienced a similar "won't compile" issue. Because you (whomever the Anonymous poster was) did not describe your failure I hope you did not expect your problem to be taken seriously. But here is what I did to solve my problem.
The error was passing the &nmhdr parameter to SendMessage(). So I casted the param and all worked out.
GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), reinterpret_cast<long>(&nmhdr))
xicoloko - nice work.
Darren - thanks for the suggestion
|
|
|
|
|
Oops, sorry, I missed the "Display this message as-is (no HTML)" check box and lost the <long>.
GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), reinterpret_cast<long>(&nmhdr))
|
|
|
|
|
The window is opened as a seperate dialog as I Add it to CXTabCtrl class. The samples you had used are newly created with classwizard.
Try these to repro:
Create a new project (dialog) with wizards. Then add your files to the project. Try to Add already the created Dialog to TabCtrl new dialog. The dialogs are not tabbed. Unfortunately
|
|
|
|
|
Editing the resource file and changing the style of the parent dialog to the following. It did the trick for me.
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
EXSTYLE WS_EX_APPWINDOW
|
|
|
|
|
The window is opened as a seperate dialog as I Add it to CXTabCtrl class. The samples you had used are newly created with classwizard.
Try these to repro:
Create a new project (dialog) with wizards. Then add your files to the project. Try to Add already the created Dialog to TabCtrl new dialog. The dialogs are not tabbed. Unfortunately
|
|
|
|
|
I really like this control but it would be pretty nice if when it displays the dialog for a given control it would actually stretch the dialog to fit the tab. I'm actually using a class I found here as well, CResizableDlg that allows you to use anchors so that when stretched, the controls say proportional (depending where you set the anchors). Whether you do it that way, or simply handle OnSize in each of you dialogs, I just need this control to force my dialogs to resize to fit the control. I'm very inexperienced with the DC so I'm a little confused as to where and how exactly the dialog is displayed. It looks like it's happening in the DrawItem member function. I expected to find it as something simple like ShowWindow but at at least when on the first tab I don't see it working that way. Any suggestions
|
|
|
|
|
Ok, So I answered it myself... though I think my implementation is possibly not the cleanest. I added a new public method under operations:
void ResizeDlgToTab(bool bResizeDlgToTab)
{ m_bResizeDlgToTab = bResizeDlgToTab; };
Obviously, m_bResizeDlgToTab is just another bool I added with all the others in Protected.
In the constructor I initialize this boolean to false. I added support for OnSize:
void CXTabCtrl::OnSize(UINT nType, int cx, int cy)
{
CTabCtrl::OnSize(nType, cx, cy);
if (m_bResizeDlgToTab)
{
CWnd* pWnd = NULL;
TCITEM item;
int nIndex = GetCurSel();
if (GetItem(nIndex, &item))
{
pWnd = (CWnd*)item.lParam;
}
if (pWnd)
{
CRect r;
int nTabHeight, nTabWidth;
GetClientRect(r);
nTabHeight = r.bottom;
nTabWidth = r.right;
pWnd->MoveWindow(m_ptTabs.x, m_ptTabs.y, nTabWidth - 20, nTabHeight - 45, TRUE);
}
}
}
and OnShowWindow:
void CXTabCtrl::OnShowWindow(BOOL bShow, UINT nStatus)
{
CTabCtrl::OnShowWindow(bShow, nStatus);
if (bShow && m_bResizeDlgToTab)
{
CWnd* pWnd = NULL;
TCITEM item;
int nIndex = GetCurSel();
if (GetItem(nIndex, &item))
{
pWnd = (CWnd*)item.lParam;
}
if (pWnd)
{
CRect r;
int nTabHeight, nTabWidth;
GetClientRect(r);
nTabHeight = r.bottom;
nTabWidth = r.right;
pWnd->MoveWindow(m_ptTabs.x, m_ptTabs.y, nTabWidth - 20, nTabHeight - 45, TRUE);
}
}
}
In order to get my dialog stretched where I like it right now I added a little OnSize call to the DrawItem method like so:
.....
pDC->RestoreDC(nSavedDC);
// Force an inital onsize if requested
if (m_bResizeDlgToTab)
{
CRect r;
GetClientRect(r);
OnSize(SIZE_RESTORED, r.right, r.bottom);
}
}
That's mostly it. I wasn't sure, so I also updated the calls to SetWindowPosition in AddTab and ChangeTab like so:
if (m_bResizeDlgToTab)
{
CRect r;
int nTabHeight, nTabWidth;
GetClientRect(r);
nTabHeight = r.bottom;
nTabWidth = r.right;
pNewTab->SetWindowPos(NULL, m_ptTabs.x, m_ptTabs.y, nTabWidth - 20, nTabHeight - 45,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER);
}
else
{
pNewTab->SetWindowPos(NULL, m_ptTabs.x, m_ptTabs.y , 0, 0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER);
}
I hope this is useful to someone. I have example code if anyone needs it
|
|
|
|
|
yes i could use an example please, i tried your modifications and it seems like only the first tab is the one that will resize itself. Maybe i messed up somewhere, i dunno but after checking it for errors numerous times i still cant see why it doesn't work.
|
|
|
|
|
I have encounter a problem with TabControl in general and with this class similarly.
When I press the Enter key in any of the controls (edit box), the child dialog in the
current tab will become invisible. It will only come back when I click on other tab and
then back to the previous invisible tab. Could someone enlighten me regarding this?
Thanks
|
|
|
|
|