Special.cpp
上传用户:hnzycx
上传日期:2022-08-09
资源大小:12567k
文件大小:2k
- // Special.cpp : implementation file
- #include "stdafx.h"
- #include "MobileClient.h"
- #include "Special.h"
- #include "DataParsing.h"
- // CSpecial dialog
- IMPLEMENT_DYNAMIC(CSpecial, CDialog)
- //CSpecial构造
- CSpecial::CSpecial(CWnd* pParent /*=NULL*/)
- : CDialog(CSpecial::IDD, pParent)
-
- {
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- App->m_tcp.OnRead = OnReadSpecial;
- }
- //CSpecial析构
- CSpecial::~CSpecial()
- {
- }
- void CSpecial::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_SpecialList);
- }
- BEGIN_MESSAGE_MAP(CSpecial, CDialog)
- ON_BN_CLICKED(IDC_BUTTON1, &CSpecial::OnBnClickedButton1)
- END_MESSAGE_MAP()
- // CSpecial message handlers
- //回调函数
- void CALLBACK CSpecial::OnReadSpecial(CWnd* pWnd,const char *buf,int len)
- {
-
-
- CString strRecv(buf);
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- App->context = strRecv;
- }
- BOOL CSpecial::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- m_SpecialList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
- m_SpecialList.InsertColumn(0,_T("特价菜名"),LVCFMT_LEFT,120,-1);
- m_SpecialList.InsertColumn(1,_T("价格"),LVCFMT_LEFT,100,-1);
-
- CStringList returnValue;
- CDataParsing *dp=new CDataParsing(App->context);
- dp->ProcessDataForDB(returnValue);
- POSITION pos=returnValue.GetHeadPosition();
- Sleep(3000);
- CString tail;
- tail=returnValue.GetTail();
- //解析,输出优惠/特价菜信息
- if(tail==_T("END"))
- {
- int k = returnValue.GetCount();
- k = (k-2)/2;
-
- int i = 0;
- CString arg1;
- CString arg2;
- arg1 = returnValue.GetNext(pos);
- while(k)
- {
-
- arg1 = returnValue.GetNext(pos);
- arg2 = returnValue.GetNext(pos);
- m_SpecialList.InsertItem(i,arg1);
- m_SpecialList.SetItemText(i,1,arg2);
- k--;
- i++;
- }
-
- }
- return TRUE;
- }
- //返回主界面
- void CSpecial::OnBnClickedButton1()
- {
- OnCancel();
- }