M8SDK

来自开放百科 - 灰狐
跳转到: 导航, 搜索

M8的一个应用主要定义两个和实现类:

Class CSampleMainWnd : public CMzWndEx
Class CSampleMainApp : public CMzApp

一个最简单的Hello World 应用

#include <mzfc_inc.h>
#define MZ_IDC_TESTBTN1  101
class CSample1MainWnd: public CMzWndEx
{
  MZ_DECLARE_DYNAMIC(CSample1MainWnd);
public:  
  UiButton m_btn;
protected:
  virtual BOOL OnInitDialog()
 {
   if (!CMzWndEx::OnInitDialog())
   {
     return FALSE;
   }
   m_btn.SetButtonType(MZC_BUTTON_GREEN);
   m_btn.SetPos(100,250,280,100);
   m_btn.SetID(MZ_IDC_TESTBTN1);
   m_btn.SetText(L"Hello MZFC!");
   m_btn.SetTextColor(RGB(255,255,255));
   AddUiWin(&m_btn);
   return TRUE;
 }  
 virtual void OnMzCommand(WPARAM wParam, LPARAM lParam)
 {
   UINT_PTR id = LOWORD(wParam);
   switch(id)
   {
   case MZ_IDC_TESTBTN1:
     {
       if(1 == MzMessageBoxEx(m_hWnd, L"You have pressed Exit button, Really want exit?", L"Exit", MB_YESNO, false))
         PostQuitMessage(0);
     }
     break;
   } } };
MZ_IMPLEMENT_DYNAMIC(CSample1MainWnd)
class CSample1App: public CMzApp
{
public:
  CSample1MainWnd m_MainWnd;
  virtual BOOL Init()
  {
    CoInitializeEx(0, COINIT_MULTITHREADED);
    RECT rcWork = MzGetWorkArea();
    m_MainWnd.Create(rcWork.left,rcWork.top,RECT_WIDTH(rcWork),RECT_HEIGHT(rcWork), 0, 0, 0);
    m_MainWnd.Show();
    return TRUE;
  }
};
CSample1App theApp;
分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱