I am new to windows programming in visual studio(i mean visual c++)
I made a C++ file to include WndProc(containing WM_PAINT,WM_DESTROY and WM_KEYDOWN),then I thought to include a class name CEventHandler store it in EventHandler.h
The class definition in EventHandler.cpp and main in try.cpp,They all are part of a project named try2.vcproj stored at same folder.
When I tried to compile the project it informed that EventHandler.h not found fatal error C1083!!!!!
Plz help me!!!!
Thanx.

Is EventHandler.h is a file that you created? If it is then use Windows Explorer and check if the file exists ? Is it in the same folder as the other source files, such as try.cpp ? If all those are ok, then post the code for the file that gives you that error.

Ya EventHandler.h is the file I have created.
the file do exists and in the same folder wid try.cpp.

Here is my EventHandler.h

#include <windows.h>

class CEventHandler
{
	CEventHandler();
	~CEventHandler();
	void paint(HWND hWnd,HDC hDC);
	void Key_Press(HWND hWnd);
private:
	static bool boolDrawText;
}

Here is my EventHandler.cpp

#include "EventHandler.h"

CEventHandler::CEventHandler()
{
	boolDrawText=true;
}
CEventHandler::~CEventHandler()
{
}
void CEventHandler::paint(HWND hWnd,HDC hDC)
{
	PAINTSTRUCT ps;
	RECT rectClient={1000,1000,1000,1000};
	hWnd=BeginPaint(hDC,&ps);
if(boolDrawText)
{
	
	GetClientRect(hWnd,&rectClient);
	DrawText=
		(
			hDC,
			TEXT("3 tutorial"),
			-1,
			&rectClient,
			DT_SINGLELINE|DT_CENTER|DT_VCENTER)
		);
	EndPaint(hWnd,&ps);
}
	
}

void CEventHandler::Key_Press(HWND hWnd)
{
	boolDrawText=!boolDrawText;
	InvalidateRect(hWnd,NULL,true);
	
}

Here is my try.cpp

#include <windows.h>
#include "EventHandler.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
CEventHandler * g_pCEventHandler;

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
   HWND                hWnd;
   MSG                 msg;
   WNDCLASS            wndClass;
   
   // The application performs the following tasks.
   // 1. Create a window 
   // 2. show the window
   // 3. Retrieve and dispatch windows events until window is destroyed

   // 1. Create a window

   // 1.1 Create a WndProc. see WndProc defined below  

   // 1.2 initialize a window class structure
   // this tells the OS what type of window you want.
   // The window class contains the windows procedure
   // wndproc that will run the window
   wndClass.style          = CS_HREDRAW | CS_VREDRAW;
   wndClass.lpfnWndProc    = WndProc;
   wndClass.cbClsExtra     = 0;
   wndClass.cbWndExtra     = 0;
   wndClass.hInstance      = hInstance;
   wndClass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
   wndClass.hCursor        = LoadCursor(NULL, IDC_ARROW);
   wndClass.hbrBackground  = (HBRUSH)GetStockObject(WHITE_BRUSH);
   wndClass.lpszMenuName   = TEXT("klo");
   wndClass.lpszClassName  = TEXT("My Type of Window");
   
   // 1.3 register it with the OS
   RegisterClass(&wndClass);
   
   // 1.4 Ask the OS to create the window.
   // It is not yet visible. 
   // The OS has created an internal representation
   // of it.
   hWnd = CreateWindow
	  (
      TEXT("My Type of Window"),   // window class name
      TEXT("Try2"),  // window caption
      WS_OVERLAPPEDWINDOW,      // window style
      CW_USEDEFAULT,            // initial x position
      CW_USEDEFAULT,            // initial y position
      CW_USEDEFAULT,            // initial x size
      CW_USEDEFAULT,            // initial y size
      NULL,                     // parent window handle
      NULL,                     // window menu handle
      hInstance,                // program instance handle
      NULL						// creation parameters
	  ); 
   g_pEventHandler=new CEventHandler;
	  
   // 2. show the window. 
   // 2.1 The OS now displays the window
   // on the screen. The client area of the window is blank
   ShowWindow(hWnd, iCmdShow);
   // 2.2 update the window. This OS call results in 
   // a WM_PAINT event being sent to your window that asks it to
   // draw itself for the first time. The client area is drawn now.
   UpdateWindow(hWnd);
   // initialize the window done

   // 3. start retreiving and dispatching messages from the message queue for the window.
   // Here we are asking the OS to retrieve messages
   // from our message queue and dispatching them to our WndProc
   // Translate message is asking the OS 
   // to translate some keyboard
   // related information in the message
   while(GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   // GetMessage returns false when the OS tells you there are no more events.
   // This happens when your window has been destroyed.
 delete g_pEventHandler;
   return (int) (msg.wParam);
}  // WinMain

LRESULT CALLBACK WndProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
	HDC hDC=0;
	

	switch(Message)
	{
	case WM_PAINT:
		g_pEventHandler->paint(hWnd,hDC);
		return 0;
	
	case WM_KEYDOWN:
		g_pEventHandler->Key_Press(hWnd);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
	default:
		return DefWindowProc(hWnd,Message,wParam,lParam);
	}
}

Thanx.

Here are some other possible causes for that error number. One of the reasons is that your project is set up to use precompiled headers and the file "stdafx.h" is not present in the project. Solution is to turn off precompiled headers.

What compiler are you using? Do you have windows.h on your computer ? If not then you will have to download the huge Windows SDK.

SIR,
I have included stdafx.h and nothing got correct.
the errors I got are:
1>d:\study material\sen\mywork\eventhandler.cpp(1) : fatal error C1083: Cannot open include file: 'EventHandler.h': No such file or directory
1>d:\study material\sen\mywork\try1.cpp(2) : fatal error C1083: Cannot open include file: 'EventHandler.h': No such file or directory
This is the path of EventHandler.h:(I got this by right-clicking the EventHandler.h tab and then clicking copy full path)
d:\study material\SEN\MyWork\EvevtHandler.h
EventHandler.cpp path:
d:\study material\SEN\MyWork\EventHandler.cpp
try1.cpp path:
d:\study material\SEN\MyWork\try1.cpp

PLZ help!

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