MainFrm.cpp
资源名称:vc_demo.rar [点击查看]
上传用户:zcy791212
上传日期:2013-03-06
资源大小:196k
文件大小:19k
源码类别:
Modem编程
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "vc_demo.h"
- #include "time.h"
- #include "SettingDlg.h"
- #include "senddatadlg.h"
- #include "WordThread.h"
- #include "MainFrm.h"
- #include "gprsdll.h"
- #include "vc_demoView.h"
- #include "gprsdll.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_MICLEAR, OnMiclear)
- ON_COMMAND(ID_MIOFFLINE, OnMioffline)
- ON_COMMAND(ID_MIREFRESHTABLE, OnMirefreshtable)
- ON_COMMAND(ID_MISENDDATA, OnMisenddata)
- ON_COMMAND(ID_MISTARTSERVICE, OnMistartservice)
- ON_COMMAND(ID_MISTOPSERVICE, OnMistopservice)
- ON_COMMAND(ID_QUIT, OnQuit)
- ON_WM_CLOSE()
- ON_COMMAND(ID_MIANSWER, OnMianswer)
- ON_COMMAND(ID_MISHOWDATA, OnMishowdata)
- ON_COMMAND(ID_SHOWMENU, OnShowmenu)
- ON_COMMAND(ID_HELPCONTENT, OnHelpcontent)
- ON_WM_TIMER()
- ON_UPDATE_COMMAND_UI(ID_MISTARTSERVICE, OnUpdateMistartservice)
- ON_UPDATE_COMMAND_UI(ID_MIOFFLINE, OnUpdateMistopservice)
- ON_UPDATE_COMMAND_UI(ID_MIANSWER, OnUpdateMianswer)
- ON_COMMAND(ID_MISERVERSETTING, OnMiserversetting)
- ON_UPDATE_COMMAND_UI(ID_SHOWMENU, OnUpdateShowmenu)
- ON_COMMAND(ID_MIOFFLINEALL, OnMiofflineall)
- ON_COMMAND(ID_MIVIEWWORD, OnMiviewword)
- ON_UPDATE_COMMAND_UI(ID_MIVIEWWORD, OnUpdateMiviewword)
- ON_UPDATE_COMMAND_UI(ID_MIREFRESHTABLE, OnUpdateMistopservice)
- ON_UPDATE_COMMAND_UI(ID_MISENDDATA, OnUpdateMistopservice)
- ON_UPDATE_COMMAND_UI(ID_MISTOPSERVICE, OnUpdateMistopservice)
- ON_UPDATE_COMMAND_UI(ID_MIOFFLINEALL, OnUpdateMistopservice)
- //}}AFX_MSG_MAP
- ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
- ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
- ON_MESSAGE(ID_MISENDDATA,OnMisenddata)
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR
- // status line indicator
- //ID_INDICATOR_CAPS,
- //ID_INDICATOR_NUM,
- //ID_INDICATOR_SCRL,
- //0x1234
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- m_bAutoMenuEnable=false;
- this->m_bServerRunning=false;
- this->m_bAnswer=FALSE;
- this->m_viewword=TRUE;
- memset(this->m_userid,0x00,12);
- init_option(&m_option);
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_wndMenuBar.Create(this) ||
- !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // faile to create
- }
- if (!m_wndToolBar.CreateEx(this,
- TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST,
- WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY
- | CBRS_SIZE_DYNAMIC
- )
- || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndMenuBar);
- DockControlBar(&m_wndToolBar);
- this->SetToolBarStyle();
- this->SetStatusBarStyle();
- return 0;
- }
- BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
- CCreateContext* pContext)
- {
- // create splitter window
- if (!m_wndSplitter.CreateStatic(this, 1, 2))
- return FALSE;
- if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(130, 100), pContext))
- {
- m_wndSplitter.DestroyWindow();
- return FALSE;
- }
- if (!m_wndSplitter2.CreateStatic(&m_wndSplitter,2,1,WS_VISIBLE | WS_CHILD | WS_BORDER,m_wndSplitter.IdFromRowCol(0,1)))
- return FALSE;
- if (!m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CVc_demoView), CSize(100, 200), pContext) ||
- !m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(CBottomEditView), CSize(100, 100), pContext))
- {
- m_wndSplitter2.DestroyWindow();
- return FALSE;
- }
- return TRUE;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- CVc_demoView* CMainFrame::GetRightPane()
- {
- CWnd* pWnd = m_wndSplitter2.GetPane(0, 0);
- CVc_demoView* pView = DYNAMIC_DOWNCAST(CVc_demoView, pWnd);
- return pView;
- }
- CLeftView* CMainFrame::GetLeftPane()
- {
- CWnd* pWnd = m_wndSplitter.GetPane(0, 0);
- CLeftView* pView = DYNAMIC_DOWNCAST(CLeftView, pWnd);
- return pView;
- }
- CBottomEditView* CMainFrame::GetBottompane()
- {
- CWnd* pWnd = m_wndSplitter2.GetPane(1, 0);
- CBottomEditView* pView = DYNAMIC_DOWNCAST(CBottomEditView, pWnd);
- return pView;
- }
- void CMainFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
- {
- // TODO: customize or extend this code to handle choices on the
- // View menu.
- CVc_demoView* pView = GetRightPane();
- // if the right-hand pane hasn't been created or isn't a view,
- // disable commands in our range
- if (pView == NULL)
- pCmdUI->Enable(FALSE);
- else
- {
- DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
- // if the command is ID_VIEW_LINEUP, only enable command
- // when we're in LVS_ICON or LVS_SMALLICON mode
- if (pCmdUI->m_nID == ID_VIEW_LINEUP)
- {
- if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
- pCmdUI->Enable();
- else
- pCmdUI->Enable(FALSE);
- }
- else
- {
- // otherwise, use dots to reflect the style of the view
- pCmdUI->Enable();
- BOOL bChecked = FALSE;
- switch (pCmdUI->m_nID)
- {
- case ID_VIEW_DETAILS:
- bChecked = (dwStyle == LVS_REPORT);
- break;
- case ID_VIEW_SMALLICON:
- bChecked = (dwStyle == LVS_SMALLICON);
- break;
- case ID_VIEW_LARGEICON:
- bChecked = (dwStyle == LVS_ICON);
- break;
- case ID_VIEW_LIST:
- bChecked = (dwStyle == LVS_LIST);
- break;
- default:
- bChecked = FALSE;
- break;
- }
- pCmdUI->SetRadio(bChecked ? 1 : 0);
- }
- }
- }
- void CMainFrame::OnViewStyle(UINT nCommandID)
- {
- // TODO: customize or extend this code to handle choices on the
- // View menu.
- CVc_demoView* pView = GetRightPane();
- // if the right-hand pane has been created and is a CVc_demoView,
- // process the menu commands...
- if (pView != NULL)
- {
- DWORD dwStyle = -1;
- switch (nCommandID)
- {
- case ID_VIEW_LINEUP:
- {
- // ask the list control to snap to grid
- CListCtrl& refListCtrl = pView->GetListCtrl();
- refListCtrl.Arrange(LVA_SNAPTOGRID);
- }
- break;
- // other commands change the style on the list control
- case ID_VIEW_DETAILS:
- dwStyle = LVS_REPORT;
- break;
- case ID_VIEW_SMALLICON:
- dwStyle = LVS_SMALLICON;
- break;
- case ID_VIEW_LARGEICON:
- dwStyle = LVS_ICON;
- break;
- case ID_VIEW_LIST:
- dwStyle = LVS_LIST;
- break;
- }
- // change the style; window will repaint automatically
- if (dwStyle != -1)
- pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
- }
- }
- void CMainFrame::SetToolBarStyle()
- {
- CImageList img;
- m_wndToolBar.GetToolBarCtrl().SetButtonWidth(40, 100);
- m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
- //m_wndToolBar.SetButtonStyle(8,TBSTYLE_CHECK);
- //m_wndToolBar.SetButtonStyle(4,m_wndToolBar.GetButtonStyle(4)
- // | TBSTYLE_DROPDOWN);
- img.Create(IDB_HOTTOOLBAR, 32, 0, RGB(244, 247, 14));
- m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
- img.Detach();
- img.Create(IDB_COLDTOOLBAR, 32, 0, RGB(244, 247, 14));
- m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
- img.Detach();
- for(int i = 0; i < m_wndToolBar.GetCount(); i++)
- {
- UINT id = m_wndToolBar.GetItemID(i);
- CString s;
- if (!s.LoadString(id))
- continue;
- int j = s.Find(_T('n'));
- if(j < 0) continue;
- s = s.Right(s.GetLength() - j - 1);
- m_wndToolBar.SetButtonText(i,s);
- }
- CRect rect;
- m_wndToolBar.GetItemRect(0,&rect);
- m_wndToolBar.SetSizes(rect.Size(),CSize(32,32));
- }
- void CMainFrame::OnMiclear()
- {
- // TODO: Add your command handler code here
- CEdit &ce=this->GetBottompane()->GetEditCtrl();
- ce.SetWindowText("");
- }
- void CMainFrame::OnMioffline()
- {
- /*
- char buf[64];
- if (11==strlen(m_userid))
- {
- sprintf(buf,"确认使 %s 下线吗?",this->m_userid);
- if (IDYES==MessageBox(buf,"确认",MB_YESNO | MB_ICONINFORMATION))
- {
- do_close_one_user((unsigned char *)m_userid,NULL);
- this->RefreshUserTable();
- }
- }
- */
- }
- void CMainFrame::OnMirefreshtable()
- {
- this->RefreshUserTable();
- }
- void CMainFrame::OnMisenddata()
- {
- CTreeCtrl &tc=this->GetLeftPane()->GetTreeCtrl();
- CSendDataDlg sdd(NULL,&tc);
- sdd.SetUserId(this->m_userid);
- sdd.DoModal();
- }
- void CMainFrame::OnMistartservice()
- {
- char mess[512];
- BOOL bResult;
- bResult=DSStartService(m_option.m_iServerPort);
- if (bResult)
- {
- sprintf(mess,"厦门桑荣科技数据服务中心启动,侦听端口为%drn",m_option.m_iServerPort);
- if ((m_option.m_bSysAutoPoll) && (m_option.m_iPollTimeInterval>0) && (m_option.m_iOffLineTime>0))
- this->SetTimer(1,(m_option.m_iPollTimeInterval)*1000,NULL);
- this->AddTextToEditView(mess,false);
- if (!StartRecv())
- {
- DSStopService();
- sprintf(mess,"启动接收线程失败,关闭数据中心服务rn");
- this->AddTextToEditView(mess,false);
- }
- else
- {
- sprintf(mess,"启动接收线程成功,系统就绪。rn");
- AddTextToEditView(mess,false);
- this->m_bServerRunning=true;
- }
- }
- else
- {
- sprintf(mess,"数据中心服务启动失败!rn");
- this->AddTextToEditView(mess,false);
- }
- }
- void CMainFrame::OnMistopservice()
- {
- // TODO: Add your command handler code here
- char mess[512];
- if (m_option.m_bSysAutoPoll)
- this->KillTimer(1);
- //this->AddTextToEditView(mess);
- if(!DSStopService())
- {
- DSGetLastError(mess,sizeof(mess));
- }
- else
- {
- sprintf(mess,"停止数据中心服务成功!rn");
- }
- this->AddTextToEditView(mess,false);
- StopRecvThread();
- this->m_bServerRunning=false;
- this->GetRightPane()->ClearAllItem();
- this->GetLeftPane()->ClearAllItem();
- }
- void CMainFrame::OnQuit()
- {
- // TODO: Add your command handler code here
- this->OnClose();
- }
- void CMainFrame::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- if (IDYES==MessageBox("确定要退出吗?","退出",MB_YESNO | MB_ICONINFORMATION))
- {
- if (m_bServerRunning)
- {
- this->OnMistopservice();
- }
- CFrameWnd::OnClose();
- }
- }
- UINT CMainFrame::ProcessRvData(LPVOID lparam)
- {
- CMainFrame* pMainFrm=(CMainFrame*)lparam;
- ModemDataStruct modemdata;
- static char buf[2048];
- while(1)
- {
- if (DSGetNextData(&modemdata,0)!=FALSE)
- {
- if (modemdata.m_data_len>0)
- {
- //whether show head
- if (pMainFrm->m_option.m_bShowHead)
- {
- struct tm when;
- when = *localtime((time_t*)&modemdata.m_recv_time);
- // sprintf(buf,"rnuserid:%s,time:%s,len:%d",
- // modemdata.m_modemId,asctime(&when),modemdata.m_data_len);
- sprintf(buf,"rnuserid:%8.8x,time:%s,len:%d",
- modemdata.m_modemId,asctime(&when),modemdata.m_data_len);
- pMainFrm->AddTextToEditView(buf);
- }
- //Hex or not to show data
- modemdata.m_data_buf[modemdata.m_data_len]=0;
- if (pMainFrm->m_option.m_bHexShow)
- {
- pMainFrm->PrintData((char*)modemdata.m_data_buf);
- }
- else
- {
- pMainFrm->AddTextToEditView((char*)modemdata.m_data_buf);
- }
- }
- }
- else
- {
- break;
- }
- } //endof while(1)
- return 1;
- }
- void CMainFrame::AddTextToEditView(char * szContent,bool newline)
- {
- if (szContent)
- {
- CString text;
- CEdit &ce=GetBottompane()->GetEditCtrl();
- if (ce.GetLineCount()>100)
- ce.SetWindowText("");
- ce.GetWindowText(text);
- if (newline)
- ce.SetWindowText(text+"rn"+szContent);
- else
- ce.SetWindowText(text+szContent);
- ce.LineScroll(ce.GetLineCount());
- }
- }
- void CMainFrame::AddTextToEditView(int iContent,bool newline)
- {
- CString text;
- char buf[32];
- sprintf(buf,"%d",iContent);
- CEdit &ce=this->GetBottompane()->GetEditCtrl();
- if (ce.GetLineCount()>100)
- ce.SetWindowText("");
- ce.GetWindowText(text);
- if (newline)
- ce.SetWindowText(text+"rn"+buf);
- else
- ce.SetWindowText(text+buf);
- ce.LineScroll(ce.GetLineCount());
- }
- void CMainFrame::RefreshUserTable(int flag)
- //flag=1 means refresh usertable , 0 means not
- //flag==1:called by timer
- //flag==0:called by manual
- {
- int i,iMaxDTUAmount;
- ModemInfoStruct mi;
- bool bShow;
- time_t t_now,t_update;
- this->GetRightPane()->ClearAllItem();
- this->GetLeftPane()->ClearAllItem();
- iMaxDTUAmount=DSGetModemCount();
- TRACE("TIMER:MAX MODEM COUNT = %d.n",iMaxDTUAmount);
- for (i=0;i<iMaxDTUAmount;i++)
- {
- DSGetModemByPosition(i,&mi);
- bShow=true;
- if ((m_option.m_bSysAutoPoll) && (1==flag))
- {
- /* if type of update time is ulong then use */
- /* the following code */
- t_now=time(NULL);
- t_update=mi.m_refresh_time;
- if ((t_now-t_update)>=m_option.m_iOffLineTime)
- {
- bShow=false;
- }
- }
- if (bShow)
- {
- //add to ListView of right top
- this->GetRightPane()->InsertUserItem(
- &mi);
- //add to TreeView of left
- CString str;
- str.Format("%8.8x",mi.m_modemId);
- GetLeftPane()->InsertUserItem(str.GetBuffer(1));
- }
- }
- this->GetLeftPane()->GetTreeCtrl().Expand(
- this->GetLeftPane()->GetTreeCtrl().GetFirstVisibleItem(),TVE_EXPAND);
- }
- void CMainFrame::OnMianswer()
- {
- m_bAnswer=!m_bAnswer;
- }
- void CMainFrame::OnMiserversetting()
- {
- this->GetPara(0);
- }
- void CMainFrame::OnMishowdata()
- {
- this->GetPara(1);
- }
- void CMainFrame::OnShowmenu()
- {
- ShowControlBar(&m_wndMenuBar,!m_wndMenuBar.IsWindowVisible(),FALSE);
- m_wndToolBar.SetButtonStyle(5,TBSTYLE_BUTTON);
- }
- void CMainFrame::OnHelpcontent()
- {
- MessageBox("厦门桑荣科技技术部");
- }
- void CMainFrame::SetStatusBarStyle()
- {
- m_wndStatusBar.SetPaneInfo(0,ID_SEPARATOR,SBPS_STRETCH,100);
- m_wndStatusBar.SetPaneText(1,"",TRUE);
- m_wndStatusBar.SetPaneText(2,"数据中心软件DEMO软件",TRUE);
- }
- void CMainFrame::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- if (1==nIDEvent)
- this->RefreshUserTable(1);
- if (3==nIDEvent)
- ProcessRvData(this);
- CFrameWnd::OnTimer(nIDEvent);
- }
- void CMainFrame::PrintData(char *szData)
- {
- char buf[128];
- int i,j,len,totallen;
- totallen=strlen(szData);
- for (i=0;i<totallen;i+=16)
- {
- len=(totallen-i)>16?16:(totallen-i);
- sprintf(buf,"%04X : ",i);
- for (j=0;j<len;j++)
- {
- sprintf(buf+9+j*3,"%02X ",szData[i+j]&0xFF);
- buf[64+j]=szData[i+j];
- }
- memset(buf+len*3+9,' ',64-len*3-9);
- buf[64+len]=' ';
- this->AddTextToEditView(buf);
- }
- }
- void CMainFrame::OnUpdateMistartservice(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(!m_bServerRunning);
- }
- void CMainFrame::OnUpdateMistopservice(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_bServerRunning);
- }
- void CMainFrame::OnUpdateMianswer(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck(m_bAnswer);
- }
- void CMainFrame::init_option(LPOPTION pOption)
- {
- pOption->m_bSaveToLog=FALSE;
- pOption->m_iLogItemCount=200;
- pOption->m_bShowDataHead=TRUE;
- pOption->m_iServerPort=5001;
- pOption->m_bSysAutoPoll=TRUE;
- pOption->m_iPollTimeInterval=5;
- pOption->m_iOffLineTime=120;
- pOption->m_bShowHead=TRUE;
- pOption->m_bHexShow=TRUE;
- }
- void CMainFrame::GetPara(int tabindex)
- {
- CSettingDlg sdlg(NULL,tabindex,!m_bServerRunning);
- sdlg.m_bSaveToLog=m_option.m_bSaveToLog;
- sdlg.m_iLogItemCount.Format("%d",m_option.m_iLogItemCount);
- sdlg.m_iOffLineTime.Format("%d",m_option.m_iOffLineTime);
- sdlg.m_iPollTime.Format("%d",m_option.m_iPollTimeInterval);
- sdlg.m_iServerPort.Format("%d",m_option.m_iServerPort);
- sdlg.m_bSysAutoPoll=m_option.m_bSysAutoPoll;
- sdlg.m_bShowHead=m_option.m_bShowHead;
- sdlg.m_bHexShow=m_option.m_bHexShow;
- if (IDOK==sdlg.DoModal())
- {
- m_option.m_bSaveToLog=sdlg.m_bSaveToLog;
- m_option.m_iLogItemCount=atoi(sdlg.m_iLogItemCount.GetBuffer(0));
- m_option.m_iOffLineTime=atoi(sdlg.m_iOffLineTime.GetBuffer(0));
- m_option.m_iPollTimeInterval=atoi(sdlg.m_iPollTime.GetBuffer(0));
- m_option.m_iServerPort=atoi(sdlg.m_iServerPort.GetBuffer(0));
- m_option.m_bSysAutoPoll=sdlg.m_bSysAutoPoll;
- m_option.m_bShowHead=sdlg.m_bShowHead;
- m_option.m_bHexShow=sdlg.m_bHexShow;
- }
- }
- void CMainFrame::SetUserId(char *szUserId)
- {
- strncpy(this->m_userid,szUserId,11);
- this->m_userid[11]=' ';
- }
- void CMainFrame::OnUpdateShowmenu(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_wndMenuBar.IsWindowVisible());
- }
- void CMainFrame::OnMiofflineall()
- {
- /*
- do_close_all_user(NULL);
- this->RefreshUserTable();
- */
- }
- void CMainFrame::OnMiviewword()
- {
- // TODO: Add your command handler code here
- if (!IsWindowVisible())
- return;
- CRect rect;
- m_viewword=!m_viewword;
- m_wndToolBar.SetShowWord(m_viewword);
- m_wndToolBar.GetItemRect(0,&rect);
- if (m_viewword)
- {
- m_wndToolBar.SetSizes(CSize(SHOWTEXTLEN,rect.Size().cy),CSize(32,32));
- }
- else
- {
- m_wndToolBar.SetSizes(CSize(NOTEXTLEN,rect.Size().cy),CSize(32,32));
- }
- ShowControlBar(&m_wndToolBar,TRUE,FALSE);
- }
- void CMainFrame::OnUpdateMiviewword(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_wndToolBar.IsWindowVisible());
- pCmdUI->SetCheck(m_viewword);
- }
- BOOL CMainFrame::IsShowToolBarWord()
- {
- return m_viewword;
- }
- int CMainFrame::CompareDateTimeAndNow(char * szDateTime)
- {
- int nYear,nMonth,nDay,nHour,nMin,nSec;
- char temp[20];
- memset(temp,0,20);
- strncpy(temp,szDateTime,4);
- nYear = atoi(temp);
- memset(temp,0,20);
- strncpy(temp,&(szDateTime[5]),2);
- nMonth = atoi(temp);
- memset(temp,0,20);
- strncpy(temp,&(szDateTime[8]),2);
- nDay = atoi(temp);
- memset(temp,0,20);
- strncpy(temp,&(szDateTime[11]),2);
- nHour = atoi(temp);
- memset(temp,0,20);
- strncpy(temp,&(szDateTime[14]),2);
- nMin = atoi(temp);
- memset(temp,0,20);
- strncpy(temp,&(szDateTime[17]),4);
- nSec = atoi(temp);
- CTime updatetime(nYear,nMonth,nDay,nHour,nMin,nSec);
- time_t stUpdatetime = updatetime.GetTime();
- CTime currenttime = CTime::GetCurrentTime();
- return (currenttime.GetTime()-stUpdatetime);
- }
- BOOL CMainFrame::StartRecv(void)
- {
- SetTimer(3,100,NULL); //500ms every time.
- return TRUE;
- }
- void CMainFrame::StopRecvThread()
- {
- KillTimer(3);
- }