|
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
|
|
|
|
|
so that CFormView can do some OnInitialUpdate job
|
|
|
|
|
It would be a lot of value to me if I could set a position past which the splitter bar cannot be moved. Seems like you need
to add a function to set the ClientRect region in which the
splitter bar can operate.
Thanks in advance for any help...
|
|
|
|
|
Do the following in your WM_MOUSEMOVE message handler of CSplitterWnd derived class.
I am assuming you have 2 panes and want to maintain minimum size for top pane. You can easily customise it to your needs.
void CMySplitterWnd::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if( nFlags == MK_LBUTTON)
{
if (point.y <= MINHEIGHT) point.y = MINHEIGHT;
CSplitterWnd::OnMouseMove(nFlags, point);
}
else
CSplitterWnd::OnMouseMove(nFlags, point);
}
regards,
Aman
|
|
|
|
|
Thank you very much for your class!
It was very helpful to me.
|
|
|
|
|
Hi, I would like to use HS et VS Scroll bar with your Spitter windows class, but i dont know how to do it. Can you help me plz?
Tx
Seb
|
|
|
|
|
I'm very happy to know that people like u live on earth...
Tx for all.
Your tutorial was very usefull.
|
|
|
|
|
This is almost exactly like a Microsoft sample (http://support.microsoft.com/support/kb/articles/Q199/5/15.ASP) and you are missing calling the OnInitialUpdate on the newly created view.
|
|
|
|
|
|
I wrote one line at the end of function ReplaceView
pNewView->OnInitialUpdate();
Please pardon my weak English!
|
|
|
|
|
strange thing is - I have that in my code at home - which I put in for someone and I haven't posted it here as I lost my password to the account that posted this when my NT2000 upgrade from NT blew up - I also changed ISPs too - wierd
Holy Handgrenade of Antioch instructions
|
|
|
|