473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Split Screen application and assigning different views

79
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

Expand|Select|Wrap|Line Numbers
  1. m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitMFCView), CSize(1, 1), pContext);
  2.  
  3. 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:

Expand|Select|Wrap|Line Numbers
  1. pDC->SetBkColor(RGB(152,0,0));
  2.  
  3. 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.
Aug 28 '07 #1
5 2169
Banfa
9,065 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitMFCView), CSize(1, 1), pContext);
  2.  
  3. 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.
Aug 28 '07 #2
ahammad
79
This is what I did to create the splitter:

Expand|Select|Wrap|Line Numbers
  1. (m_wndSplitter.Create(this, 2 , 1, CSize(10, 10), pContext))
It seems correct to me. I'll try debugging.

Edit:

Expand|Select|Wrap|Line Numbers
  1. m_wndSplitter.SplitRow(350);
That's where I split horizontally.

Also, in my main app's CPP, there is this in the initialization:

Expand|Select|Wrap|Line Numbers
  1.     CSingleDocTemplate* pDocTemplate;
  2.     pDocTemplate = new CSingleDocTemplate(
  3.         IDR_MAINFRAME,
  4.         RUNTIME_CLASS(CSplitMFCDoc),
  5.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  6.         RUNTIME_CLASS(CSplitMFCView));
Could this have something to do with it? The CreateView method does take in a RUNTIM_CLASS variable.
Aug 28 '07 #3
ahammad
79
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
Expand|Select|Wrap|Line Numbers
  1. m_wndSplitter.SplitRow(350);
  2. m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitMFCView), CSize(100, 100), pContext);
  3. m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CMyView), CSize(100, 100), pContext);
Any other ideas?
Aug 28 '07 #4
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.

Expand|Select|Wrap|Line Numbers
  1. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
  2.     CCreateContext* pContext)
  3. {
  4.     // create splitter window
  5.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  6.         return FALSE;
  7.  
  8.     if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) ||
  9.         !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CSBSView), CSize(100, 100), pContext))
  10.     {
  11.         m_wndSplitter.DestroyWindow();
  12.         return FALSE;
  13.     }
  14.  
  15.     m_wndSplitter.SetColumnInfo(0, 200, 20);
  16.  
  17.     return TRUE;
  18. }
  19.  
Aug 28 '07 #5
ahammad
79
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.
Aug 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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,...
9
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...
2
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 ...
3
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...
5
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...
3
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...
2
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...
7
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...
10
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.