Annotation of mstools/mfc/samples/ctrltest/dlgpen.cpp, revision 1.1.1.1

1.1       root        1: // dlgpen.cpp : regular dialog template using pen controls
                      2: //
                      3: // This is a part of the Microsoft Foundation Classes C++ library.
                      4: // Copyright (C) 1992 Microsoft Corporation
                      5: // All rights reserved.
                      6: //
                      7: // This source code is only intended as a supplement to the
                      8: // Microsoft Foundation Classes Reference and Microsoft
                      9: // QuickHelp documentation provided with the library.
                     10: // See these sources for detailed information regarding the
                     11: // Microsoft Foundation Classes product.
                     12: 
                     13: #include "ctrltest.h"
                     14: 
                     15: // we need the MFC extensions for PenWindows
                     16: #include <afxpen.h>
                     17: 
                     18: /////////////////////////////////////////////////////////////////////////////
                     19: // Dialog class
                     20: 
                     21: class CPenEditDlg : public CModalDialog
                     22: {
                     23: public:
                     24:        CPenEditDlg()
                     25:                : CModalDialog(IDD_SUB_PENEDIT)
                     26:                { }
                     27: 
                     28:        // access to controls is through inline helpers
                     29:        CHEdit& Edit1()
                     30:                                { return *(CHEdit*)GetDlgItem(IDC_EDIT1); }
                     31:        CHEdit& Edit2()
                     32:                                { return *(CHEdit*)GetDlgItem(IDC_EDIT2); }
                     33:        CBEdit& Edit3()
                     34:                                { return *(CBEdit*)GetDlgItem(IDC_EDIT3); }
                     35:        CBEdit& Edit4()
                     36:                                { return *(CBEdit*)GetDlgItem(IDC_EDIT4); }
                     37: 
                     38:        BOOL OnInitDialog();
                     39:        void OnOK();
                     40: };
                     41: 
                     42: BOOL CPenEditDlg::OnInitDialog()
                     43: {
                     44:        // any special init goes here
                     45: 
                     46:        // There are many ways to customize HEdit and BEdit controls which
                     47:        //  can be done in OnInitDialog.
                     48:        //  Here is just one example of setting BOXLAYOUT to draw complete
                     49:        //  rectangles for boxes (regardless of global defaults which is
                     50:        //  usually combs).
                     51:        CBEdit* pBEdit = &Edit4();
                     52: 
                     53:        CRect rect;
                     54:        pBEdit->GetClientRect(rect);        // how high is it ?
                     55:        BOXLAYOUT boxlayout;
                     56:        pBEdit->GetBoxLayout(&boxlayout);   // what are the current settings ?
                     57:        boxlayout.style |= BXS_RECT;
                     58:        boxlayout.cyCusp = rect.Height() - 10;  // a reasonable size
                     59:        VERIFY(pBEdit->SetBoxLayout(&boxlayout));
                     60: 
                     61:        return TRUE;
                     62: }
                     63: 
                     64: void CPenEditDlg::OnOK()
                     65: {
                     66: #ifdef _DEBUG
                     67:        // dump results, normally you would do something with these
                     68:        CString s;
                     69:        Edit1().GetWindowText(s);
                     70:        TRACE("edit1 = '%s'\n", (const char*) s);
                     71:        Edit2().GetWindowText(s);
                     72:        TRACE("edit2 = '%s'\n", (const char*) s);
                     73:        Edit3().GetWindowText(s);
                     74:        TRACE("edit3 = '%s'\n", (const char*) s);
                     75:        Edit4().GetWindowText(s);
                     76:        TRACE("edit4 = '%s'\n", (const char*) s);
                     77: #endif
                     78: 
                     79:        EndDialog(IDOK);
                     80: }
                     81: 
                     82: /////////////////////////////////////////////////////////////////////////////
                     83: // Run the test
                     84: 
                     85: void CTestWindow::OnTestPenEditFromTemplate()
                     86: {
                     87:        TRACE("running dialog with BEDIT controls in it\n");
                     88:        CPenEditDlg dlg;
                     89:        dlg.DoModal();
                     90: }
                     91: 
                     92: 
                     93: /////////////////////////////////////////////////////////////////////////////

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.