Click here to Skip to main content
15,912,837 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralDrawing simple shapes and controlling them Pin
Hmmkk5-Jun-05 1:23
Hmmkk5-Jun-05 1:23 
GeneralRe: Drawing simple shapes and controlling them Pin
Hmmkk5-Jun-05 2:15
Hmmkk5-Jun-05 2:15 
GeneralFrom, "Windows Forms Programming in C#" Pin
ursus zeta5-Jun-05 10:50
ursus zeta5-Jun-05 10:50 
GeneralRe: From, "Windows Forms Programming in C#" Pin
Hmmkk6-Jun-05 11:01
Hmmkk6-Jun-05 11:01 
Generalconfusing Pin
ursus zeta7-Jun-05 8:16
ursus zeta7-Jun-05 8:16 
GeneralRe: confusing Pin
Hmmkk7-Jun-05 11:43
Hmmkk7-Jun-05 11:43 
Generaltoo much info Pin
ursus zeta10-Jun-05 10:50
ursus zeta10-Jun-05 10:50 
General3 occurences of error C2039 Pin
joseph19503-Jun-05 4:36
joseph19503-Jun-05 4:36 
Hello again,

I am recreating an example app - a hexadecimal editor - I am getting three errors when I compile.
These are all C2039's. They are "MeasureFontHeight" is not a member of "CHexViewerView","Top" is not a member of "CRect", and "ReadLine" is not a member of "HexViewerDoc". The code using these follows:

// HexViewerView.cpp : implementation of the CHexViewerView class
//

#include "stdafx.h"
#include "HexViewer.h"

#include "HexViewerDoc.h"
#include "HexViewerView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CHexViewerView

IMPLEMENT_DYNCREATE(CHexViewerView, CScrollView)

BEGIN_MESSAGE_MAP(CHexViewerView, CScrollView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()

// CHexViewerView construction/destruction

CHexViewerView::CHexViewerView()
{
// TODO: add construction code here
memset(&m_logfont, 0, sizeof(m_logfont));
m_nPointSize = 120;

_tcscpy(m_logfont.lfFaceName, _T("Fixedsys"));

CWindowDC dc(NULL);
m_logfont.lfHeight = ::MulDiv(m_nPointSize,
dc.GetDeviceCaps(LOGPIXELSY),720);
m_logfont.lfPitchAndFamily = FIXED_PITCH;

m_pFont = new CFont;
m_pFont->CreateFontIndirect(&m_logfont);

}

CHexViewerView::~CHexViewerView()
{
if (m_pFont != NULL)
{
delete m_pFont;
}

}

BOOL CHexViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CScrollView::PreCreateWindow(cs);
}
int CHexViewerView::MeasureFontHeight(CFont* pFont, CDC* pDC)
{
//how tall is the identified font in the identified device class(DC)
CFont* pOldFont;
pOldFont = pDC->SelectObject(pFont);

CRect rectDummy;
CString strRender = _T("1234567890ABCDEF- ");
int nHeight = pDC->DrawText(strRender, -1, rectDummy,
DT_TOP | DT_SINGLELINE | DT_CALCRECT);
pDC->SelectObject(pOldFont);

return nHeight;
}

// CHexViewerView drawing

void CHexViewerView::OnDraw(CDC* pDC)
{
CHexViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

CString strRender;
CFont* pOldFont;
CSize ScrolledSize;
//int MeasureFontHeight;
int nStartLine;
int nHeight;
CRect ScrollRect;
CPoint ScrolledPos = GetScrollPosition();

CRect rectClient;
GetClientRect(&rectClient);

//Determine how tall each line is
pOldFont = pDC->SelectObject(m_pFont);
nHeight = MeasureFontHeight(m_pFont, pDC);
//Find a starting line based on scrolling
//and current line size
ScrolledSize = CSize(rectClient.Width(),
rectClient.Height());
ScrollRect = CRect(rectClient.left, ScrolledPos.y,
rectClient.right,
ScrolledSize.cy + ScrolledPos.y);
nStartLine = ScrolledPos.y/16;
//Verify we are where we should be
ScrollRect.Top= nStartLine*nHeight;

if (pDoc->m_pFile != NULL)
{
int nLine;
for (nLine = nStartLine;
ScrollRect.top < ScrollRect.bottom;
nLine++)
{
if (!pDoc->ReadLine(strRender, 16, nLine*16))
break;

nHeight = pDC->DrawText(strRender, -1,
&ScrollRect,
DT_TOP | DT_NOPREFIX | DT_SINGLELINE);
ScrollRect.top += nHeight;
}
}

pDC->SelectObject(pOldFont);

// TODO: add draw code for native data here
}

void CHexViewerView::OnInitialUpdate()
{
CHexViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

CSize sizeTotal(0,pDoc->m_lFileSize);
SetScrollSizes(MM_TEXT, sizeTotal);

CScrollView::OnInitialUpdate();


}




// CHexViewerView printing




BOOL CHexViewerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

void CHexViewerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}

void CHexViewerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}


// CHexViewerView diagnostics

#ifdef _DEBUG
void CHexViewerView::AssertValid() const
{
CScrollView::AssertValid();
}

void CHexViewerView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}

CHexViewerDoc* CHexViewerView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHexViewerDoc)));
return (CHexViewerDoc*)m_pDocument;
}
#endif //_DEBUG


// CHexViewerView message handlers

******************************************************

the associated header file code follows:

******************************************************

// HexViewerView.h : interface of the CHexViewerView class
//


#pragma once


class CHexViewerView : public CScrollView
{
protected: // create from serialization only
CHexViewerView();
DECLARE_DYNCREATE(CHexViewerView)

// Attributes
public:
CHexViewerDoc* GetDocument() const;
protected:
CFont* m_pFont;
LOGFONT m_logfont;
int m_nPointSize;
int m_nPageHeight;
int m_nPageWidth;

// Operations
public:

// Overrides
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// Implementation
public:
virtual ~CHexViewerView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG // debug version in HexViewerView.cpp
inline CHexViewerDoc* CHexViewerView::GetDocument() const
{ return reinterpret_cast<CHexViewerDoc*>(m_pDocument); }
#endif

**********************************************************************************

The ReadLine is iterated in the code segment from HexViewerDoc.cpp which follows:

**********************************************************************************

public:
BOOL ReadLine(CString& strLine,
int nLength,
LONG lOffset = -IL);
// TODO: Add your specialized creation code here

return TRUE;

I am unable to see what I am doing wrong. Can anyone help please ?
Thank you in advance. Joe





GeneralRe: 3 occurences of error C2039 Pin
toxcct5-Jun-05 3:33
toxcct5-Jun-05 3:33 
GeneralRe: 3 occurences of error C2039 Pin
joseph19506-Jun-05 2:52
joseph19506-Jun-05 2:52 
GeneralRe: 3 occurences of error C2039 Pin
toxcct6-Jun-05 2:57
toxcct6-Jun-05 2:57 
GeneralRe: 3 occurences of error C2039 Pin
joseph19506-Jun-05 7:38
joseph19506-Jun-05 7:38 
Generalremoving variable Pin
joseph19503-Jun-05 2:56
joseph19503-Jun-05 2:56 
GeneralRe: removing variable Pin
toxcct3-Jun-05 3:33
toxcct3-Jun-05 3:33 
GeneralRe: removing variable Pin
joseph19503-Jun-05 4:15
joseph19503-Jun-05 4:15 
GeneralLabel Text problems Pin
Hmmkk2-Jun-05 8:34
Hmmkk2-Jun-05 8:34 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 10:02
protectorChristian Graus2-Jun-05 10:02 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:25
Hmmkk2-Jun-05 10:25 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 10:30
protectorChristian Graus2-Jun-05 10:30 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:38
Hmmkk2-Jun-05 10:38 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 10:46
protectorChristian Graus2-Jun-05 10:46 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:48
Hmmkk2-Jun-05 10:48 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:57
Hmmkk2-Jun-05 10:57 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 12:18
protectorChristian Graus2-Jun-05 12:18 
GeneralPassing data between forms Pin
richiemac1-Jun-05 8:58
richiemac1-Jun-05 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.