      ,     

       ,      , 
    Windows.       
 .     ,   ,  
  ,  Windows  .    ,  
    .  ,  , 
       ,   
Windows.          
 . 
    
    163 

    ,      , 
  .      
 .      
,    Windows-.    
   ,        
.  ,       .   
         . 

        

           
   .    ,   
  .        
 .         
  .     ,   
    Microsoft,   . 7.1. 

    . 7.1.        


    164 MFC:   

        : 32  32 .  Windows 3.1 
  ,   ,  3232.  
  Windows 95    .     
 ( 3232).    ( 1616 ).  
      Windows.  
 (  )  ,   
 ,     Explorer,   
 Large Icons,        .  
    Explorer   Small Icons,   
           
(task bar).    ,   
Microsoft  Visual C++  4 ( ),      
      .     , , 
 ,        
.    ,  MFC   . 
 Windows 95      4848 ,   
         . 
         ,     
     ICON  CURSOR.     : 

      ICON   

      CURSOR   

      _  _  , 
, ,   .   
     .  _  
 ,     . 
           MY1CON   
MYCURSOR.   4)      
    ICON.ICO,      CURSOR.CUR.   
   : 

    MYCURSOR CURSOR CURSOR.CUR 
    MY1CON ICON ICON.ICO 


        

          ,   
    .       
 ,   MFC    . 
      / ,  
     .     2,   
  AfxRegisterWiidClass().   : 

    LPCSTR AFXAPI AfxRegisterWndClass(UINT Style, 
    HCURSOR hCur=0, II   
    HBRUSH hBrush-^O, II   
    HICON hIcon^O); II   


    7.   ,     165 

            , 
        CreateQ   . 
     Style     .   
    .      
Style  .       
,    ,  : , *  
  . ..    , hBrush  
 ,       , a 
hicon     .  ,  
   .      
Windows-    .  MFC   
.       ,  
   .        
AfxRegisterWndClass().  ,  MFC     
.   ,      . 

        

         ,   
    .     Loadlcon() 
 LoadCursor(),    CWinApp.    
 ,     , : 

    HICON CWinApp::LoadIcon(LPCSTR IpszIconName} const; 
    HCURSOR CWinApp::LoadCursor(LPCSTR IpszCursorName) const; 

     Ips^IconName        
 IpszCursorName    .  LoadIconQ 
      .   ,  
 ,   LoadCursorQ.    NULL,  
    . 
            
 ,        
 AfxRegisterWndClass(). 

        

       (   )     
9,       GDI-.   
   . 
       ,      
  ,        
1 .  ,   (brush),   , 
         
  ,     ,   
.  |      ,  
   - |  .     
  (  i ,    ). 
   CBrush,     CGdiObject. 

    *    , . .  . . 


    166                                        MFC:   

           CreateStockObjectQ, 
   CGdiObject.   : 

    BOOL CGdiObject::CreateStockObject(int Item}; 

      Item   GDI-,   
 (       ).   
  ,      (. 7.1): 

     7.1.    

    	  

    BLACKBRUSH	 
    DKGRAYJBRUSH	- 
    HOLLOWBRUSH	"" 
    LTGRAYBRUSH	- 
    WHITEBRUSH	 

       ,      
,      . 
      ,       
Aft(RegisterWndClass(),    : 

    CBrush bkbrush; 
    //   
    bkbrush.CreateStockObject(WHITE_BRUSH) ; 

       ,      
 .   bkbrush      
hBrush   AfxRegisterWndClassQ,   CBrush  
  CBrush   HBRUSH. 
        ,   MFC,  
   .     
WHITE_BRUSH.        .  
    . 

     ,      

           . 
   ,     
  (..   ).     
Windows 95,        , 
       .    
   ,    ,  
      Explorer   Large Icons. 
          
  .  , 

    7.   ,        167 

               
,    -       
     . 
        ,      
     ( ,  Windows 
95)  ,        . 
        IC.H,     : 

    // IC.H 
    //       
    class CMainWin : public CFrameWnd 
    { 
    public: 
    CMainWin(LPCSTR ClassName); //    
    //     
    DECLARE_MESSAGE_MAP() 
    }; 
    //      
    class CApp : public CWinApp 
    { 
    public: 
    BOOL Initlnstance () ; 
    }; 

     ,   CMainWin()   , 
        . 
      : 

    // ,      
    ftinclude <afxwin.h> 
    #include "ic.h" 
    //  ,     
    CMainWin::CMainWin(LPCSTR ClassName) 
    ( 
    Create(ClassName, "Custom Icon and Cursor"); 
    //   
    BOOL CApp::Initlnstance() 
    ( 
    CBrush bkbrush; 
    //   
    bkbrush.CreateStockObject(WHITE_BRUSH) ; 


    168                                    MFC:   


    LPCSTP, cname = AfxRegisterWndClass(0, 
    LoadCursor("MYCURSOR" 
    bkbrush, 
    Loadlcon("MYICON")) ; 
    m pMainWnd = new CMainWin(cname); 
    m pMainWnd->ShowWindow(m nCmdShow) ; 
    m pMainWnd->UpdateWindow(); 
    return TRUE; 
    //     
    BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) 
    END_MESSAGE_MAP() 
    CApp App; //    

         CApp::InitInstaiice().   
   ,       
.         
  ,    .  ,  
 AfxRegisterWndClassQ,      
CMainWinQ,     .    
 ,    ,     
 CreateQ. 
         . 7.2. (,    
.  , ,  .  ,  Windows 95 
   .)     
,  ,        
. ,   ,    . 

    . 7.2.   


         

     Windows      ,  
     .       
 Loadlcon()  LoadCursorQ,   LoadStandardIcon()  
LoadStandardCursor().   : 

    HICON CWinApp::LoadStandardIcon(LPCSTR Ipszlcon) const.; 
    HCURSOR CWinApp::LoadStandardCursor(LPCSTR IpszCursor) const; 


    7.   ,        169 

      Ips^lcon       
     (. 7.2): 

     7.2.   Windows 

    IDIAPPLICATION IDIASTERISK IDIEXCLAMATION IDIHAND IDIQUESTION 
IDIWINLOGO	     
   "I"       
 "Stop"        
Windows 95 
     /pszCursor    .  
    (. 7.3): 

     7.3.     Windows 

    IDCARROW IDCCROSS I DC J BEAM IDC WAIT	  
  ""      
    \JU\^    4/J -l.ytfl    U\J^JLl^ft.lLU,l.l,l\J 1    11^/1 1^'^1^/1--/^ 
  ^lILl^^/llfl-'   J 1 ^/*    J >-H ^ 1-1-1  H-*i?l    ->U iJ\/J-/l-l-l 
V/I If in             , 
    NULL    .                                                 | 

      ,      
 j  .    SYSIC.H,    
:  ! 

    // SYSIC.H                                                            | 
    //       
    class CMainWin : public CFrameWnd 
    { 
    public: 
    CMainWin(LPCSTR ClassName); //    
    //     
    DECLARE_MESSAGE_MAP () 
    ); 
    //      
    class CApp : public CWinApp 
    ( 
    public: 
    BOOL Initlnstance() ; 
    ); 


    170                                    MFC:   

       : 

    // ,      
    itinclude <afxwin.h> 
    tinclude "sysic.h" 
    //  ,     
    CMainWin::CMainWin(LPCSTR ClassName) 
    ( 
    Create(ClassName, "Using a Predefined Icon and Cursor"); 
    } 
    //   
    BOOL CApp::Initlnstance() ( 
    CBrush bkbrush; 
    //   
    bkbrush.CreateStockObj ect(WHITE_BRUSH) ; 
    LPCSTR cname = AfxRegisterWndClass(0, 
    LoadStandardCursor(IDC_CROSS), 
    bkbrush, 
    LoadStandardIcon(IDI_QUESTION)) ; 
    m_pMainWnd = new CMainWin(cname) ; 
    m_pMainWnd->ShowWindow(m_nCmdShow) ; 
    m_pMainWnd->UpdateWindow() ; 
    return TRUE; 
    1 
    //     
    BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) 
    END_MESSAGE_MAP() 
    CApp App; //    

             
 ,          
     . 

        

         .  
Windows    ,    
    .     
 ,   API    MFC,  
 , ,     , 
   .    ,    
  

    7.   ,        171 

             . 
     ,  
     .     
,     .  ,  
   ,       
.    MFC   CBitmap. 

       

             
,      .   
      ,     
 . ,      ,  
 ,       . 
  i     6464 .  
  ..     ,   : 

    MYBPl BITMAP . 

     ,   BITMAP    
.    : 

      BITMAP   

      _  ,   
.         . ); 
   ,     .      

    ; 
         

            ,   
     .     ,  
     . 
         CBitmap     
LoadBitmapO     ,    
.   : 

    BOOL CBitmap::LoadBitmap(LPCSTR IpszBitmapName) ; 

     Ips^BitmapName    .  
           . 
          ,   
 ,  "MYBIT": 

    CBitmap bit; 
    bit.LoadBitmap("MYBIT") ; 

         .     , 
   : 
    1.   ,     
     . 

    172                                    MFC:   

    2.          
(memory device context),        
   . 
    3.          . 
    4.  ,        
 .       .* 
     ,    ,    
.           
  . (,       
       CBitmap,  m_bmpl.) 

    //     
    afx_msg void CMainWin::OnLButtonDown(UINT flags, CPoint loc) 
    ( 
    CClientDC DC (this) ; 
    CDC memDC; 
    //     
    memDC.CreateCompatibleDC(&DC) ; 
    //       
    memDC.SelectObject(&m_bmpl) ; 
    //      
    DC.BitBit (loc.x, loc., 64, 64, SmernDC, 0, , SRCCOPY) ; 
    } 

         .  
   . , DC,    . 
, memDC,       ,   
  .     CreateCompatibIeDC(), 
   CDC,      
 .     : 

    virtual BOOL CDC::CreateCompatibleDC(CDC *pDC); 

          ,   , 
    pDC.      
      .   
          . 
           ,     
  ,    ,    
SelectObject().   ,       

    *   ,       
  ,     , :    
,       - ,   . 
  3   ,    ,   
 ,    ,    . 
 4   ,    ,    
,   ,    .  . . 


    7.   ,        173 

    ,          . 
 SelectObjectO   ,     
 .   ,     
 , : 

    CBitmap *CDC::SelectObject(CBitmap *pBltmap); 

      pBitmap     , 
   .      
 ,       .    
 NULL.   ,     
   ,    .  , , 
    . 
            
 BitBltQ,       
  ,     .   
 : 

    BOOL CDC::BitBlt (int X, int , int Width, ink Height, 
    CDC *pSourceDC, ink SourceX, int SourceY, 
    DWORD dwRasterOp); 

            .  
   Width  Height.  pSourceDC  
    ,      
  ,     CreateCompatibleDC(). 
 SourceX  Source Y      
.    0.  dwRasterOp   
      .   
    (. 7.4): 

     7.4.   

      

SRCAND
SRCCOPY 
SRCINVERT 
SRCPAINT	
           (AND)
     ,   
           (XOR)
           (OR) 

               
 . 
          BitBItQ    
  ,     . 

    174                                    MFC:   

       ,      
    .     
    CBitmap.       
   CGdiObject::DeleteObject(),    : 

    II BOOL CGdiObject::DeleteObject (); 

               
 . 

          

                
 ,  .     
,     .     
 . 7.3.    .,    : 

    //  . 
    //       
    class CMainWin : public CFrameWnd 
    ( 
    public: 
    CBitmap m bmpi; //    
    CMainWin () ; 
    afx_msg void OnLButtonDown(UINT flags, CPoint loc) ; 
    DECLARE_MESSAGE_MAP() 
    }; 
    //      
    class CApp : public CWinApp 
    ( 
    public: 
    BOOL Initlnstance() ; 
    ); 

     ,    CMainWin   in_bmpl.  
  CBitmap,     .  
         
  CMainWin (  - ),   
   . 

    7.   ,        175 

    H Display a Bitmap 

    . 7.3.      

       : 

    // ,      
    ftinclude <afxwin.h> 
    #include "bmp.h" 
    //   
    CMainWin::CMainWin() 
    { 
    Create(NULL, "Display a Bitmap"); 
    //   
    m_bmpl.LoadBitmap("MYBPl") ; 
    //   
    BOOL CApp::Initlnstance () 
    { 
    m pMainWnd = new CMainWin(); 
    m_pMainWnd->ShowWindow(m__nCmdShow) ; 
    m_pMainWnd->UpdateWindow() ; 
    return TRUE; 
    //     
    BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) 
    ON_WM_LBUTTONDOWN() 


    176 MFC:   


    END_MESSAGE_MAP() 
    //     
    afx_msg void CMainWin::OnLButtonDown(UINT flags, CPoint loc) 
    ( 
    CClientDC DC(this); 
    CDC memDC; 
    //     
    memDC.CreateCompatibleDC(&DC) ; 
    //       
    memDC.SelectObject(&m bmpi); 
    //      
    DC.BitBIt(loc.x, loc., 64, 64, &memDC, 0, , SRCCOPY) ; 
    ) 
     ; //    

     ,     CMainWin(). 
         , 
    ,   . ,  
       .    
,  ,    ,   
,  -    . 

        

         ,   
  .      
.    .      
,      ,    . 
      ,       
 .        . 
     ({) : 

    MYBP2 BITMAP BP2.BMP 

            6464 
      2.. 
         ,   
 ,   2.: 

    // 2. 
    //       
    class CMainWin : public CFrameWnd 
    ( 
    public: 
    CBitmap m bmpi, m bmp2; //    
    CMainWin() ; 
    afx msg void OnLButtonDown(UINT flags, CPoint loc); 


    7.   ,        177 


    afx_msg void OnRButtonDown(UINT flags, CPoint loc) ; 
    DECLARE_MESSAGE_MAP() 
    ) ; 
    //      
    class CApp : public CWinApp 
    ( 
    public: 
    BOOL Initlnstance(); 
    }; 

          CMainWin   inJbmp2  
 OnRButtonDown(). 
        .     j 
,      ON_WM_RBUTTON- J 
DOWN(),      OnRButtonDown().           

    // ,      
    ^include <afxwin.h                                                   , 
    #include "bmp2.h"                                                    ! 
    //   
    CMainWin::CMainWin () 
    { 
    Create(NULL, "Display Two Bitmaps"); 
    m_bmpl.LoadBitmap("MYBP1") ; 
    m_bmp2.LoadBitmap("MYBP2") ; 
    ) 
    //                                             j 
    BOOL CApp::Initlnstance () 
    { 
    m_pMainWnd = new CMainWin(); 
    m_pMainWnd-ShowWindow(m_nCmdShow) ; 
    m pMainWnd-UpdateWindow() ; 
    return TRUE; 
    //     
    BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) 
    ON_WM_LBUTTONDOWN() 
    ON_WM_RBUTTONDOWN() 
    END_MESSAGE_MAP() 
    //      
    afx_insg void CMainWin::OnLButtonDown(UINT flags, CPoint loc) 
    ( 
    CClientDC DC (this); 
    CDC memDC; 


    178                                    MFC:   


    //     
    meniDC.CreateCompatibleDC (&DC) ; 
    //       
    memDC.SelectObject(&m_bmpl) ; 
    //      
    DC.BitBIt(loc.x, loc.y, 64, 64, &memDC, , 0, SRCCOPY); 
    //      
    afx_msg void CMainWin::OnRButtonDown(UINT flags, CPoint loc) 
    ( 
    CClientDC DC(this); 
    CDC memDC; 
    //     
    memDC.CreateCompatibleDC(&DC) ; 
    //       
    memDC.SelectObject(&m_bmp2) ; 
    //      
    DC.BitBIt (loc.x, loc.y, 64, 64, &memDC, , , SRCCOPY); 
     ; //    

        ,       
    ,        
 .      . 7.4. 

     Llisplau Two Bitmap! 

    . 7.4.      

    7.   ,     179 
