?? engmodeexview.cpp
字號:
// EngModeExView.cpp : CEngModeExView 類的實現
//
#include "stdafx.h"
#include "EngModeEx.h"
#include "EngModeExDoc.h"
#include "EngModeExView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
extern TCHAR strReturnData[256];
myFunType curFunType = SYSTEMINFO;
FunControl engFunControl[] =
{
{_T("=========================================="),NULL},
{_T("版本號"),getRadioVer},
{_T("切換頻段"),switchRange},
{NULL,NULL }
};
FunControl systemFunControl[] =
{
{_T("=========================================="),NULL},
{_T("內存信息"),getMemoryInfo},
{NULL,NULL }
};
FunControl debugFunControl[] =
{
{_T("=========================================="),NULL},
{_T("GPIO信息"),GPIOControl},
{_T("睡眠喚醒信息"),WakeSleepInfo},
{_T("開關無線模塊"),OpenCloseWireless},
{_T("電池信息"),DispBattery},
{NULL,NULL }
};
// CEngModeExView
IMPLEMENT_DYNCREATE(CEngModeExView, CListView)
BEGIN_MESSAGE_MAP(CEngModeExView, CListView)
ON_COMMAND(IDM_SELECT, &CEngModeExView::executeSelFun)
ON_COMMAND(ID_SYSTEMINFO, &CEngModeExView::OnSysteminfo)
ON_COMMAND(ID_ENGMODE, &CEngModeExView::OnEngmode)
ON_COMMAND(ID_DEBUG, &CEngModeExView::OnDebug)
ON_NOTIFY_REFLECT(NM_CLICK, &CEngModeExView::OnNMClick)
ON_WM_DESTROY()
END_MESSAGE_MAP()
// CEngModeExView 構造/析構
CEngModeExView::CEngModeExView()
{
// TODO: 在此處添加構造代碼
curFunType = SYSTEMINFO;
}
CEngModeExView::~CEngModeExView()
{
}
BOOL CEngModeExView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此處通過修改
// CREATESTRUCT cs 來修改窗口類或樣式
return CListView::PreCreateWindow(cs);
}
void CEngModeExView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
// TODO: 調用 GetListCtrl() 直接訪問 ListView 的列表控件,
// 從而可以用項填充 ListView。
//RECT rect;
//GetWindowRect(&rect);
ModifyStyle(LVS_TYPEMASK, LVS_LIST);
CListCtrl& listCtrl = GetListCtrl();
static BOOL imgInsert = FALSE;
if(!imgInsert)
{
ImageList.Create(16,16,TRUE,2,2);
ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
listCtrl.SetImageList(&ImageList,LVSIL_SMALL);
imgInsert = TRUE;
}
#if 0
HWND listWnd = listCtrl.GetSafeHwnd();
DWORD style = ListView_GetExtendedListViewStyle(listWnd);
ListView_SetExtendedListViewStyle(listWnd,LVS_LIST /*| LVS_NOCOLUMNHEADER |LVS_EX_GRIDLINES*/);
style = ListView_GetExtendedListViewStyle(listWnd);
LV_COLUMN lvCol;
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
lvCol.fmt = LVCFMT_LEFT;
lvCol.iSubItem = 0;
//添加表頭
lvCol.cx = 100;
lvCol.pszText = _T("文件名稱");
ListView_InsertColumn(listWnd,0,&lvCol);
lvCol.cx = 100;
lvCol.pszText = _T("文件名稱");
ListView_InsertColumn(listWnd,1,&lvCol);
#endif
DWORD funNum = 0;
FunControl *tmpFunCtl = NULL;
switch(curFunType)
{
case ENGINEERINGMODE:
funNum = sizeof(engFunControl) / sizeof(FunControl);
tmpFunCtl = engFunControl;
break;
case SYSTEMINFO:
tmpFunCtl = systemFunControl;
funNum = sizeof(systemFunControl) / sizeof(FunControl);
break;
case DEBUGINFO:
funNum = sizeof(debugFunControl)/sizeof(FunControl);
tmpFunCtl = debugFunControl;
break;
default:
break;
}
listCtrl.DeleteAllItems();
listCtrl.InsertItem(0,_T("請選擇: "));
for(DWORD i=0;i<funNum;i++)
{
if (tmpFunCtl[i].Name != NULL && wcslen(tmpFunCtl[i].Name) > 0)
{
listCtrl.InsertItem(i+1,tmpFunCtl[i].Name);
}
}
listCtrl.DeleteItem(0);
SetCursor(LoadCursor(NULL,IDC_NO));
}
void CEngModeExView::executeSelFun()
{
SetCursor(LoadCursor(NULL, IDC_WAIT));
CListCtrl& m_FunList = GetListCtrl();
DWORD selCount = m_FunList.GetSelectedCount();
if(selCount < 1)
{
goto Exit;
}
DWORD selItem = 0;
POSITION pos = m_FunList.GetFirstSelectedItemPosition();
if (pos == NULL)
{
goto Exit;
}
else
{
while (pos)
{
selItem = m_FunList.GetNextSelectedItem(pos);
}
}
FunControl *tmpFunCtl = NULL;
switch(curFunType)
{
case ENGINEERINGMODE:
tmpFunCtl = engFunControl;
break;
case SYSTEMINFO:
tmpFunCtl = systemFunControl;
break;
case DEBUGINFO:
tmpFunCtl = debugFunControl;
break;
default:
tmpFunCtl = engFunControl;
break;
}
//TCHAR *strReturn = NULL;
if (tmpFunCtl != NULL && (tmpFunCtl[selItem].funName != NULL))
{
if(TRUE == (tmpFunCtl[selItem].funName)())
{
if (wcslen(strReturnData) >1)
{
TCHAR tmpName[256];
StringCchCopy(tmpName,sizeof(tmpName),tmpFunCtl[selItem].Name);
StringCchCat(tmpName,sizeof(tmpName),_T(":"));
StringCchCat(tmpName,sizeof(tmpName),strReturnData);
m_FunList.SetItemText(selItem,0,tmpName);
//SysFreeString(strReturn);
//strReturn = NULL;
}
}
}
else
{
SetCursor(LoadCursor(NULL,IDC_NO));
}
Exit:
SetCursor(LoadCursor(NULL,IDC_NO));
return;
}
// CEngModeExView 診斷
#ifdef _DEBUG
void CEngModeExView::AssertValid() const
{
CListView::AssertValid();
}
CEngModeExDoc* CEngModeExView::GetDocument() const // 非調試版本是內聯的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEngModeExDoc)));
return (CEngModeExDoc*)m_pDocument;
}
#endif //_DEBUG
// CEngModeExView 消息處理程序
void CEngModeExView::OnSysteminfo()
{
curFunType = SYSTEMINFO;
OnInitialUpdate();
}
void CEngModeExView::OnEngmode()
{
curFunType = ENGINEERINGMODE;
LoadRILLib();
OnInitialUpdate();
}
void CEngModeExView::OnDebug()
{
curFunType = DEBUGINFO;
OnInitialUpdate();
}
void CEngModeExView::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult)
{
executeSelFun();
// TODO: Add your control notification handler code here
*pResult = 0;
}
void CEngModeExView::OnDestroy()
{
CListView::OnDestroy();
unLoadRILLib();
// TODO: Add your message handler code here
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -