Home | Products | Download | Purchase | Support 


   

ControlSample Sample

 

The ControlSample sample demonstrates the how to use the tab control and bitmap button control of E-XD++,  E-XD++ Library ships with many kind of extend controls, these controls can be used by your application at any place.

Steps:

1. Add the following codes within the header of dialog:
public:
CControlSampleDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CControlSampleDlg)
enum { IDD = IDD_CONTROLSAMPLE_DIALOG };
CFOImageButton m_ButtonCancel;
CFOImageButton m_ButtonOther;
CFOImageButton m_ButtonOpen;
CFOImageButton m_ButtonNew;
//}}AFX_DATA
CFOTabCtrl m_wndTab;
CFOTemplateWnd m_wndPage1;
CFOTemplateWnd m_wndPage2;
CFOTemplateWnd m_wndPage3;
CFOTemplateWnd m_wndPage4;

2.Add the following codes also:

void CControlSampleDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CControlSampleDlg)
	DDX_Control(pDX, IDOK, m_ButtonCancel);
	DDX_Control(pDX, IDC_BUTTON_TEMPLATE, m_ButtonOther);
	DDX_Control(pDX, IDC_BUTTON_OPEN, m_ButtonOpen);
	DDX_Control(pDX, IDC_BUTTON_NEW, m_ButtonNew);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CControlSampleDlg, CDialog)
	//{{AFX_MSG_MAP(CControlSampleDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CControlSampleDlg message handlers
#define TAB_ID 1232
#define TAB_PAGE1_ID 1233
#define TAB_PAGE2_ID 1234
#define TAB_PAGE3_ID 1235
#define TAB_PAGE4_ID 1236

BOOL CControlSampleDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_ButtonNew.SetBitmap(IDB_BITMAP_NEW);
	m_ButtonNew.SetBtnCursor(IDC_FO_HAND);
	m_ButtonOpen.SetBitmap(IDB_BITMAP_OPEN);
	m_ButtonOpen.SetBtnCursor(IDC_FO_HAND);
	m_ButtonOther.SetBitmap(IDB_BITMAP_OTHER);
	m_ButtonOther.SetBtnCursor(IDC_FO_HAND);
	m_ButtonCancel.SetBtnCursor(IDC_FO_HAND);

	// TODO: Add extra initialization here
	CRect theRect;
	GetDlgItem(IDC_TABPOS)->GetWindowRect( &theRect );
	ScreenToClient(&theRect);	
	
	// Create tab control at first.
	DWORD dwStyle = WS_CHILD | WS_VISIBLE | FOP_TS_ALIGN_TOP | WS_TABSTOP;
	m_wndTab.Create(this, dwStyle);
	m_wndTab.SetWindowPos(&wndTop,theRect.left,theRect.top,theRect.Width(),theRect.Height(),SWP_SHOWWINDOW);

	// Empty rectangle.
	theRect.SetRectEmpty();

	CFOModelBoxItem *pItem = NULL;

	// Create first page.
	m_wndPage1.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_EX_CLIENTEDGE,theRect,&m_wndTab,TAB_PAGE1_ID);	
	m_wndTab.AddTab(&m_wndPage1,_T("Page 1"));
	m_wndTab.SetTabPageIcon(0,IDI_FILE_ICON,CSize(32,32));
	pItem = m_wndPage1.AddNewItem();
	pItem->SetLinkFileName("1.xxx");
	pItem = m_wndPage1.AddNewItem();
	pItem->SetLinkFileName("1.xxx");
	pItem = m_wndPage1.AddNewItem();
	pItem->SetLinkFileName("1.xxx");
	pItem = m_wndPage1.AddNewItem();
	pItem->SetLinkFileName("1.xxx");
	pItem = m_wndPage1.AddNewItem();
	pItem->SetLinkFileName("1.xxx");
	m_wndPage1.SetBkColor(RGB(231,231,231));


	// Create the second page.
	m_wndPage2.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_EX_CLIENTEDGE,theRect,&m_wndTab,TAB_PAGE2_ID);	
	m_wndTab.AddTab(&m_wndPage2,_T("Page 2"));
	m_wndTab.SetTabPageIcon(1,IDI_FILE_ICON,CSize(32,32));
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	pItem = m_wndPage2.AddNewItem();
	pItem->SetLinkFileName("2.xxx");
	m_wndPage2.SetBkColor(RGB(192,192,255));


	// Create the third page.
	m_wndPage3.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_EX_CLIENTEDGE,theRect,&m_wndTab,TAB_PAGE3_ID);
	m_wndTab.AddTab(&m_wndPage3,_T("Page 3"));
	m_wndTab.SetTabPageIcon(2,IDI_FILE_ICON,CSize(32,32));
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	pItem = m_wndPage3.AddNewItem();
	pItem->SetLinkFileName("3.xxx");
	m_wndPage3.SetBkColor(RGB(255,254,248));

	// Create the forth page.
	m_wndPage4.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_EX_CLIENTEDGE,theRect,&m_wndTab,TAB_PAGE4_ID);	
	m_wndTab.AddTab(&m_wndPage4,_T("Page 4"));
	m_wndTab.SetTabPageIcon(3,IDI_FILE_ICON,CSize(32,32));
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	pItem = m_wndPage4.AddNewItem();
	pItem->SetLinkFileName("4.xxx");
	m_wndPage4.SetBkColor(RGB(0,204,153));

	m_wndTab.ActivateTab(0);
	m_wndTab.GetTabControl()->SetTabPageIconSize(32);
	m_wndTab.SetTabTotalHeightOrWidth(40);
//	m_wndTab.SetDrawFlatBorder(TRUE);
	m_wndTab.SetDrawMoneyMode(TRUE);
	m_wndTab.SetDrawMark(FALSE);
	m_wndTab.GetTabControl()->SetInflating(TRUE);
//	m_wndTab.GetTabControl()->SetActiveTabBkColor(RGB(192,192,255));
//	m_wndTab.GetTabControl()->SetInActiveTabBkColor(RGB(255,254,248));
	m_wndTab.UpdateWindow();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



[ Home | Products | Download Area | Purchase | SupportContact us ]


Copyright ?1998-2007 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.com