123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- // TestDlg1.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "TestDlg1.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // TestDlg dialog
- TestDlg::TestDlg(CWnd* pParent /*=NULL*/)
- : CDialog(TestDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(TestDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void TestDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(TestDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(TestDlg, CDialog)
- //{{AFX_MSG_MAP(TestDlg)
- ON_WM_CTLCOLOR()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // TestDlg message handlers
- BOOL TestDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CRect rc;
- GetDlgItem(IDC_STATIC5)->GetWindowRect(rc);
- ScreenToClient(rc);
- m_propertySheet.m_Rect = rc;
- m_propertySheet.m_nPages = -1; // init this membervariable
- m_propertySheet.m_nActPage = 0; // init this membervariable
- m_propertySheet.m_nCtrlID = 2000; // control-id in the dialog
- // and create it on the screen
- m_propertySheet.Create (WS_VISIBLE | WS_CHILD | WS_TABSTOP,
- m_propertySheet.m_Rect, this, m_propertySheet.m_nCtrlID);
- // Now add the dialogs page per page
- TC_ITEM Item;
- Item.mask = TCIF_TEXT;
- CMyPropertyPage *pPropPage;
-
- int nN;
- int nPages = 2; // in my example I have two pages
- for (nN = 0; nN < nPages; nN++)
- {
- pPropPage = new (CMyPropertyPage); // new it
-
- // Create the tab and the dialog
- switch (nN)
- {
- case 0: // page number 1 - a small example
- Item.pszText = _T("¹«Ë¾¼ò½é");
- pPropPage->m_strTitle = _T("&Page1"); // or get the title of m_fontPage - whatwever you want
- pPropPage->m_pDialogPage = (CMyPropDialog *) &m_propPage1;
- pPropPage->m_pDialogPage->Create (IDD_PROPPAGE1, &m_propertySheet);
- break;
- case 1: // page number 1 - a small example
- Item.pszText = _T("¹«Ë¾ww");
- pPropPage->m_strTitle = _T("&Page2"); // or get the title of m_fontPage - whatwever you want
- pPropPage->m_pDialogPage = (CMyPropDialog *) &m_propPage2;
- pPropPage->m_pDialogPage->Create (IDD_PROPPAGE2, &m_propertySheet);
- break;
- }
- m_propertySheet.InsertItem (nN, &Item); // this is fot CTabWnd
- pPropPage->m_hLocal = NULL; // nothing is created on the fly
- // important information on delete!
- // add it to the array
- m_propertySheet.m_Dialogs.Add (pPropPage);
- m_propertySheet.m_nPages++; // one more page
- // the size of CTabWnd is m_rect
- // the size of the dialog is smaller
- pPropPage->m_Rect.top = 30; // above there must be enough place for the tab-control
- pPropPage->m_Rect.left = 10; // border of 10 units is good
- pPropPage->m_Rect.bottom = m_propertySheet.m_Rect.bottom - m_propertySheet.m_Rect.top - 10;
- pPropPage->m_Rect.right = m_propertySheet.m_Rect.right - m_propertySheet.m_Rect.left - 10;
- // Only the 1. page should be active at startup
- if (nN > 0)
- {
- pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
- pPropPage->m_Rect.top, 0, 0,
- SWP_HIDEWINDOW | SWP_NOSIZE);
- }
- else
- {
- pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
- pPropPage->m_Rect.top, 0, 0,
- SWP_SHOWWINDOW | SWP_NOSIZE);
- }
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- extern CBrush g_editbkbrush;
- HBRUSH TestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
-
- if(nCtlColor==CTLCOLOR_STATIC)
- {
- char szTemp[MAX_PATH];
- GetClassName(pWnd->GetSafeHwnd (), szTemp, sizeof(szTemp));
- if(lstrcmpi(szTemp, "Edit") == 0)
- {
- pDC->SetBkColor( g_bkcol );
- return g_editbkbrush;
- }
- else
- {
- pDC->SetBkColor( g_bkcol );
- pDC->SetBkMode (TRANSPARENT);
- }
- return g_editbkbrush;
- }
- else if(nCtlColor==COLOR_BACKGROUND)
- {
- pDC->SetBkColor( g_bkcol );
- pDC->SetBkMode (TRANSPARENT);
- return g_editbkbrush;
- }
- // TODO: Return a different brush if the default is not desired
- return g_editbkbrush;
- }
|