|
I got it to work if anyone is curious.
|
|
|
|
|
hello
How to change the tab text color ?
Thanks
|
|
|
|
|
Help me please!
How to hide this control directly, i.e. form main menu as toolbar, for example (sorry for bad English)?
|
|
|
|
|
The MDI tabs looked good in my project, until I included a manifest so that common controls would have XP style when possible. In this mode, the tabs have extra lines below them. Is there a workaround for this?
|
|
|
|
|
Here is a solution to the problem that I found after many attempts. For the purists, it's not perfect since it leaves a few pixels incorrectly drawn but they really don't notice and the compromise is worth it.
There are a number of basic problems to overcome:
1. With XP styles, the area under the 'tab box' doesn't get redrawn
2. The patch up and repair pixels are different and not availalable from GetSysColor
3. When the spinner appears, it is a law unto itself
4. Avoiding having to detect XP styles (uxtheme stuff that needs VC7 or new platform SDK install)
Replace the whole function as follows (restore spaces at start of lines):
<br />
void CMDITabs::OnPaint()<br />
{<br />
CPaintDC dc(this);<br />
<br />
if (GetItemCount() == 0) return;
<br />
int dcState = dc.SaveDC();<br />
<br />
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();<br />
pThreadState->m_lastSentMsg.wParam = WPARAM(HDC(dc));<br />
Default();<br />
<br />
dc.RestoreDC(dcState);<br />
<br />
DWORD face = ::GetSysColor(COLOR_3DFACE);<br />
if (m_bTop)<br />
{<br />
CRect rect(0, m_height - 7, m_width, m_height);<br />
dc.FillSolidRect(&rect, face);<br />
}<br />
else<br />
{<br />
CRect rect(0, 0, m_width, 3);<br />
dc.FillSolidRect(&rect, face);<br />
}<br />
}<br />
This brute force solution works by letting Windows do its thing then painting over the top with the background (3D face) colour to hide the mess. The SaveDC and RestoreDC calls are necessary to allow redrawing over the area that Windows has marked as already redrawn when the spinner is displayed.
The result is neat and acceptable with or without the XP style. 2 pixels are lost at the right-hand end of the line and the second underline is also gone. But they don't really notice.
|
|
|
|
|
I have some tabs they show default Icon from Windows and some they show other Icon's but I don't know why ??
if I set the icon with SetIcon(hIcon, TRUE) it doenst change anything within the TAB.
it only change the Icon of the frame whitch I dont' display (no Sys-Menu) ..
How i can force MDITAB to get the icon I set with SetIcon(); ????
THX. for helping me out of this !!
|
|
|
|
|
Insert m_mdiTabs.Create(this); in ...
-->
Insert m_wndMDITabs.Create(this); in ...
|
|
|
|
|
I use CMDItabs in AutoCAD and noticed a problem when toolbars were being positioned in AutoCAD 2004 and 2005. While the toolbar was being moved around, the tabs "jumped" to the top of the frame and hid underneath the other toolbars. Resizing the frame made the tabs jump back into their correct position.
Delving into the MFC source code showed the problem and the solution. The problem lies with the AFX_SIZEPARENTPARAMS structure. Its usage is a bit more complex than I thought. Basically, the "hDWP" member needs to be checked as to whether a query or move operation is being requested. If hDWP is NULL, then a query operation is active, and everything except moving the windows is required (i.e. the rect member should still be filled in). If the HDWP is not NULL, then the move should be carried out as well.
As an aside, the window positioning should be carried out using DeferWindowPos rather than MoveWindow which I believe allows the operation to be optimised.
Christian, I'm afraid I'm using a much hacked version of your code, so I can't easily provide the changes required to implement the above. If the explanation above makes no sense, let me know and I'll provide a version of your OnSizeParent with my changes applied.
Cheers (and thanks for such a useful tool!)
|
|
|
|
|
I would be interested in applying your code changes to my version of OnSizeParent...
Could you please send me instructions of what to change?
Thanks
How do I print my voice mail?
|
|
|
|
|
This isn't the code I run (I've ammended the original version too much). But it does show the general idea.
Good Luck,
- Adrian
p.s.
AfxRepositionWindow isn't documented, but the MFC source code says more than words ever could!
afx_msg LRESULT CMDITabs::OnSizeParent(WPARAM, LPARAM lParam)
{
if (GetItemCount() < m_minViews)
{
ShowWindow(SW_HIDE);
}
else
{
AFX_SIZEPARENTPARAMS* pParams = reinterpret_cast<AFX_SIZEPARENTPARAMS*>(lParam);
const bool bLayoutQuery = (pParams->hDWP == NULL);
const int height = 26 + (m_bImages ? 1 : 0);
const int offset = 2;
m_height = height + offset;
m_width = pParams->rect.right - pParams->rect.left;
if (m_bTop)
{
pParams->rect.top += height;
if (!bLayoutQuery)
{
CRect rectTab(pParams->rect.left, pParams->rect.top - height, m_width, m_height);
AfxRepositionWindow(pParams, m_hWnd, &rectTab);
}
}
else
{
pParams->rect.bottom -= height;
if (!bLayoutQuery)
{
CRect rectTab(pParams->rect.left, pParams->rect.bottom - offset, m_width, m_height);
AfxRepositionWindow(pParams, m_hWnd, &rectTab);
}
}
ShowWindow(SW_NORMAL);
}
return 0;
}
|
|
|
|
|
Hi,
I am working on a freeware program. Can I use MDI Tabs source in my program?
thanks
-- narm
|
|
|
|
|
Yes
Christian
---
Always expect the unexpected!
|
|
|
|
|
I don't want the tab title order number. For example, I want to remove "1" of "MDITabs 1". Do you have any good idea? Thanks.
|
|
|
|
|
hi ,all
i means when create new tab,i don't want to select some form type from box,in some place ,i hope to specify a form type when create a tab.
that is ,when i press menu1,i want to create a form A tab directly;when i click menu2,i want to create a form B tab directly.during the creatation,not to select .
how to implement it ?
thanks a lot before.
|
|
|
|
|
There appears to be a drawing problem on XP if your app includes the manifest file.
A row of pixels (two rows?) between the tab and the MDI area are never redrawn.
Disabling the excluded clip rectangles in the paint function solves the problem but doesn't leave the control looking as clean as it could.
Does anyone have a better solution?
--
The Obliterator
|
|
|
|
|
My application calls for multiple document views and I would like to use similar approach as CMDITabs. I would like to have CMDITabs class " inside " tab document class, however, CMDITab cannot do that per this message board.
I was thinking making a doc tab and than an array of view tabs.
How does one gets the menu to have submenu e.a document with pop-up of views?
My views are not same for each document.
I am looking for any suggestions how to do this.
|
|
|
|
|
YES ,it is flick ,I don't know how to resolve it , Would you like to help me ?
thank you
|
|
|
|
|
It's flick because of when you switch a to a tab, the tab that is to be hiden is first restored and the new tab is maximized.
To prevent this, you could set the tab wich is to be hiden to his max size before the bringtotop,
That is what i do (i(ve remove the onselchange) :
void CMDITabs::OnLButtonDown(UINT nFlags, CPoint point)
{
CTabCtrl::OnLButtonDown(nFlags, point);
TCHITTESTINFO tcHit;
tcHit.pt = point;
int selected = HitTest(&tcHit);
int current = GetCurSel();
if (selected!=current)
{
TCITEM item;
item.mask = TCIF_PARAM;
GetItem(GetCurSel(), &item);
HWND hWnd = HWND(item.lParam);
if (::IsZoomed(hWnd)!=0)
{
CRect rect;
::GetClientRect(hWnd,&rect);
GetItem(current, &item);
::MoveWindow(HWND(item.lParam)
,rect.left-GetSystemMetrics(SM_CXFRAME)-GetSystemMetrics(SM_CXEDGE)
,rect.top-GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYFRAME)-GetSystemMetrics(SM_CYEDGE)
,rect.Width()+GetSystemMetrics(SM_CXFRAME)+2*GetSystemMetrics(SM_CXEDGE)
,rect.Height()+GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME)+2*GetSystemMetrics(SM_CYEDGE)
,FALSE);
GetItem(selected, &item);
::MoveWindow(HWND(item.lParam)
,rect.left-GetSystemMetrics(SM_CXFRAME)-GetSystemMetrics(SM_CXEDGE)
,rect.top-GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYFRAME)-GetSystemMetrics(SM_CYEDGE)
,rect.Width()+GetSystemMetrics(SM_CXFRAME)+2*GetSystemMetrics(SM_CXEDGE)
,rect.Height()+GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME)+2*GetSystemMetrics(SM_CYEDGE)
,FALSE);
}
GetItem(selected, &item);
hWnd = HWND(item.lParam);
// Invalidate window avant de l'afficher
CView * pView = (CView*) FromHandle(hWnd);
pView->Invalidate(TRUE);
::BringWindowToTop(HWND(item.lParam));
SetCurSel(selected);
}
}
In this case, tou must do the job yourself for restoring the windows pos, like a MDICascade() when the user chose to restore the windows...
|
|
|
|
|
|
Hi,
The TCS_BUTTON style is working but there is just a little problem : the OnSelChange is called only when the left mouse button is released.
When no button style is used, OnSelChange is call immediately after the left mouse boutton is pressed.. It's because of how the button notify his state, i think (like all other buttons) but i'd like that the focus change immediatly
Do you have an idea to correct that ?
Thanks you
|
|
|
|
|
Ok I use this code and it works :
void CMDITabs::OnLButtonDown(UINT nFlags, CPoint point)
{
CTabCtrl::OnLButtonDown(nFlags, point);
TCHITTESTINFO tcHit;
RECT rect;
tcHit.pt = point;
int selected = HitTest(&tcHit);
if (selected!=GetCurSel())
{
SetCurSel(selected);
TCITEM item;
item.mask = TCIF_PARAM;
GetItem(GetCurSel(), &item);
::BringWindowToTop(HWND(item.lParam));
}
}
|
|
|
|
|
when the tab select change, I want to transfer the function of view. but I can't transfer it,help me!!!
when the tab select change, I want to update the button of
toolbar,how to dao?
|
|
|
|
|
I was wondering if it is possible to have the window text be the same as the tab text. Currently it only seems to display the document name. The reason I ask is because each of my windows will have a different name. I am able to change the wondow text properly because I can see them being displayed at the top of the screen as well as in the Window list however the tabs stay as the document name. If you have any suggestions that would be great.
Thanks!
Amy
|
|
|
|
|
I am trying to implement the Serialize function so that I can save and reload my document (with multiple views). This would include creating a new view manually versus using the Window->New button. So for I have tried this and have not had any luck. Any suggestions?
void CScriptBuilderDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
//for each view
numViews = 0;
pos = GetFirstViewPosition();
while (pos != NULL)
{
cview = (CScriptBuilderView *)GetNextView(pos);
numViews++;
}
ar << numViews;
//Plus storing other info related to my views
}
else
{
ar >> numViews;
for (int i = 0; i < numViews; i++)
{
cview = new CScriptBuilderView();
cview->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0,0,0,0), AfxGetMainWnd(), AFX_IDW_PANE_FIRST + 1, NULL);
AddView(cview);
//Plus retrieve other info related to my view
}
}
UpdateAllViews(NULL);
}
Thanks in Advance
Amy
|
|
|
|
|
I have derived my CMainFrame class from CPIFrame (see this plugin archietecture article), which is derived from CMDIFrameWnd. Now the problem is VC says there is no CMDIFrameWnd::OnUpdateFrameTitle(BOOL). What could be the problem?
|
|
|
|
|