Duilib學習三 響應按鈕

來源:互聯網
上載者:User

標籤:style   blog   http   ar   color   sp   on   div   2014   

 1 #pragma once 2 #include <UIlib.h> 3 using namespace DuiLib; 4  5 #ifdef _DEBUG 6 #   ifdef _UNICODE 7 #       pragma comment(lib, "DuiLib_ud.lib") 8 #   else 9 #       pragma comment(lib, "DuiLib_d.lib")10 #   endif11 #else12 #   ifdef _UNICODE13 #       pragma comment(lib, "DuiLib_u.lib")14 #   else15 #       pragma comment(lib, "DuiLib.lib")16 #   endif17 #endif18 19 class CDuiFrameWnd : public CWindowWnd, public INotifyUI20 {21 public:22     virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); }23     virtual void    Notify(TNotifyUI& msg) 24     {25         if(msg.sType == _T("click"))26         {27             if(msg.pSender->GetName() == _T("btnHello")) 28             {29                 ::MessageBox(NULL, _T("我是按鈕"), _T("點擊了按鈕"), NULL);30             }31         }32     }33 34     virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)35     {36         LRESULT lRes = 0;37 38         if( uMsg == WM_CREATE ) 39         {40             CControlUI *pWnd = new CButtonUI;41             pWnd->SetName(_T("btnHello"));      // 設定控制項的名稱,這個名稱用於標識每一個控制項,必須唯一,相當於MFC裡面的控制項ID42             pWnd->SetText(_T("Hello World"));   // 設定文字43             pWnd->SetBkColor(0xFF00FF00);       // 設定背景色44 45             m_PaintManager.Init(m_hWnd);46             m_PaintManager.AttachDialog(pWnd);47             m_PaintManager.AddNotifier(this);   // 添加控制項等訊息響應,這樣訊息就會傳達到duilib的訊息迴圈,我們可以在Notify函數裡做訊息處理48             return lRes;49         }50 51         if( m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes) ) 52         {53             return lRes;54         }55 56         return __super::HandleMessage(uMsg, wParam, lParam);57     }58 59 protected:60     CPaintManagerUI m_PaintManager;61 };62 63 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)64 {65     CPaintManagerUI::SetInstance(hInstance);66 67     CDuiFrameWnd duiFrame;68     duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);69     duiFrame.ShowModal();70     return 0;71 }




Duilib學習三 響應按鈕

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.