YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
View in English
View in Japanese
View in
참고
View in Français
View in Italiano
View in 中文(繁體)
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


VC++ Article: CSplitterWnd Extension that Allows Create Multiple Views, and Switch Views in Any Pane

By Caroline Englebienne

This article explains how to switch between multiple views in a splitter window pane without deleting and re-creating views. It is inefficient to create & destroy views, and often disrupts an application's design, yet the only examples of switching views I have found are doing just that! I have created a CSplitterWnd replacement class that adds the multiple views per pane functionality in a lightweight and easy to use way. NOTE: This class is intended for static splitters only, not dynamic ones.

I. How to use my code

I derived a class (AW_CMultiViewSplitter) from CSplitterWnd. You can simply include the files AW_CMultiViewSplitter.h and AW_CMultiViewSplitter.cpp to your project, use a AW_CMultiViewSplitter instead of a classic splitter window and call the 2 following functions:

int AddView(int nRow, int nCol, CRuntimeClass * pViewClass, CCreateContext* pContext)
This function should be called where you would usually call CreateView() but you want more than one view for the pane. If you only need a single view, just call CreateView(), as usual. AddView() returns an int, which is the ID of the newly created view. This ID is used in the function ShowView() if you want to make this new view visible.

void ShowView(int viewID)
This function takes a viewID as its only parameter. This function takes care of hiding the previously visible view and showing the requested one.

II. Points of interest

I will skip the detailed code here and just explain the basic idea that makes it work. For the details, you can download the little sample I wrote to illustrate the use of my splitter window.

The 2 point of interest are:
- how to create multiple views in a same pane
- how to switch between views
 

How to create multiple views in a same pane

In a classic splitter window, when a view is created in a pane, its window identifier is set to an ID computed from the row and column numbers corresponding to the pane. Therefore, when you have multiple views for a pane, you must set all but one to ID zero as well as hide all the non-visible views.

The following code block demonstrates how to add a new view to a pane when one is currently assigned to the pane:

HideCurrentView(nRow, nCol)
{
 CWnd * pView  = GetCurrentView(pane.row, pane.col);
 pView->SetDlgCtrlID(0);
 pView->ShowWindow(SW_HIDE);
}

CreateView(nRow, nCol, pViewClass, CSize(10,10), pContext);

SetCurrentView(nRow, nCol, newViewID)
{
 CWnd * pView  = GetView( viewID);
 pView->SetDlgCtrlID(IdFromRowCol(pane.row, pane.col));
 pView->ShowWindow(SW_SHOW);
}

How to switch between windows

The window that is displayed is the one whose identifier is the ID computed from the row and column numbers. Then, to switch views, you just need to get the visible one, set its ID to something else, hide it, get the window you want to see, set its ID to the good one (obtained by calling IdFromRowCol), show it, and refresh the splitter.

GetPaneFromViewID(viewID);
HideCurrentView(pane.row, pane.col);
SetCurrentView(pane.row, pane.col, viewID);

Downloads

Download demo project - 29 Kb
Download source - 3 Kb

 

 

 

Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net