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

1.1       root        1: // wclsedit.cpp : registered WNDCLASS Edit control example
                      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: #include "paredit.h"
                     15: 
                     16: /////////////////////////////////////////////////////////////////////////////
                     17: // Dialog class
                     18: 
                     19: class CWclsEditDlg : public CModalDialog
                     20: {
                     21: public:
                     22:        CWclsEditDlg()
                     23:                : CModalDialog(IDD_WNDCLASS_EDIT)
                     24:                { }
                     25: 
                     26:        // access to controls is through inline helpers
                     27:        CEdit&  Edit1()
                     28:                                { return *(CEdit*)GetDlgItem(IDC_EDIT1); }
                     29:        CEdit&  Edit2()
                     30:                                { return *(CEdit*)GetDlgItem(IDC_EDIT2); }
                     31:        CEdit&  Edit3()
                     32:                                { return *(CEdit*)GetDlgItem(IDC_EDIT3); }
                     33:        CEdit&  Edit4()
                     34:                                { return *(CEdit*)GetDlgItem(IDC_EDIT4); }
                     35: 
                     36:        BOOL OnInitDialog();
                     37:        void OnOK();
                     38: 
                     39:        void OnIllegalChar();
                     40:        DECLARE_MESSAGE_MAP();
                     41: };
                     42: 
                     43: BOOL CWclsEditDlg::OnInitDialog()
                     44: {
                     45:        // nothing special to do
                     46:        return TRUE;
                     47: }
                     48: 
                     49: void CWclsEditDlg::OnOK()
                     50: {
                     51: #ifdef _DEBUG
                     52:        // dump results, normally you would do something with these
                     53:        CString s;
                     54:        Edit1().GetWindowText(s);
                     55:        TRACE("edit1 = '%s'\n", (const char*) s);
                     56:        Edit2().GetWindowText(s);
                     57:        TRACE("edit2 = '%s'\n", (const char*) s);
                     58:        Edit3().GetWindowText(s);
                     59:        TRACE("edit3 = '%s'\n", (const char*) s);
                     60:        Edit4().GetWindowText(s);
                     61:        TRACE("edit4 = '%s'\n", (const char*) s);
                     62: #endif
                     63: 
                     64:        EndDialog(IDOK);
                     65: }
                     66: 
                     67: /////////////////////////////////////////////////////////////////////////////
                     68: // Handle custom control notification here
                     69: 
                     70: BEGIN_MESSAGE_MAP(CWclsEditDlg, CModalDialog)
                     71:        ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT1, OnIllegalChar)
                     72:        ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT2, OnIllegalChar)
                     73:        ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT3, OnIllegalChar)
                     74:        ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT4, OnIllegalChar)
                     75: END_MESSAGE_MAP()
                     76: 
                     77: 
                     78: void  CWclsEditDlg::OnIllegalChar()
                     79: {
                     80:        TRACE("Don't do that!\n");
                     81:        // add extra reporting here...
                     82: }
                     83: 
                     84: /////////////////////////////////////////////////////////////////////////////
                     85: // Run the test
                     86: 
                     87: void CTestWindow::OnTestWndClassEdit()
                     88: {
                     89:        TRACE("running dialog containing WNDCLASS special edit items\n");
                     90:        if (!CParsedEdit::RegisterControlClass())
                     91:        {
                     92:                MessageBox("Failed to register WNDCLASS for parsed control");
                     93:                return;
                     94:        }
                     95:        CWclsEditDlg dlg;
                     96:        dlg.DoModal();
                     97: }
                     98: 
                     99: 
                    100: /////////////////////////////////////////////////////////////////////////////

unix.superglobalmegacorp.com

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