|
Actually... I found an interesting blurb about creating a class and inheriting from CSplitterWnd and overloading two of the un-documented methods to set the width of the splitter, and remove the re-sizing grabber...
The original article I used is Here[^] but I guess it was a little dated, because there was no CPaneSplitter() method in the AFXEXT.H file when I looked (after getting no results) ... so, I used DrawAllSplitBars in place, and added in the additional members that the other article was missing ...
Here is what I did (works great!)
// - .H File - //
class CThinFrameSplitterWnd : public CSplitterWnd {
public:
void DrawAllSplitBars(CDC* pDC, int cxInside, int cyInside);
int HitTest(CPoint pt) const;
};
// .CPP File - //
void CThinFrameSplitterWnd::DrawAllSplitBars(CDC* /*pDC*/, int /*cxInside*/, int /*cyInside*/){
m_cxSplitter = 0;
m_cySplitter = 1;
m_cxBorderShare = 0;
m_cyBorderShare = 0;
m_cxSplitterGap = 0;
m_cySplitterGap = 0;
m_cxBorder = 0;
m_cyBorder = 0;
}
int CThinFrameSplitterWnd::HitTest(CPoint /*pt*/) const {
ASSERT_VALID (this);
return 0; // don't let the user see the mouse hits
}
Then i just swapped
CSplitterWnd m_mainSplitter;
for
CThinFrameSplitterWnd m_mainSplitter;
and poof! ... no more splitter bar (which was exactly what I wanted)
I hope this little tid bit helps out others as well as it has me
qcha0s
|
|
|
|
|
Thanks
- must admit I haven't written any MFC in 3 years - brought back some memories
There are 10 sorts of people in this world. Those who understand binary and those that don't.www.many-monkeys.com
|
|
|
|
|
memories? or nightmares :P
qcha0s
|
|
|
|
|
Your piece of code to lock the splitter bar helped me a lot! Thanks so much.
|
|
|
|
|
Hello,
how can insert in a child of SplitterWnd a CPropertySheet?
I know that the CPropertySheet is'nt a CView deriviates.
But is there any way, which I can include CPropertySheet ?
Thanks for any helps. jr
|
|
|
|
|
you might be better posting this in the main forums
however I suspect the best way would be to simulate a property sheet by using a form view and a tab control and then switch between your little dialogs
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
I have a mainframe class which switches among many form views. In one of the Form view i have to crate static splitter wnd with 1 row and 2 cols.
How to do this?
|
|
|
|
|
Have you looked at the sample project?
Here is the relevant area from MainFrm.cpp.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_wndSplitter.CreateStatic(this,1,2))
{
TRACE(_T("failed to create the splitter"));
return FALSE;
}
if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CSplittstView),CSize(100,100),pContext))
{
TRACE(_T("Failed to create view in first pane"));
return FALSE;
}
if (!m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CForm1),CSize(100,100),pContext))
{
TRACE(_T("failed to create view in second pane"));
return FALSE;
}
return TRUE;
}
However this sort of question should be sent to the MFC forum and not to an articles questions.
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
HI,
How can I use the CUsefulSplitterWnd for MDI ?
The example is a SDI-App.
Must I move the OnCreateClient in CFrame to CChildFrame ?
Have someone an example ? Thanks.
|
|
|
|
|
you use the CUsefulSplitterWnd in an MDI app in the same way as you would CSplitterWnd - so yes you would move it to CChildFrame - have you tried?
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Hello,
yes I tried it. At program start is working fine.
But if I try to schwitch/change to other CFormView,
I have problems with ReplaceView(..) Function .
CChildFrame*pChildFrame=(CChildFrame*)AfxGetMainWnd();
pChildFrame->m_wndSplitter.ReplaceView(0,1,RUNTIME_CLASSCForm1),CSize(100,100));
So, in Function I have an exception.
It's came from the GetPane() ?
<<if ((getpane(row,col)-="">IsKindOf(pViewClass))==TRUE)>>
It's seem that I have not a correct pointer of the View?
Have you the same example as MDI example ? I would be nice to have it here as downloadable.
Greetings, jr
|
|
|
|
|
Ah - the AfxGetMainWnd would be wrong as it would be pointing at the wrong window - do you have a sample at all - I'll try and find a compiler to run it on (away from my development machine for a few weeks)
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Hello Shoun,
thanks for all helps. I solve the problem. You're on right
with the pointer from the wrong window in MDI -Application.
//ReplaceView in SDI-Application :
CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
pMainFrame->m_wndSplitter.ReplaceView(0,1,RUNTIME_CLASS(CForm1),CSize(100,100));
//ReplaceView in MDI-Application:
CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();
// Get the active MDI child window.
CChildFrame* pChild = (CChildFrame*)pMainWnd->MDIGetActive();
pChild->m_wndSplitter.ReplaceView(0,1,RUNTIME_CLASS(CForm1),CSize(100,100));
Send Greetings to your family from the Black Forest /Heidelberg. jr
|
|
|
|
|
With this method, you can't get a pointer to the Document Class, you'll become an ASSERT Error.
CMyDocClass*pDoc = GetDocument();
Try it....
Update: I've found the Problem *rofl* its awkward, i've forgot to implement your method in the children window...
Greetz Neti from Switzerland ^_^
If you, your girlfriend and dead people are in the room means that all are deaf. How many people are there?
|
|
|
|
|
Hi
First of all congratulations, great work.
I use your class and I have a little problem. I try to discribe it: I want to print the right view. On the left view I ve to click for changing the view on the right side, the focus is on the left splitter and when I click directly on printing. What happens: the printing message goes to the left splitter not to the right one.
When I click into the right splitter and than on printing it works.
My question is what must I do to set the focus automatically on the right splitter. I want to do it always.
I hope you understand what I want. Perhaps it is easy to solve and you can help me
thanks
yummi
|
|
|
|
|
I think its all related to how MFC does its printing - I think by default it will print the first view in its list of views - what you have to do is override this default mechanism and make it print the second view instead - I think there is a command message you can intercept ID_FILE_PRINT that may help you
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Hi
First of all thank you for your answer.
I noticed the following: when I don't click on the second pane (view) and I changed the view by clicking on another item in the first pane the algorithm set always the new view as active.
When I click in the view pane and after I do this I click in the first pane to change the view, the ActivateView function will not be called, because of that the printing message receives in the first pane (the selecting area).
I make the following changes in the function ReplaceView:
<br />
if (pActiveView==NULL || pActiveView==GetPane(row,col))<br />
bSetActive=TRUE;<br />
else<br />
bSetActive=TRUE;
so that bSetActive always be TRUE (I show it on that way so that you can find it on your code)
Because of that here
<br />
if (bSetActive==TRUE)<br />
GetParentFrame()->SetActiveView(pNewView); <br />
the new View always get the active part.
I don't know if there is any secondary effect on your algorithm?
I Hope you understood whatv I mean.
Thanks
yummi
|
|
|
|
|
This class clarified a lot for me and made my life a little happier today; thanks a bunch!!! Great work.
|
|
|
|
|
I also thank you...as it is what I was looking for also!!
Everybody gotta be somebody
|
|
|
|
|
This was just what i was looking for!
|
|
|
|
|
glad to help - just remember to look at some of the forum messges as you may have problems that the others have fixed
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Please remember to call OnInitialUpdate() in Replace view as pointed out by salinas in
http://www.codeproject.com/splitter/usefulsplitter.asp?df=100&forumid=260&select=91652#xx91652xx
BOOL CUsefulSplitterWnd::ReplaceView(int row, int col,CRuntimeClass * pViewClass,SIZE size)
{
CCreateContext context;
BOOL bSetActive;
if ((GetPane(row,col)->IsKindOf(pViewClass))==TRUE)
return FALSE;
CDocument * pDoc= ((CView *)GetPane(row,col))->GetDocument();
CView * pActiveView=GetParentFrame()->GetActiveView();
if (pActiveView==NULL || pActiveView==GetPane(row,col))
bSetActive=TRUE;
else
bSetActive=FALSE;
if (pDoc!=NULL) pDoc->m_bAutoDelete=FALSE;
((CView *) GetPane(row,col))->DestroyWindow();
if (pDoc!=NULL) pDoc->m_bAutoDelete=TRUE;
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
CreateView(row,col,pViewClass,size, &context);
CView * pNewView= (CView *)GetPane(row,col);
if (bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);
RecalcLayout();
pNewView->OnInitialUpdate();
GetPane(row,col)->SendMessage(WM_PAINT);
return TRUE;
}
I hope u guys don make the same mistake as me. Spend almost a week and asking around and still couln'd find the problem. Finally solved it and noticed salinas post too.
The above code also takes care of things when u don't use a document/view architecture, just a small check on pDoc!=NULL
or u can use WM_INITIALUPDATE as suggested by salinas post
then you would need to include this
#include <afxpriv.h>
and change
pNewView->OnInitialUpdate();
to
pNewView->SendMessage(WM_INITIALUPDATE);
|
|
|
|
|
yes this could be useful to add - when I created this class (for a 16bit project ~ '95)I wasn't using CFormViews as the views in the splitters and thus I never noticed it was required - or maybe it is new to the 32 bit environment.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Hi,
I've got some trouble with ReplaceView, and it's hard to describe here, but i'll try.
I use 2 splitter to create 2 rows, and the first row has two columns. To create first row, i use CFrameWnd which has SplitterWnd.
But when i try to ReplaceView with this splitter (in CFrameWnd), it failed. i don't know exactly what happens, but maybe the CDocument failed (when document add view - that's is my debug).
So, what happens ???
Do i create splitter right ? ( 2 col, 1 row splitter)
Help me, please. I give up !!!
Thanks,
nvhoang
|
|
|
|
|
sorry I haven't been receving emails from this article due to a change of email address - and I forgot to update codeproject.
do you still require assistance?
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|