 |
|
 |
I got it so you can drag a tab to the left / right and change the order of the views.
Open the header, and insert:
class CMDITabs : public CXPTabCtrl{
...
private:
int m_iMouseDownItem; public:
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
In the implementation add:
CMDITabs::CMDITabs()
{
m_iMouseDownItem=-1;
also
void CMDITabs::OnLButtonDown(UINT nFlags, CPoint point)
{
CXPTabCtrl::OnLButtonDown(nFlags, point);
TCHITTESTINFO tcHit;
tcHit.pt = point;
int selected = HitTest(&tcHit);
int current = GetCurSel();
m_iMouseDownItem = selected;
SetCapture();
Then add the functions:
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
void CMDITabs::OnLButtonUp(UINT nFlags, CPoint point)
{
CTabCtrl::OnLButtonUp(nFlags, point);
m_iMouseDownItem = -1;
ReleaseCapture();
}
void CMDITabs::OnMouseMove(UINT nFlags, CPoint point)
{
CTabCtrl::OnMouseMove(nFlags, point);
TCHITTESTINFO tcHit;
tcHit.pt = point;
if(m_iMouseDownItem >=0)
{
int selected = HitTest(&tcHit);
if(selected>=0 && selected != m_iMouseDownItem)
{
TCITEM itema;
char texta[256];
itema.cchTextMax = 255;
itema.pszText = texta;
itema.mask = TCIF_TEXT|TCIF_PARAM|TCIF_IMAGE|TCIF_STATE;
TCITEM itemb;
char textb[256];
itemb.cchTextMax = 255;
itemb.pszText = textb;
itemb.mask = TCIF_TEXT|TCIF_PARAM|TCIF_IMAGE|TCIF_STATE;
BOOL ok = GetItem(selected, &itema);
GetItem(m_iMouseDownItem, &itemb);
ok = SetItem(m_iMouseDownItem, &itema);
SetItem(selected, &itemb);
m_iMouseDownItem = selected;
this->SetCurSel(selected);
}
}
}
|
|
|
|
 |
|
 |
good
|
|
|
|
 |
|
 |
Hello!
I have SDI multi-view application, could you please tell how to adap code for SDI model ?
Thanks.
|
|
|
|
 |
|
 |
thank you!it's really simply to use,but a pity,when i changes the view,something flushs on the screen,can you tell me why?
|
|
|
|
 |
|
 |
I am developing an application with UI showing templates (top) folders, views (middle) folders and splitter frame (bottom) panes. In another words - a filing cabinet layout. I am cobbling it together using code from Bob and got it working from middle down. Having little difficulty with the template level. Anybody done similar stuff? Cheers Vaclav
|
|
|
|
 |
|
 |
The above message is not working for me. I included its handler as OnSizeParent(WPARAM, LPARAM) in CMyToolBar. I also included it message map entry as ON_MESSAGE(WM_SIZEPARENT,OnSizeParent) but my function never gets called when i resize the main window. Can anyone help please.
Thanks in advance.
Khan
|
|
|
|
 |
|
 |
Hi,
The code is good, I try to use in Visual Studio like interface, but it can't work, can it use in this case?
test
|
|
|
|
 |
|
 |
Hi,
I am new in MDI, I need to control the child windows from mainframe or CApp.
How can I get and track the created child windows, so I can change the title, send messages to the child window.
Thanks in advance.
|
|
|
|
 |
|
 |
This is a really good class, it took literally 3 minutes to integrate into the code I had and they worked fist time.
Well Done
|
|
|
|
 |
|
 |
I started using VS.NET 2005 , everytime I am trying to implement this kind of tabcontrols I am getting LNK errors. Do you have any idea...I am posting the LNK errors as below;
Error 1 error LNK2019: unresolved external symbol "public: __thiscall CMDITabs::CMDITabs(void)" (??0CMDITabs@@QAE@XZ) referenced in function "public: __thiscall CMainFrame::CMainFrame(void)" (??0CMainFrame@@QAE@XZ) MainFrm.obj
Error 2 error LNK2019: unresolved external symbol "public: void __thiscall CMDITabs::Create(class CFrameWnd *,unsigned long)" (?Create@CMDITabs@@QAEXPAVCFrameWnd@@K@Z) referenced in function "protected: int __thiscall CMainFrame::OnCreate(struct tagCREATESTRUCTW *)" (?OnCreate@CMainFrame@@IAEHPAUtagCREATESTRUCTW@@@Z) MainFrm.obj
Error 3 error LNK2019: unresolved external symbol "public: void __thiscall CMDITabs::Update(void)" (?Update@CMDITabs@@QAEXXZ) referenced in function "protected: virtual void __thiscall CMainFrame::OnUpdateFrameTitle(int)" (?OnUpdateFrameTitle@CMainFrame@@MAEXH@Z) MainFrm.obj
Error 4 fatal error LNK1120: 3 unresolved external
Error count and the LNK 2019 are the same for all kind of implementations...
Thanks...
|
|
|
|
 |
|
 |
so your sure of that all .cpp/.obj are in the project?
it just looks like missing of some object file in the project.:->
|
|
|
|
 |
|
 |
In my programme,I want to create more than one objects of CFormA,and the objects have some different attributes from each other.
How to do this?
wmzhang
|
|
|
|
 |
|
 |
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):
void CMDITabs::OnPaint()
{
CPaintDC dc(this);
if (GetItemCount() == 0) return; // do nothing
int dcState = dc.SaveDC();
// windows should draw the control as usual
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
pThreadState->m_lastSentMsg.wParam = WPARAM(HDC(dc));
Default();
dc.RestoreDC(dcState);
DWORD face = ::GetSysColor(COLOR_3DFACE);
if (m_bTop)
{
CRect rect(0, m_height - 7, m_width, m_height);
dc.FillSolidRect(&rect, face);
}
else
{
CRect rect(0, 0, m_width, 3);
dc.FillSolidRect(&rect, face);
}
}
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.
|
|
|
|
 |