Win32 PropertySheet and Stacked Tabs
Hello, I have a small problem.
I'm using Win32 PropertySheet function to create a static property sheety dialog. If I create a couple sheets, the tabs stay on the same line. However, if I create a dozen or so sheets, the tabs now show up in a stacked arrangement.
Question is, how do I stop Win32 from stacking the tabs?
I do realize that CPropertySheet has a class member called EnableStackedTabs(), however, I'm not using it. I would like to use the Win32 version. I searched the flag settings in both PROPSHEETHEADER and PROPSHEETPAGE, but I can't find any mention of stacked tabs or how to disable it.
Any ideas?
Re: Win32 PropertySheet and Stacked Tabs
Remove the TCS_MULTILINE style
Re: Win32 PropertySheet and Stacked Tabs
Quote:
Originally Posted by
Arjay
Remove the TCS_MULTILINE style
Thanks! Where is the appropriate place to remove it?
I tried to remove it in 4 different places, but it still didn't work.
This is the property sheet callback function:
Code:
static INT CALLBACK
Sheet_CallbackProc(HWND hDlg, UINT uMessage, LPARAM lParam) {
switch(uMessage) {
case WM_INITDIALOG: {
// Doesn't work - tabs still stacked
//CWnd::ModifyStyle(hDlg, TCS_MULTILINE, TCS_SINGLELINE, 0);
// Doesn't work - tabs still stacked
//HWND hWndTab = (HWND)::GetDlgItem(hDlg, AFX_IDC_TAB_CONTROL);
//if (hWndTab != NULL) {
// CWnd::ModifyStyle(hWndTab, TCS_MULTILINE, TCS_SINGLELINE, 0);
}
}
return TRUE;
case PSCB_PRECREATE:
if (((LPDLGTEMPLATEEX)lParam)->signature == 0xFFFF) {
// Doesn't work - sheets don't show up
//((LPDLGTEMPLATEEX)lParam)->style &= ~TCS_MULTILINE;
//((LPDLGTEMPLATEEX)lParam)->style &= TCS_SINGLELINE;
}
else {
// Doesn't work - sheets don't show up
//((LPDLGTEMPLATE)lParam)->style &= ~TCS_MULTILINE;
//((LPDLGTEMPLATE)lParam)->style &= TCS_SINGLELINE;
}
return TRUE;
}
return FALSE;
}
I also check my .rc resource files, and I see no mention of TCS_MULTILINE or TCS_SINGLELINE.
Re: Win32 PropertySheet and Stacked Tabs
I'm a bit confused (after seeing references to CWnd::ModifyStyle). Are you using MFC or not? Thanks.
Be sure to set the style on the tab control hwnd (use the Spy++ to get its id and then ::GetDlgItem).
If you aren't using mfc, look at the following code to extract out the GetWindowLong/SetWindowLong calls
and call them in the WM_INITDIALOG.
Code:
AFX_STATIC BOOL AFXAPI _AfxModifyStyle(HWND hWnd, int nStyleOffset,
DWORD dwRemove, DWORD dwAdd, UINT nFlags)
{
ASSERT(hWnd != NULL);
DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset);
DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
if (dwStyle == dwNewStyle)
return FALSE;
::SetWindowLong(hWnd, nStyleOffset, dwNewStyle);
if (nFlags != 0)
{
::SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
}
return TRUE;
}
BOOL PASCAL
CWnd::ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd, UINT nFlags)
{
return _AfxModifyStyle(hWnd, GWL_STYLE, dwRemove, dwAdd, nFlags);
}
BOOL PASCAL
CWnd::ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd, UINT nFlags)
{
return _AfxModifyStyle(hWnd, GWL_EXSTYLE, dwRemove, dwAdd, nFlags);
}
Re: Win32 PropertySheet and Stacked Tabs
Well, actually MFC already provides a solution:
Code:
BOOL CPropertySheet::OnInitDialog()
{
// change tab style if scrolling tabs desired (stacked tabs are default)
if (!m_bStacked)
{
HWND hWndTab = (HWND)::GetDlgItem(m_hWnd, AFX_IDC_TAB_CONTROL);
if (hWndTab != NULL)
CWnd::ModifyStyle(hWndTab, TCS_MULTILINE, TCS_SINGLELINE, 0);
}
. . .
Re: Win32 PropertySheet and Stacked Tabs
Thanks, but it didn't work. I have the same code in WM_INITDIALOG.
And yes, I am using MFC and Win32. I'm using both because the original code comes from an older Win32 program, and I haven't fully converted it to MFC yet.
Re: Win32 PropertySheet and Stacked Tabs
What didn't work? Did you debug your code? Did you find tab control successfully? Did you test return codes?
In case you really want to get some help, you'd better upload a minimal compilable project that replicates your issue.
Re: Win32 PropertySheet and Stacked Tabs
I come to the conclusion that stacked tabs cannot be disabled for the Win32 property sheets.
I think everyone is assuming this change happens only once during WM_INITDIALOG (it may have worked for a millisecond), but there could be hidden code that continually tracks the length of the line and modifies the style whenever it sees fit.
Thanks.
Re: Win32 PropertySheet and Stacked Tabs
Quote:
Originally Posted by
maxbug
I come to the conclusion that stacked tabs cannot be disabled for the Win32 property sheets.
I think everyone is assuming this change happens only once during WM_INITDIALOG (it may have worked for a millisecond), but there could be hidden code that continually tracks the length of the line and modifies the style whenever it sees fit.
Thanks.
What hidden code? Where? If you think it's in MFC, you should have the MFC source code - take a look for yourself.
Re: Win32 PropertySheet and Stacked Tabs
There is no source code for the Win32 property sheets. CPropertySheet must have been updated to allow the user to control it, because EnableStackedTabs() does not exist for the Win32 version.
Re: Win32 PropertySheet and Stacked Tabs
Quote:
Originally Posted by
maxbug
There is no source code for the Win32 property sheets. CPropertySheet must have been updated to allow the user to control it, because EnableStackedTabs() does not exist for the Win32 version.
The source code for MFC is in the atlmfc folder. If you look at the MFC source code, you can see where sets the stack style (like Igor posted in post #5).
As Igor mentioned, if this isn't working, zip up and post a small test project that repros the problem. We may just be able to look at your code and find out what is wrong.