正文

公共模塊設計(1)

Visual C++項目開發(fā)案例全程實錄(第2版) 作者:明日科技


 

為了使程序的界面更美觀,在本系統(tǒng)中使用鉤子函數對按鈕控件進行了修改,首先創(chuàng)建一個按鈕類CDrawButton類。CDrawButton類的代碼如下:

//定義按鈕狀態(tài)

enum ButtonState  {bsNormal,bsHot,bsDown};

//按鈕包裝類

class CDrawButton  

{

public:

ButtonState  m_State;        //按鈕當前狀態(tài)

WNDPROC  m_OldProc;     //記錄按鈕的窗口函數

int          m_Flag;        //是否釋放關聯(lián)按鈕的CDrawButton對象

static int     m_Style;        //按鈕風格

public:

CDrawButton( )  //構造函數

{

m_State   = bsNormal;  //設置按鈕狀態(tài)

m_OldProc = NULL;    //設置窗口函數

m_Flag    = 0;    //設置按鈕風格

}

virtual ~CDrawButton() //析構函數

{

m_State   = bsNormal;   //設置按鈕狀態(tài)

m_OldProc = NULL; //設置窗口函數

};


上一章目錄下一章

Copyright ? 讀書網 www.talentonion.com 2005-2020, All Rights Reserved.
鄂ICP備15019699號 鄂公網安備 42010302001612號