Hello!
I am working on a Windows Forms application using CLR. Up to now, everything has gone great, but I am trying to set a pixel in the form with the standard SetPixel() method supplied by the Windows API.
Unfortunately, whenever I try to do this, I get Error LNK2019, saying essentially that the SetPixel() function is an 'unresolved external symbol.'
This is a huge problem for me because without being able to set pixels I will not be able to even get started on the actual rendering I'm planning to do with the application.
(I'm using SetPixel() as a way of making a temporary 'graphics engine' that can draw on windows. I've made one before that worked fine (albeit painstakingly slowly), so I know I'm doing everything else perfectly. Obviously, when I start to use real graphics and rendering in my application, I'm not going to use SetPixel() but I want to be certain that Windows API functions still work, as they will be the backbone of my engine.)
Code:
(in RenderBase.h)
#ifndef RENDERBASE_H
#define RENDERBASE_H
#include <Windows.h>
class RenderBase
{
public:
void SetPixel(int x, int y, COLORREF color);
COLORREF GetPixel(int x, int y);
};
#endif
(in RenderBase.cpp)
#include "RenderBase.h"
void RenderBase::SetPixel(int _X, int _Y, COLORREF _Color)
{
HDC hDC = GetDC(GetActiveWindow());
::SetPixel(hDC, 12 + _X, 37 + _Y, _Color); //Offset the coordinates given so they show where I want them to
}