YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
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++ Example: Creating a CTabCtrl Application

 
 Ben Hill
April 3, 2000 

Environment: VC6 SP3, NT4, Windows 2000 Pro, Windows 2000 Server

Firstly add the CMyTabCtrl.cpp and CMyTabCtrl.h to your project.

Using Visual Studio add a CTabCtrl control to your dialog. Add a member variable for this control as a CMyTabCtrl type not a simple CTabCtrl. CMyTabCtrl is derived from CTabCtrl.

You can simply add a CTabCtrl member variable and manually edit the file to become CMyTabCtrl

Now create dialogs for every page you require. These must be child dialogs with no border. Any controls here in these dialogs are handled by their own class.

Create a Class for each dialog. In the example these are CTabOne, CTabTwo and CTabThree.

In the CmyTabCtrl constructor you must add a new for each page. Also in the Init function you must specify all tab dialogs to hide all but one

In this example the OnLButtonDown message handler is used to show and hide the various dialogs. The page is managed with a variable m_tabCurrent which holds the value of selected pages.

In the main app dialogs OnInitDialog message handler add the tabs you require for your dialog. In this example these are Tab One, Tab Two and Tab Three.

Functionality for the left and right cursor keys to select the tabs can be added in the CMyTabCtrl class.

CMyTabCtrl::CMyTabCtrl()
{
 m_tabPages[0]=new CTabOne;
 m_tabPages[1]=new CTabTwo;
 m_tabPages[2]=new CTabThree;

 m_nNumberOfPages=3;
}

CMyTabCtrl::~CMyTabCtrl()
{
 for(int nCount=0; nCount < m_nNumberOfPages; nCount++){
  delete m_tabPages[nCount];
 }
}

void CMyTabCtrl::Init()
{
 m_tabCurrent=0;

 m_tabPages[0]->Create(IDD_TAB_ONE, this);
 m_tabPages[1]->Create(IDD_TAB_TWO, this);
 m_tabPages[2]->Create(IDD_TAB_THREE, this);

 m_tabPages[0]->ShowWindow(SW_SHOW);
 m_tabPages[1]->ShowWindow(SW_HIDE);
 m_tabPages[2]->ShowWindow(SW_HIDE);

 SetRectangle();
}

void CMyTabCtrl::SetRectangle()
{
 CRect tabRect, itemRect;
 int nX, nY, nXc, nYc;

 GetClientRect(&tabRect);
 GetItemRect(0, &itemRect);

 nX=itemRect.left;
 nY=itemRect.bottom+1;
 nXc=tabRect.right-itemRect.left-1;
 nYc=tabRect.bottom-nY-1;

 m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
 for(int nCount=1; nCount < m_nNumberOfPages; nCount++){
  m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
 }
}


//////////////////////////////////////////////////////
// CMyTabCtrl message handlers

void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
 CTabCtrl::OnLButtonDown(nFlags, point);

 if(m_tabCurrent != GetCurFocus()){
  m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
  m_tabCurrent=GetCurFocus();
  m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
  m_tabPages[m_tabCurrent]->SetFocus();
 }
}

The Dialog Showing, Hiding and Drawing code is from the C++ Forum On this site. It was posted by someone whom I don't have name for.

If it was you then please let me know and I will have your name added

I hope this code is of some use. It has helped me to develop much more complex dialogs.

Downloads

Download demo project - 18 Kb
Download source - 2 Kb

 

 

 

Copyright ?1998-2024 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