📄 nurritionandneeddlg.cpp
字号:
// NurritionAndNeedDlg.cpp : implementation file
//
#include "stdafx.h"
#include "FoodMenu.h"
#include "NurritionAndNeedDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNurritionAndNeedDlg dialog
CNurritionAndNeedDlg::CNurritionAndNeedDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNurritionAndNeedDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNurritionAndNeedDlg)
//}}AFX_DATA_INIT
}
void CNurritionAndNeedDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNurritionAndNeedDlg)
DDX_Control(pDX, IDC_TAB1, m_Tab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNurritionAndNeedDlg, CDialog)
//{{AFX_MSG_MAP(CNurritionAndNeedDlg)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
ON_BN_CLICKED(IDC_CHANGE_FOOD_NURRITION_BUTTON, OnChangeFoodNurritionButton)
ON_BN_CLICKED(IDC_CHANGE_NURRITION_NEED_BUTTON, OnChangeNurritionNeedButton)
ON_BN_CLICKED(IDC_HOME1, OnHome1)
ON_BN_CLICKED(IDC_BACK, OnBack)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNurritionAndNeedDlg message handlers
void CNurritionAndNeedDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nSelect = m_Tab.GetCurSel();
if(nSelect >=0)
DoTab(nSelect);
*pResult = 0;
}
void CNurritionAndNeedDlg::OnChangeFoodNurritionButton()
{
foodnurrition.LoadBitmaps(IDB_foodnurrition2);
VERIFY(foodnurrition.SubclassDlgItem(IDC_CHANGE_FOOD_NURRITION_BUTTON, this));
foodnurrition.SizeToContent();
foodneed.LoadBitmaps(IDB_foodneed2);
VERIFY(foodneed.SubclassDlgItem(IDC_CHANGE_NURRITION_NEED_BUTTON, this));
foodneed.SizeToContent();
DoTab(0);
}
void CNurritionAndNeedDlg::OnChangeNurritionNeedButton()
{
foodnurrition.LoadBitmaps(IDB_foodnurrition1);
VERIFY(foodnurrition.SubclassDlgItem(IDC_CHANGE_FOOD_NURRITION_BUTTON, this));
foodnurrition.SizeToContent();
foodneed.LoadBitmaps(IDB_foodneed1);
VERIFY(foodneed.SubclassDlgItem(IDC_CHANGE_NURRITION_NEED_BUTTON, this));
foodneed.SizeToContent();
DoTab(1);
}
void CNurritionAndNeedDlg::SetDlgState(CWnd *pWnd, BOOL bShow,int dialog)
{
pWnd->EnableWindow(bShow);
if(bShow)
{
if(dialog==1)
{
pWnd->ShowWindow(SW_SHOW);
pWnd->CenterWindow();
// pWnd->MoveWindow(0,0,640,475,false);
}
else if(dialog==2)
{
pWnd->ShowWindow(SW_SHOW);
pWnd->CenterWindow();
// pWnd->MoveWindow(0,120,640,200,false);
}
}
else
pWnd->ShowWindow(SW_HIDE);
}
void CNurritionAndNeedDlg::DoTab(int nSel)
{
if(nSel>1) nSel = 1;
if(nSel<0) nSel = 0;
BOOL bTab[2];
bTab[0] = bTab[1] = FALSE;
bTab[nSel] = TRUE;
SetDlgState(m_pFoodNurritionDlg, bTab[0],1);
SetDlgState(m_pNurritionNeedDlg, bTab[1],2);
}
BOOL CNurritionAndNeedDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
/////////////////////////////////////////////////////////////////////////
home.LoadBitmaps(IDB_home,IDB_home);
VERIFY(home.SubclassDlgItem(IDC_HOME1, this));
home.SizeToContent();
back.LoadBitmaps(IDB_return,IDB_return);
VERIFY(back.SubclassDlgItem(IDC_BACK, this));
back.SizeToContent();
foodnurrition.LoadBitmaps(IDB_foodnurrition1);
VERIFY(foodnurrition.SubclassDlgItem(IDC_CHANGE_FOOD_NURRITION_BUTTON, this));
foodnurrition.SizeToContent();
foodneed.LoadBitmaps(IDB_foodneed1);
VERIFY(foodneed.SubclassDlgItem(IDC_CHANGE_NURRITION_NEED_BUTTON, this));
foodneed.SizeToContent();
//////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------创建二个对话框---------------------
m_pFoodNurritionDlg = new CFoodNurritionDlg;
m_pFoodNurritionDlg->Create(IDD_1_FOOD_NURRITION, GetDlgItem(IDC_STATIC_DLG));
m_pNurritionNeedDlg = new CNurritionNeedDlg;
m_pNurritionNeedDlg->Create(IDD_1_NURRITION_NEED_DIALOG, GetDlgItem(IDC_STATIC_DLG));
//-----------------------------------------------------------------------------------
DoTab(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CNurritionAndNeedDlg::OnHome1()
{
CDialog::EndDialog(1);
CDialog::DestroyWindow();
}
void CNurritionAndNeedDlg::OnBack()
{
CDialog::EndDialog(1);
CDialog::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -