winMain is a default main function nothing else. window.cpp included in it.
without the polygon the code can be compiled and a simple window shows. but when i want to draw a polygon i get the following error message:
D:\...\window.cpp|| undefined reference to `Polygon@12'|
tried to find the implementation of polygon but my IDE(codeblocks) cannot find it.
window.cpp
#include "window.h"
LRESULT CALLBACK window::windproc(HWND hMain, UINT msg, WPARAM wParam, LPARAM lParam)
// PROCEDURE OF THE MAIN WINDOW
{
HDC hdc;
PAINTSTRUCT ps;
POINT pt[3];
pt[0].x = 300;
pt[0].y = 200;
pt[1].x = 350;
pt[1].y = 100;
pt[2].x = 400;
pt[2].y = 200;
switch(msg)
{
case WM_PAINT:
hdc = BeginPaint(hMain,&ps);
Polygon(hdc,pt,3);
EndPaint(hMain,&ps);
break;
case WM_MBUTTONDOWN:
PostQuitMessage(0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hMain, msg, wParam, lParam);
}
return 0;
}
void center_window(HWND main)
{
RECT rc;
GetClientRect(main, &rc);
int xPos = (GetSystemMetrics(SM_CXSCREEN) - rc.right)/2;
int yPos = (GetSystemMetrics(SM_CYSCREEN) - rc.bottom)/2;
SetWindowPos(main, 0, xPos, yPos, 0, 0, SWP_NOZORDER | SWP_NOSIZE );
}
void check_return(HWND main)
{
if(!main)
MessageBox(main, __FILE__, "ERROR", MB_OK | MB_ICONERROR);
}
window.h
#include <windows.h>
class window
{
public:
class invalid{}; // to throw an exception
window(){}
~window(){}
LPCSTR label{"main"};
LPCSTR title{"Placeholder"};
static LRESULT CALLBACK windproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
};
// AUX FUNCTIONS
void center_window(HWND hwnd);
void check_return(HWND hwnd);