MZFC

/************************************************************************/
/*
* Copyright (C) Meizu Technology Corporation Zhuhai China
* All rights reserved.
* 中国珠海, 魅族科技有限公司, 版权所有.
*
* This file is a part of the Meizu Foundation Classes library.
* Author:    Michael
* Create on: 2008-12-1
*/
/************************************************************************/

// The steps for running this sample code:
// Use Visual Studio 2005/2008 to create a smart device project,
// Choose M8SDK,
// Choose empty project,
// Add a sample.cpp file to the project,
// Copy this peace of code into the sample.cpp,
// Now, you can build the project and try to run it in M8 emulator or device.

// include the MZFC library header file
#include <mzfc_inc.h>

// This sample shows in a MZFC application:
// application's creation & initialization,
// window's creation & initialization,
// using button control, and process its command.

// ID of the button in the window
#define MZ_IDC_TESTBTN1  101

// Main window derived from CMzWndEx
class CSample1MainWnd: public CMzWndEx
{
 MZ_DECLARE_DYNAMIC(CSample1MainWnd);
public:
 // A button control in the window
 UiButton m_btn;

protected:
 // Initialization of the window (dialog)
 virtual BOOL OnInitDialog()
 {
  // Must all the Init of parent class first!
  if (!CMzWndEx::OnInitDialog())
  {
   return FALSE;
  }

  // Then init the controls & other things in the window
  m_btn.SetButtonMode(5);
  // Add the control into the window.
  AddUiWin(&m_btn);

  return TRUE;
 }

 // override the MZFC command handler
 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)

// Application class derived from CMzApp
class CSample1App: public CMzApp
{
public:
 // The main window of the app.
 CSample1MainWnd m_MainWnd;

 // Initialization of the application
 virtual BOOL Init()
 {
  // Init the COM relative library.
  CoInitializeEx(0, COINIT_MULTITHREADED);

  // Create the main window
  RECT rcWork = MzGetWorkArea();
  m_MainWnd.Create(rcWork.left,rcWork.top,RECT_WIDTH(rcWork),RECT_HEIGHT(rcWork), 0, 0, 0);
  m_MainWnd.Show();

  // return TRUE means init success.
  return TRUE;
 }
};

// The global variable of the application.
CSample1App theApp;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值