1. RichEdit2.0控件使用
1.1使用该控件需要有如下操作为前提
APP头文件中添加私有成员:
HMODULE hMod;
源文件中重载虚函数:
InitInstance()
{
hMod = LoadLibrary(_T("riched20.dll"));
AfxInitRichEdit2();
}
ExitInstance()
{
// TODO: 在此添加专用代码和/或调用基类
FreeLibrary(hMod);
return CWinApp::ExitInstance();
}
2. 线程使用
2.1 Winows API函数
类内声明私有函数:
static DWORD WINAPI TestProc(LPVOID lpParameter);
创建线程
HANDLE hThreadSync;
hThreadSync = CreateThread(NULL, 0, TestProc, (LPVOID)this, 0, NULL);
if (hThreadSync == NULL)
{
AfxMessageBox("工作线程启动失败!",MB_OK|MB_ICONERROR);
return FALSE;
}
CloseHandle(hThreadSync);
线程函数:
DWORD WINAPI CTTMSystemDlg::TestProc(LPVOID lpParameter);
{
CTTMSystemDlg *pDlg = (CTTMSystemDlg *)lpParameter;
while (1)
{
if (pDlg->m_socketTestTx.isConnected())
{
pDlg->m_bTteSyc[TX] = pDlg->IsTteSync(pDlg->m_socketTestTx);
pDlg->PhyLinkStatusTest(pDlg->m_socketTestTx, &(pDlg->m_phyLinkStatus[TX]));
}
if (pDlg->m_socketTestRx.isConnected())
{
pDlg->m_bTteSyc[RX] = pDlg->IsTteSync(pDlg->m_socketTestRx);
pDlg->PhyLinkStatusTest(pDlg->m_socketTestRx, &(pDlg->m_phyLinkStatus[RX]));
}
}
return 0;
}