Hey so my project is an Average Calculator to calculate the average of a set of numbers. Anyways, I must make it in a GUI and I have chosen Win32. My problem now resides while trying to do the following:
- When there is a paint request, to paint anything. (e.g text or change in display) there must be a handler that handles it outside of the main file.

Im totally new to classes and Win32 itself so sorry for my "nooby" mistakes. Anyways, Here is my code:

PaintHandler.cpp

#include <Windows.h>
#include "stdafx.h"
#include "PaintHandler.h"

class PaintHandler{

};
/**/


void PaintHandler::writeText(HWND hWnd, HDC hdc, int x, int y, char text) {
	TextOut(hdc, x, y, (LPCWSTR) text,11);
}

PaintHandler.h

class PaintHandler{

public:
	void writeText(HWND hWnd, HDC hdc, int x, int y, char text);
}

stdafx.h

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <Windows.h>
#include <Windows.h>
#include <iostream>

// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>


// TODO: reference additional headers your program requires here
#include "PaintHandler.h"

You can probably tell from above that im using Visual C++ (2010) and im trying to avoid the usage of .NET

So my problem is in the Paint Handler.cpp file which at line number 11.

void PaintHandler::writeText(HWND hWnd, HDC hdc, int x, int y, char text) {

I get the following error:
Error: class "Paint Handler" has no member "writeText".

I have no clue why it is saying that. Also, if my classes concept is incorrect please let me know. Any help is appreciated :)
Thanks

#include "stdafx.h"

class PaintHandler {
	PaintHandler() {
	}


	void PaintHandler::writeText(HWND hWnd, HDC hdc, int x, int y, char text) {
		TextOut(hdc, x, y, (LPCWSTR) text,11);
	}
};

I did this and it works. Why ? But I get error : error C2011: 'PaintHandler' : 'class' type redefinition

Edited 5 Years Ago by becool007: n/a

This question has already been answered. Start a new discussion instead.