Click here to Skip to main content
15,891,811 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: LZMA SDK and .zip files Pin
leon de boer16-May-14 19:00
leon de boer16-May-14 19:00 
QuestionDouble buffering Pin
imran.prdc14-May-14 20:58
imran.prdc14-May-14 20:58 
QuestionRe: Double buffering Pin
CPallini14-May-14 21:39
mveCPallini14-May-14 21:39 
AnswerRe: Double buffering Pin
Legor14-May-14 21:54
Legor14-May-14 21:54 
AnswerRe: Double buffering Pin
Richard MacCutchan14-May-14 21:56
mveRichard MacCutchan14-May-14 21:56 
AnswerRe: Double buffering Pin
Software_Developer15-May-14 4:35
Software_Developer15-May-14 4:35 
AnswerRe: Double buffering Pin
Stefan_Lang15-May-14 22:21
Stefan_Lang15-May-14 22:21 
QuestionCan I properly derive from CMFCPropertyGridColorProperty ? Pin
Maximilien14-May-14 4:10
Maximilien14-May-14 4:10 
I'm trying to derive from CMFCPropertyGridColorProperty and cannot override the virtual function because my derived class is not a friend of CMFCPropertyGridCtrl.

Here is a minimal representation of the problem.

C++
class CMFCPropertyGridCtrl 
{
	friend class CMFCPropertyGridColorProperty;

protected:
	CRect m_rectList; // Properies area
};

class CMFCPropertyGridColorProperty
{
	friend class CMFCPropertyGridCtrl;

public:
	virtual void AdjustInPlaceEditRect(CRect& rectEdit, CRect& rectSpin);

protected:
	// back pointer
	CMFCPropertyGridCtrl* m_pWndList;
};

void CMFCPropertyGridColorProperty::AdjustInPlaceEditRect(CRect& rectEdit, CRect& rectSpin)
{
	// original code removed for clarity.

	// access to CMFCPropertyGridCtrl::m_rectList;
	m_pWndList->m_rectList.left += 20;
}

class MyPropertyGrid : public CMFCPropertyGridColorProperty 
{
	virtual void AdjustInPlaceEditRect(CRect& rectEdit, CRect& rectSpin);
};

void MyPropertyGrid::AdjustInPlaceEditRect(CRect& rectEdit, CRect& rectSpin)
{
	// original code removed for clarity.
	// access to CMFCPropertyGridCtrl::m_rectList;
	m_pWndList->m_rectList.left += 40;  // ERROR.
}


trying to compile this, I get the following understandable error :
error C2248: 'CMFCPropertyGridCtrl::m_rectList' : cannot access protected member declared in class 'CMFCPropertyGridCtrl'
1> d:\projects\testfriend\testfriend\testfriend.cpp(21) : see declaration of 'CMFCPropertyGridCtrl::m_rectList'
1> d:\projects\testfriend\testfriend\testfriend.cpp(17) : see declaration of 'CMFCPropertyGridCtrl'


---

I'd like to be able to override the method
virtual void AdjustInPlaceEditRect(CRect& rectEdit, CRect& rectSpin);

void CMFCPropertyGridColorProperty::AdjustInPlaceEditRect(CRect& rectEdit, CRect& rectSpin)
{
	ASSERT_VALID(this);
	ASSERT_VALID(m_pWndList);

	rectSpin.SetRectEmpty();

	rectEdit = m_Rect;
	rectEdit.DeflateRect(0, 2);

	int nMargin = m_pWndList->m_bMarkModifiedProperties && m_bIsModified ? m_pWndList->m_nBoldEditLeftMargin : m_pWndList->m_nEditLeftMargin;

	rectEdit.left = m_pWndList->m_rectList.left + m_pWndList->m_nLeftColumnWidth + m_Rect.Height() + AFX_TEXT_MARGIN - nMargin + 1;

	AdjustButtonRect();
	rectEdit.right = m_rectButton.left;
}


To change the edit box position in the CMFCPropertyGridColorProperty class; but since I do not have access to the CMFCPropertyGridCtrl class (via m_pWndList), I cannot really override it.

Any hints/tips or something else that I might have missed?

Thanks.

Max.
I'd rather be phishing!

QuestionRe: Can I properly derive from CMFCPropertyGridColorProperty ? Pin
CPallini14-May-14 6:42
mveCPallini14-May-14 6:42 
AnswerRe: Can I properly derive from CMFCPropertyGridColorProperty ? Pin
Maximilien14-May-14 7:30
Maximilien14-May-14 7:30 
GeneralRe: Can I properly derive from CMFCPropertyGridColorProperty ? Pin
CPallini14-May-14 7:32
mveCPallini14-May-14 7:32 
GeneralRe: Can I properly derive from CMFCPropertyGridColorProperty ? Pin
Maximilien14-May-14 8:02
Maximilien14-May-14 8:02 
GeneralRe: Can I properly derive from CMFCPropertyGridColorProperty ? Pin
CPallini14-May-14 9:17
mveCPallini14-May-14 9:17 
QuestionCFile Error When Writing Pin
AmbiguousName14-May-14 1:52
AmbiguousName14-May-14 1:52 
QuestionRe: CFile Error When Writing Pin
CPallini14-May-14 2:34
mveCPallini14-May-14 2:34 
AnswerRe: CFile Error When Writing Pin
AmbiguousName14-May-14 6:57
AmbiguousName14-May-14 6:57 
AnswerRe: CFile Error When Writing Pin
Software_Developer14-May-14 6:36
Software_Developer14-May-14 6:36 
GeneralRe: CFile Error When Writing Pin
AmbiguousName14-May-14 6:56
AmbiguousName14-May-14 6:56 
GeneralRe: CFile Error When Writing Pin
Software_Developer14-May-14 7:27
Software_Developer14-May-14 7:27 
GeneralRe: CFile Error When Writing Pin
Richard MacCutchan14-May-14 21:55
mveRichard MacCutchan14-May-14 21:55 
GeneralRe: CFile Error When Writing Pin
leon de boer15-May-14 4:26
leon de boer15-May-14 4:26 
AnswerRe: CFile Error When Writing Pin
Jonathan Davies14-May-14 7:42
Jonathan Davies14-May-14 7:42 
QuestionIf I use a library, do I need DLL file ? Pin
_Flaviu12-May-14 21:50
_Flaviu12-May-14 21:50 
AnswerRe: If I use a library, do I need DLL file ? PinPopular
«_Superman_»12-May-14 22:11
professional«_Superman_»12-May-14 22:11 
GeneralRe: If I use a library, do I need DLL file ? Pin
AssemToCode14-May-14 17:46
AssemToCode14-May-14 17:46 

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.