This is one of my source files 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;
}
}
This is .cpp file that draws the graph.
This is the header file, Global.h, I'm using to make 'hdc' the global variable:
#ifndef SOURCE1_H_
#define SOURCE1_H_
extern HDC hdc;
#endif
The declaration is as follows in Win32Project5.cpp (bad name I know):
#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;
And I get the errors:
LNK1120 1 unresolved externals
LNK2001 unresolved external symbol "struct HDC__ * hdc" (?hdc@@3PAUHDC__@@A)
Win32Project5 F:\Win32Project5\Win32Project5\ThreeDGraph.obj< 1
I don't think it is being declared anywhere else expect in Win32Project5.cpp if you could lend me hand that would be greatly appreciated, I'll edit if you need anymore information.