这是我的源文件之一ThreeDGraph.cpp:
#include "StdAfx.h"
#include "Global.h"
#include "Win32Project5.h"
#include "ThreeDGraph.h"
#include "ClipinData.h"
#include <windows.h>
#include <string>
#include <ios>
#define MAX_LOADSTRING 100
void CThreeDGraph::Draw3DGraph()
{
CClipinData ClipinData;
//CThreeDGraph Graph;
int SetXMaxValue, SetYMaxValue;
int SetXMinValue, SetYMinValue;
string TodaysDate;
string ClipinID = ClipinData.InstallationID;
int red = rand() % 256;
int green = rand() % 256;
int blue = rand() % 256;
HPEN CustomColourPen = CreatePen(PS_INSIDEFRAME, 1, RGB(red, green, blue));
HPEN BlackPen = CreatePen(PS_INSIDEFRAME, 1, RGB(0, 0, 0));
for (int Day = 0; Day < ClipinData.TotalNumberOfDaysOfData; Day++)
{
TodaysDate = ClipinData.ClipinDataSet[Day].DateOfStartOfData.FormatDateOnly();
int parameterID;
float parameterVAL;
int SecondsFromStartOfDay = 0;
//HDC hdcdraw = hdc;
int xoffset = 0;
int yoffset = 0;
SetXMaxValue = 864.4;
SetXMinValue = 10;
SetYMaxValue = 900;
SetYMinValue = 1;
MoveToEx(hdc, 10 + xoffset, 900 - yoffset, NULL);
for (int ParameterCount = 0; ParameterCount < ClipinData.ClipinDataSet[Day].totalNumberEvents; ParameterCount++)
{
parameterID = ClipinData.ClipinDataSet[Day].EventsList[ParameterCount].parameterID;
parameterVAL = ClipinData.ClipinDataSet[Day].EventsList[ParameterCount].parameterVAL;
SecondsFromStartOfDay = ClipinData.ClipinDataSet[Day].EventsList[ParameterCount].TimeFromStartOfSequence;
if (parameterID == PRIMARY_TEMP_ID)
{
SelectObject(hdc, CustomColourPen);
LineTo(hdc, (SecondsFromStartOfDay + xoffset) / 90 + xoffset, 900 - parameterVAL * 10 - yoffset);
}
}
SelectObject(hdc, BlackPen);
MoveToEx(hdc, 10, 1, NULL);
LineTo(hdc, SetXMinValue, SetXMaxValue);
LineTo(hdc, SetXMaxValue, SetYMaxValue);
MoveToEx(hdc, SetXMinValue, SetYMaxValue, NULL);
LineTo(hdc, 300, 600);
xoffset = xoffset + 10;
yoffset = yoffset + 10;
}
}
这是绘制图形的.cpp文件。
这是头文件Global.h,我用来制作&#39; hdc&#39;全局变量:
#ifndef SOURCE1_H_
#define SOURCE1_H_
extern HDC hdc;
#endif
声明如下Win32Project5.cpp(我知道名字错误):
#include "stdafx.h"
#include "Win32Project5.h"
#include "Global.h"
#include "ThreeDGraph.h"
#include "GBasic2DGraph.h"
#include "ClipinData.h"
#include <string>
#include <stdlib.h>
#include <vector>
#include <fstream>
#include <iostream>
#include <windows.h>
#include <winbase.h>
#include <direct.h>
#include "Shobjidl.h"
..........................
Line1: case WM_PAINT:
InvalidateRect(hWnd,NULL,true) ;
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
{
Graph.Draw3DGraph();
}
EndPaint(hWnd, &ps);
break;
我得到了错误:
LNK1120 1未解析的外部
LNK2001未解析的外部符号&#34; struct HDC__ * hdc&#34; (?HDC @@ 3PAUHDC __ @@ A)
Win32Project5 F:\ Win32Project5 \ Win32Project5 \ ThreeDGraph.obj&lt; 1
我不认为它会在Win32Project5.cpp的任何其他地方被宣布,如果你能借给我非常感谢的话,如果你需要更多信息,我会编辑。