|
Thanks for this, very helpful for me.
It does not matter that its kind of old, some of us make a good living out of maintaining\enhancing existing applications
There are many old bridges dotted around towns and cities but we dont rebuild them all with modern materials simply because we can.
I dont know why it is so many people fail to grasp this with software but can with everything else.
PR Marjoram BSc
|
|
|
|
|
In the ReplaceView() method there is a little bug. If you use CWnd derived class instead of CView, the call :
if(bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);
will fail, you have just to comment this part of code
If you need to call DoDataExchange of your CFormView derived class, for example if you have Custom Controls inside your dialog that need to be initialized by DDX, youd need to add a call to the UpdateData method.
if (bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);
GetPane(row,col)->UpdateData(FALSE);
RecalcLayout();
GetPane(row,col)->SendMessage(WM_PAINT);
That's all. And many thanks to the author of this very usefull class.
Why trying to create the wheel if your roommate just invented the car (Me)
|
|
|
|
|
Awesome little trick.
|
|
|
|
|
Hi,
I've got an SDI app with a splitter, but as soon as I override OnCreateClient in CMainFrame (returning TRUE instead of CFrameWnd::OnCreateClient(...)) I completely lose printing support. I see that CFrameWnd::OnCreateClient creates a view which I guess I need to enable printing support.
Any ideas on how I can get round this cos I wanted to have my app print a custom report, but I don't get "free printing" now!
Thanks in advance
Life would be a lot easier if I had the source code...
|
|
|
|
|
Are you trying to print from all 3 views at one and make it look like one print out? - if so I am not sure that MFC can cope with that.
The other is to custom print and ignore the views completely and print directly to the printer DC - a bit more hard work but in the end more controllable - ie paging etc
I am using VB on the current project
www.many-monkeys.com
|
|
|
|
|
I was after doing custom printing (which I've done before) but by hijacking the print preview button. But once OnCreateClient is overridden, any button or menu option with the ID_FILE_PRINT_PREVIEW identifier is automatically disabled by default.
Could I give a different button/menu option print preview capabilities? If so, how do I call a print preview myself without relying on the framework to do it for me?
Sorry for the n00bish questions!
Thanks for your help
Life would be a lot easier if I had the source code...
|
|
|
|
|
Sorry - can't help you on this as I don't know.
You could look into what MFC does when it disables the button - you should have the Source code installed when you installed Visual Studio. and then undo its changes. I think however that Print Preview can only cope with 1 View rather than the mulitple views that a splitter introduces.
Your best bet would be to look through the MFC printing articles on CodeProject or other programmer sites and or post your question on the foruns and/or newsgroups.
Shaun
I am using VB on the current project
www.many-monkeys.com
|
|
|
|
|
Ok, I thought I was starting treading out of the bounds of this thread!
Thanks for your help anyway & cheers for the splitter class (helped me a lot)
Life would be a lot easier if I had the source code...
|
|
|
|
|
Hi,
Is there a way to hide the split bar itself so you wont notice that it is a split window at all??
Thanks!
|
|
|
|
|
I haven't tried - however you might be able to try an ownerdraw approach
I am using VB on the current project
www.many-monkeys.com
|
|
|
|
|
Did you ever find a solution to this ? and if so will you share?
I'm attempting the same thing and can't seem to find any useful information
Thanks in advance
qcha0s
|
|
|
|
|
Have you tried the owner draw technique?
There are 10 sorts of people in this world. Those who understand binary and those that don't.www.many-monkeys.com
|
|
|
|
|
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
|
|
|
|