未声明标识符?强制转化也不行

#include "stdafx.h"
#include "afxmt.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义,并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "Porject1.h"
#endif

#include "Porject1Doc.h"
#include "Porject1View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CPorject1View

IMPLEMENT_DYNCREATE(CPorject1View, CFormView)

BEGIN_MESSAGE_MAP(CPorject1View, CFormView)
ON_WM_CONTEXTMENU()
ON_WM_RBUTTONUP()
ON_BN_CLICKED(IDC_DATA_LINE, &CPorject1View::OnDataLine)
ON_BN_CLICKED(IDC_END_DATA_LINE, &CPorject1View::OnEndThread)
ON_WM_PAINT()
ON_STN_CLICKED(IDC_DATA_ON_TIME, &CPorject1View::OnDataOnTime)
ON_STN_CLICKED(IDC_DATA_ON_TIME_thread, &CPorject1View::OnStnClickedDataOnTimethread)
END_MESSAGE_MAP()

// CPorject1View 构造/析构

CPorject1View::CPorject1View()
: CFormView(CPorject1View::IDD)
{
// TODO: 在此处添加构造代码

}

CPorject1View::~CPorject1View()
{
}

void CPorject1View::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}

BOOL CPorject1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式

return CFormView::PreCreateWindow(cs);

}

void CPorject1View::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();

}

void CPorject1View::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
ClientToScreen(&point);
OnContextMenu(this, point);
}

void CPorject1View::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}

// CPorject1View 诊断

#ifdef _DEBUG
void CPorject1View::AssertValid() const
{
CFormView::AssertValid();
}

void CPorject1View::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}

CPorject1Doc* CPorject1View::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPorject1Doc)));
return (CPorject1Doc*)m_pDocument;
}
#endif //_DEBUG

// CPorject1View 消息处理程序
CEvent EndPaintLine;//用来控制绘制线程结束的事件
POINT polyLine[31];//存放动态数据曲线数据值的数组
DWORD pLinePoints;//当前需绘制曲线的点数
int TimeSpan_GetData;//绘制动态曲线的时间间隔,具体系统中可在界面上加一微调按钮调整
CBrush * pBrushBlack = new CBrush;
void CPorject1View::OnDataLine()
{

// TODO:  在此添加控件通知处理程序代码
//启动工作线程并画出绘制动态曲线的子窗口的背景矩形框
CWnd*pWnd = GetDlgItem(IDC_DATA_ON_TIME_thread);
//获取绘制曲线文本框窗口指针
CDC * pDC = pWnd->GetDC();
CGdiObject * pOldBursh = pDC->SelectObject(pBrushBlack);
pDC->Rectangle(0, 0, 300, 200);
//用黑色绘制显示动态数据曲线的子窗口
pDC->SelectObject(pOldBursh);
CWinThread * pThreadDataOnTime = AfxBeginThread(DataLineThread,(LPVOID )GetSafeHwnd(), THREAD_PRIORITY_NORMAL);

}

void CPorject1View::OnEndThread()
{
// TODO: 在此添加控件通知处理程序代码
EndPaintLine.SetEvent();
}

void CPorject1View::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CFormView::OnPaint()
CWnd * pWnd = GetDlgItem(IDC_DATA_ON_TIME_thread);
//获取绘制曲线的文本框指针
pWnd->Invalidate();
pWnd->UpdateWindow();
CDC * pDC = pWnd->GetDC();
CGdiObject * pOldBrush = pDC->SelectObject(pBrushBlack);
pDC->Rectangle(0, 0, 300, 200); //绘制图曲线的矩形区域
pDC->SelectObject(pOldBrush);
}

void CPorject1View::OnDataOnTime()
{
// TODO: 在此添加控件通知处理程序代码
}

UINT DataLineThread(LPVOID lp)
{
CPen * pPenGreen = new CPen;
CPen * pPenBlack = new CPen;
CPen * pPenBKcolor = new CPen;
CPen * pPenRed = new CPen;
CPen * pPenBlue = new CPen;
CBrush * pBrushBlack = new CBrush;
pPenRed->CreatePen(PS_DOT, 1, RGB(255, 0, 0));
pPenBlue->CreatePen(PS_DOT, 1, RGB(10, 150, 255));
pPenBlack->CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
pPenGreen->CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
pPenBKcolor->CreatePen(PS_SOLID, 1, RGB(190, 190, 190));
pBrushBlack->CreateSolidBrush(RGB(0, 0, 0));
CWnd * pMainWnd = AfxGetMainWnd();
CWnd * pClient = pMainWnd->GetWindow(GW_CHILD);
CWnd * pData = pClient->GetDlgItem(IDC_DATA_ON_TIME_thread);
CDC * pDC = pData->GetDC();
BOOL runThread = TRUE;
while (runThread)
{
CWnd * pWnd =pClient-> GetDlgItem(IDC_DATA_ON_TIME);
CDC * pDC = pWnd->GetDC();
CGdiObject * pOldPen = pDC->SelectObject(pPenBlue);
static int count_T = 0;
pDC->SetBkColor(RGB(0, 0, 0));
for (int i = 0; i <= 30; i += 5)
{
if (300 - 10 * (i + count_T) >= 0)
{
pDC->MoveTo(300 - 10 * (i + count_T), 200);
pDC->LineTo(300 - 10 * (i + count_T), 0);
if ((i + count_T - 1) >= 0)
{
CGdiObject * pPenT = pDC->SelectObject(pPenBlack);
pDC->MoveTo(300 - 10 * (i + count_T - 1), 200);
pDC->LineTo(300 - 10 * (i + count_T - 1), 0);
pDC->SelectObject(pPenT);

            }
        }
        pDC->SelectObject(pOldPen);
        count_T++;
        if (count_T == 5)
            count_T = 0;
        char tm[20]; 
        _strtime(tm);
        pDC->SetBkColor(RGB(190, 190, 190));
        pDC->TextOut(280, 205,_T("tm"));
        for (i = 0; i <= 20; i += 5)
        {
            pOldPen = pDC->SelectObject(pPenRed);
            pDC->SetBkColor(RGB(0, 0, 0));
            pDC->MoveTo(0, i * 10);
            pDC->LineTo(300, i * 10);
            pDC->SelectObject(pOldPen);
        }
        if (pLinePoints >= 2)
        {
            pOldPen = pDC->SelectObject(pPenBlack);
            pDC->Polyline(polyLine, pLinePoints);
            pDC->SelectObject(pOldPen);

        }
        static int col = 0;
        int m_OnData; char mC[40];
        if (col < 31)
        {
            for (int j = 0; j <= col; j++)
                polyLine[j].x = 300 - (col - j) * 10;
            m_OnData = rand()%200;
            polyLine[col].y = m_OnData;
            col++;
            pLinePoints++;
        }
        else
        {
            pLinePoints = 31;
            for (int t = 0; t < 30; t++)
                polyLine[t].y = polyLine[t + 1].y;
            m_OnData = rand()%200;
            polyLine[30].y = m_OnData;
        }
        itoa(m_OnData, mC, 10);
        pDC->SetBkColor(RGB(190, 190, 190));
        pDC->TextOut(310, 35, _T("实时数据"));
        if (pLinePoints >= 2)
        {
            pOldPen = pDC->SelectObject(pPenGreen);
            pDC->Polyline(polyLine, pLinePoints);
            pDC->SetTextColor(RGB(0, 0, 0));
            pDC->SelectObject(pOldPen);
        }
        int retCode = ::WaitForSingleObject(EndPaintLine.m_hObject, 0);
        if (retCode == WAIT_OBJECT_0)
            runThread = FALSE;
        ::Sleep(TimeSpan_GetData);


    }
    delete pPenRed;
    delete pPenBlue;
    delete pPenGreen;
    delete pPenBlack;
    delete pPenBKcolor;
    delete pBrushBlack;
    return 0;
}

}

void CPorject1View::OnStnClickedDataOnTimethread()
{
// TODO: 在此添加控件通知处理程序代码
}
error C2065: “DataLineThread”: 未声明的标识符

c++

1个回答

把DataLineThread这个函数的定义,放在
CWinThread * pThreadDataOnTime = AfxBeginThread(DataLineThread,(LPVOID )GetSafeHwnd(), THREAD_PRIORITY_NORMAL);
的前面

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
OpenCV4.0+VS2017下运行程序总是出现未定义标识符
2
【球球大家了】VS2017出现error C2062: 意外的类型“char”怎么解决?
2
C语言函数声明中带不带标识符的问题
0
输入一个字符串,判断其是否是C的合法标识符,运用C语言编程处理的方式
3
C++如何将一个10进制int数转换成16进制的带0x标识符的int型数
3
error C2065: “c”: 未声明的标识符 error C2143: 语法错误: 缺少“;”(在“return”的前面)
0
__outpw函数在VC 64位平台编译提示找不到标识符
1
文件标识符必须为双精度类型的整数值标量。MATLAB出现上述问题如何改
3
c语言,关于getline函数找不到标识符
0
用pthreadVC2.dll编写多线程程序一直报错 error C2065: “pthread_t ”: 未声明的标识符,为什么
1
Oracle的listagg函数在group by中使用时提示标识符无效,用wm_concat可以,但想将连接符换成分号
4
ie8浏览器下网页运行后提示js错误,缺少标识符、数字、字符串
1
VS2017创建MFC程序 报错 AFX_IDW_MENUBAR未声明的标识符是怎么回事
1
我声明了的,为什么还显示error C2065: “p”: 未声明的标识符?
0
判断其是否是C的合法标识符
0
C语言合法标识符的表示计算
7
没有唯一标识符id也能准确查询数据库吗
1
为什么VS中 int gd = VGA; int gm = VGAHI;会报错未定义标识符?
1
PCL1.8.1+vs2017运行报错065 L2_Simple”: 未声明的标识符
1
C#如何获取传入参数的标识符