I have a split screen application with two panes. I would like to assign different views to each pane. I created the application using th wizard, which created a class called CSplitMFCView, a subclass of CView.
I added the following two lines in the OnCreateClient function of MainFrm.cpp - m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitMFCView), CSize(1, 1), pContext);
-
-
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CView), CSize(10, 10), pContext);
In order to differentiate between the two views, I modified the OnDraw function of CSplitMFCView so that it prints a red rectangle in the view. I added those lines: - pDC->SetBkColor(RGB(152,0,0));
-
-
pDC->FillSolidRect(1, 1, 200, 200, RGB(255,0,0));
What I thought would happen is that the first pane would have the red rectangle, and the second pane would be the default CView pane, which should be white. This was not the case, both panes have the red rectangle.
How can I fix this?
Thanks.
5 2169 Banfa 9,065
Expert Mod 8TB - m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitMFCView), CSize(1, 1), pContext);
-
-
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CView), CSize(10, 10), pContext);
I have to say this looks correct (assuming you created your splitter window 2 high and 1 wide).
Have your tried building it for debug and stepping through this part of the code in the debugger, see if anything obvious is going wrong.
This is what I did to create the splitter: - (m_wndSplitter.Create(this, 2 , 1, CSize(10, 10), pContext))
It seems correct to me. I'll try debugging.
Edit: - m_wndSplitter.SplitRow(350);
That's where I split horizontally.
Also, in my main app's CPP, there is this in the initialization: - CSingleDocTemplate* pDocTemplate;
-
pDocTemplate = new CSingleDocTemplate(
-
IDR_MAINFRAME,
-
RUNTIME_CLASS(CSplitMFCDoc),
-
RUNTIME_CLASS(CMainFrame), // main SDI frame window
-
RUNTIME_CLASS(CSplitMFCView));
Could this have something to do with it? The CreateView method does take in a RUNTIM_CLASS variable.
I think I found out what's wrong. I had placed the CreateView function in OnCreateClient, but at that point, the SplitRow function hasn't been called, so it gave me errors.
I tried putting the SplitRow function before that but it fails, and I get the two views on top of each other (I verified this by using different colored squares for every view).
In OnCreateClient of MainFrm.cpp - m_wndSplitter.SplitRow(350);
-
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitMFCView), CSize(100, 100), pContext);
-
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CMyView), CSize(100, 100), pContext);
Any other ideas?
Banfa 9,065
Expert Mod 8TB
Actually (having read the documentation on splitter windows more carefully) I think your problem is that you are calling m_wndSplitter.Create when you actually need to be calling m_wndSplitter.CreateStatic.
Create creates a dynamic splitter window, in a dynamic splitter window all panes use the same class ( read this).
CreateStatic - creates a static splitter window, in this case different cases can be different classes.
below is the working code directly from one of my projects that uses a splitter window to display 2 different views. -
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
-
CCreateContext* pContext)
-
{
-
// create splitter window
-
if (!m_wndSplitter.CreateStatic(this, 1, 2))
-
return FALSE;
-
-
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) ||
-
!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CSBSView), CSize(100, 100), pContext))
-
{
-
m_wndSplitter.DestroyWindow();
-
return FALSE;
-
}
-
-
m_wndSplitter.SetColumnInfo(0, 200, 20);
-
-
return TRUE;
-
}
-
Thanks a lot! This information is great and it helped me fix the issue I had. I'm saving it for future reference.
Thanks again for your help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: SL_McManus |
last post by:
Hi All;
I am fairly new to Perl. I have a file with close to 3000 lines
that I would like to split out in a certain way. I would like to put
the record type starting in column 1 for 2 spaces,...
|
by: Steve Jorgensen |
last post by:
Hi all,
I'm working on the schema for a database that must represent data about stock
& bond funds over time. My connundrum is that, for any of several dimension
fields, including the fund name...
|
by: seash |
last post by:
H
iam developing my windows form application(ide:visual studio.net 2003, visual c#) on windows 2000 professional operating system , but when i run the exe on Xp operating system, the screen ...
|
by: Michael Glaesemann |
last post by:
Hello all,
Recently I've been thinking about different methods of managing users
that log into a PostgreSQL-backed application. The users I'm thinking
of are not necessarily DBAs: they're...
|
by: johnny |
last post by:
hi all,
I would like to test different page layout / creative elements of a
website using a A/B/C split run test.
How could I set it up using php?
Basically, I would like to include a...
|
by: Venkat |
last post by:
Hi,
Ours is a windows based application and I have to perform an
action which takes much time (as it requires much CPU time) on a single pc.
I want to split the action to more than two and I...
|
by: ahammad |
last post by:
Hello,
I used the Doc/View architecture to create a split screen application. On startup, the screen is already split horizontally. I did the following in the MainFrm class:
BOOL...
|
by: Mike TI |
last post by:
Nov 13, 2007
Hi all
I have an application that comprises of three modules.
Initially a screen is displayed. Upon selection from a menu on this screen,
module 1, module 2 or module 3 is...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
A lot of users at my workplace use different screen resolutions, and I build
apps to use 1680 x 1050 pixels res by default. But some users are using 800
x 600, and the apps are too large for their...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |