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

1.1       root        1: // bbutton.cpp : bitmap button test
                      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: /////////////////////////////////////////////////////////////////////////////
                     16: // BitmapButton Test dialog #1
                     17: 
                     18: // In this example we pass the bitmap resource names in the constructor
                     19: //  for the buttons.  OnInitDialog is used to Subclass the buttons
                     20: //  so the dialog controls get attached to the MFC WndProc for C++
                     21: //  message map dispatch.
                     22: 
                     23: class CBMTest1Dlg : public CModalDialog
                     24: {
                     25: protected:
                     26:        // construct
                     27:        CBitmapButton button1, button2;
                     28: public:
                     29:        CBMTest1Dlg()
                     30:                : CModalDialog(IDM_TEST_BITMAP_BUTTON1),
                     31:                        button1("Image1Up", "Image1Down", "Image1Focus"),
                     32:                        button2("Image2Up", "Image2Down", "Image2Focus")
                     33:                { }
                     34: 
                     35:        BOOL OnInitDialog();
                     36:        void OnOK();
                     37: };
                     38: 
                     39: BOOL CBMTest1Dlg::OnInitDialog()
                     40: {
                     41:        // each dialog control has special bitmaps
                     42:        VERIFY(button1.SubclassDlgItem(IDOK, this));
                     43:        button1.SizeToContent();
                     44:        VERIFY(button2.SubclassDlgItem(IDCANCEL, this));
                     45:        button2.SizeToContent();
                     46: 
                     47:        return TRUE;
                     48: }
                     49: 
                     50: void CBMTest1Dlg::OnOK()
                     51: {
                     52:        EndDialog(IDOK);
                     53: }
                     54: 
                     55: /////////////////////////////////////////////////////////////////////////////
                     56: // BitmapButton Test dialog #2
                     57: 
                     58: // In this example we use the CBitmapButton AutoLoad member function.
                     59: //  Autoload uses the text/title of the button as the base resource name.
                     60: //  For this trivial example the buttons are called "OK" and "CANCEL",
                     61: //  which use the bitmaps "OKU", "OKD", "OKF", "CANCELU", "CANCELD"
                     62: //  and "CANCELF" respectively for the up, down and focused images.
                     63: 
                     64: #define ID_BUTTON_MIN       IDOK
                     65: #define N_BUTTONS   (IDCANCEL - ID_BUTTON_MIN + 1)
                     66: 
                     67: class CBMTest2Dlg : public CModalDialog
                     68: {
                     69: protected:
                     70:        // construct
                     71:        CBitmapButton buttons[N_BUTTONS];
                     72:                // array of buttons constructed with no attached bitmap images
                     73: public:
                     74:        CBMTest2Dlg()
                     75:                : CModalDialog(IDM_TEST_BITMAP_BUTTON2)
                     76:                { }
                     77: 
                     78:        BOOL OnInitDialog();
                     79:        void OnOK();
                     80: };
                     81: 
                     82: BOOL CBMTest2Dlg::OnInitDialog()
                     83: {
                     84:        // load bitmaps for all the bitmap buttons (does SubclassButton as well)
                     85:        for (int i = 0; i < N_BUTTONS; i++)
                     86:                VERIFY(buttons[i].AutoLoad(ID_BUTTON_MIN + i, this));
                     87:        return TRUE;
                     88: }
                     89: 
                     90: void CBMTest2Dlg::OnOK()
                     91: {
                     92:        EndDialog(IDOK);
                     93: }
                     94: 
                     95: /////////////////////////////////////////////////////////////////////////////
                     96: // Test driver routines
                     97: 
                     98: void CTestWindow::OnTestBitmapButton1()
                     99: {
                    100:        CBMTest1Dlg dlg;
                    101:        dlg.DoModal();
                    102: }
                    103: 
                    104: void CTestWindow::OnTestBitmapButton2()
                    105: {
                    106:        CBMTest2Dlg dlg;
                    107:        dlg.DoModal();
                    108: }
                    109: 
                    110: /////////////////////////////////////////////////////////////////////////////

unix.superglobalmegacorp.com

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