Hi I am trying to put up simple app, and i get an error, could you tell me what I am doing wrong please. Here is my code:

#include <afxwin.h>

class myapi: public CWinApp
	virtual BOOL InitInstance();
class myframe: public CFrameWnd
	afx_msg void OnPaint();
#include "example.h"

BOOL myapi::InitInstance()
	m_pMainWnd=new myframe;
	return TRUE;

	Create(NULL,_T("bandymas I"));
void myframe::OnPaint()
	//CPaintDC dc(this);

the error msg I get is : Unhandled exception at 0x566d2bea in gdiexample.exe: 0xC0000005: Access violation reading location 0x00000000.
thank you

Recommended Answers

All 4 Replies

As a general rule of thumb, if you're trying to read location 0x00000000, it means you're trying to dereference a null pointer, either directly or by trying to use a member function/variable of a null object.

How am I doing this? I dont realy understand..

If you build a version with debug symbols, you can get more information on where the error is happening from the error message. Alternatively, run the program in debug mode (or whatever it's called under your IDE) with breakpoints everywhere, and work out which line must be causing the error

Thanks I found it, I can't sometimes believe what mistakes are done by me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.