Now I'm trying to display an image in view in the dialog in MFC.
The code as following.
void CTestview::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
CRect rcWin;
GetWindowRect( &rcWin );
double ff;
ff=rcWin.Width();
rcWin.Height();
DoDisplayImage();
}
and
void CTestview::DoDisplayImage(void)
{
CPoint pt;
CRect rectClient;
CDC * pDC;
pDC = GetDC();
GetClientRect(rectClient);
int ii;
ii=slider_val;
(void) MagickCore::SetClientPath(fileposition);
InitializeMagick(fileposition);
Image m_Image;
Image m_blurgray;
int _imageHeight;
try {
//C:\work\mfc_test5\mfc_test5
m_Image.read(fileposition);
}
catch(Exception)
{
return ;
}
char str_x[10];
char str_y[10];
if (pDC != NULL)
{
m_blurgray.gaussianBlur(20,2); //blur
int nImageY;
int nImageX;
CSize sizeScaled;
// Clear the background
pDC->FillSolidRect(rectClient,pDC->GetBkColor());
pt = rectClient.TopLeft();
nImageX= m_Image.columns() ;
//nImageY = m_Image.rows();
CPoint aa;
aa = rectClient.Size();
// Extract the pixels from Magick++ image object
PixelPacket *pPixels = m_Image.getPixels(0,0,m_Image.columns(),m_Image.rows());
// Set up the Windows bitmap header
BITMAPINFOHEADER bmi;
bmi.biSize = sizeof(BITMAPINFOHEADER);
bmi.biWidth =m_Image.columns();
bmi.biHeight = (-1)*m_Image.rows();
bmi.biPlanes = 1;
bmi.biBitCount = 32;
bmi.biCompression = BI_RGB;
bmi.biSizeImage = 0;
bmi.biXPelsPerMeter = 0;
bmi.biYPelsPerMeter = 0;
bmi.biClrUsed = 0;
bmi.biClrImportant = 0;
// Blast it to the device context
SetStretchBltMode(pDC->m_hDC,COLORONCOLOR);
StretchDIBits(pDC->m_hDC,
0,
0,
m_Image.columns(),
m_Image.rows(),
0,
0,
m_Image.columns(),
m_Image.rows(),
pPixels,
(BITMAPINFO *)&bmi,
DIB_RGB_COLORS,
SRCCOPY);
//UpdateData(FALSE);
}
}
The problem is that display image have so much delay when I display an image into view.
I don't know exactly what should I do for solving this problem.
update 1
I have update the code as following.
#pragma once
#include <Magick++.h>
// CTestview view
class CTestview : public CScrollView
{
DECLARE_DYNCREATE(CTestview)
protected:
CTestview(); // protected constructor used by dynamic creation
virtual ~CTestview();
public:
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual void OnInitialUpdate(); // first time after construct
DECLARE_MESSAGE_MAP()
public:
void DoDisplayImage(void);
Image m_image
};
When I compile above code then I've got some error as following.
------ Build started: Project: mfc_test5, Configuration: Release Win32 ------
Build started
PrepareForBuild:
Creating directory "C:\work\mfc_test5\mfc_test5\Release\".
InitializeBuildStatus:
Creating "Release\mfc_test5.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
stdafx.cpp
mfc_test5.cpp
c:\program files\imagemagick-6.8.6-q8\include\magick/pixel-accessor.h(160): warning C4244: '=' : conversion from 'double' to 'MagickCore::MagickRealType', possible loss of data
c:\work\mfc_test5\mfc_test5\mfc_test5\Testview.h(33): error C2143: syntax error : missing ';' before '}'
mfc_test5Dlg.cpp
c:\program files\imagemagick-6.8.6-q8\include\magick/pixel-accessor.h(160): warning C4244: '=' : conversion from 'double' to 'MagickCore::MagickRealType', possible loss of data
c:\work\mfc_test5\mfc_test5\mfc_test5\Testview.h(33): error C2143: syntax error : missing ';' before '}'
C:\Program Files\Intel\plsuite\include\ipl.h(778): warning C4819: The file contains a character that cannot be represented in the current code page (949). Save the file in Unicode format to prevent data loss
C:\Program Files\Intel\plsuite\examples\Tutorial.IPL\IPLROOMS\COOKROOM\macros.inc(21): warning C4005: '_ASSERTE' : macro redefinition
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdbg.h(213) : see previous definition of '_ASSERTE'
Build FAILED.
Time Elapsed 00:00:37.30
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have found some reference code as following.as you can see, the following code use Image m_image.
How could it use like that?
// NtMagickView.h : interface of the CNtMagickView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_NTMAGICKVIEW_H__8A45000C_6176_11D4_AC4F_400070168026__INCLUDED_)
#define AFX_NTMAGICKVIEW_H__8A45000C_6176_11D4_AC4F_400070168026__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define NTMAGICK_DEFEXT "*.JPG;*.JPEG"
#define NTMAGICK_ALL "All Files (*.*)|*.*|"
#define NTMAGICK_BMP "Bitmaps (*.BMP;*.RLE)|*.BMP;*.RLE|"
#define NTMAGICK_GIF "GIF (*.GIF)|*.GIF|"
#define NTMAGICK_TIF "TIF (*.TIF;*.TIFF)|*.TIF;*.TIFF|"
#define NTMAGICK_JPEG "JPEG (*.JPG;*.JPEG)|*.JPG;*.JPEG|"
#define NTMAGICK_ICON "Icons (*.ICO)|*.ICO|"
class CNtMagickView : public CView
{
protected: // create from serialization only
CNtMagickView();
DECLARE_DYNCREATE(CNtMagickView)
// Attributes
public:
CString m_szFile;
Image * m_pImage;
CNtMagickDoc* GetDocument();
void DoDisplayError(CString szFunction, CString szCause);
void DoDisplayImage();
BOOL DoReadImage();
CSize Scale(CSize sizeSrc, CSize sizeTgt);
float ScaleFactor(BOOL bAllowZoom, CSize sizeSrc, CSize sizeTgt);
void UpdateUI(CCmdUI* pCmdUI);
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNtMagickView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CNtMagickView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CNtMagickView)
afx_msg void OnFileOpen();
afx_msg void OnImageFlipHorizontal();
afx_msg void OnUpdateImageFlipHorizontal(CCmdUI* pCmdUI);
afx_msg void OnImageFlipVertical();
afx_msg void OnUpdateImageFlipVertical(CCmdUI* pCmdUI);
afx_msg void OnImageRotate180();
afx_msg void OnUpdateImageRotate180(CCmdUI* pCmdUI);
afx_msg void OnImageRotate90();
afx_msg void OnUpdateImageRotate90(CCmdUI* pCmdUI);
afx_msg void OnImageRotate90ccw();
afx_msg void OnUpdateImageRotate90ccw(CCmdUI* pCmdUI);
afx_msg void OnFileClear();
afx_msg void OnUpdateFileClear(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in NtMagickView.cpp
inline CNtMagickDoc* CNtMagickView::GetDocument()
{ return (CNtMagickDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_NTMAGICKVIEW_H__8A45000C_6176_11D4_AC4F_400070168026__INCLUDED_)
Update 2
I have edited like as following but it is not called ever. is this right? when do it call this function?
void CTestview::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
m_pimage.read(fileposition);
}
You should not draw directly on the TestView's DC, but instead create a compatible memory DC, do all the drawing on there, then copy the contents of the memory DC to the view's DC. Because it is way faster!
To do it, you can change the functions to call from OnDraw to receive a parameter that is the memory DC, and forbid yourself to do GetDC() everywhere except on creating the memory DC and copying back its contents to the view DC.
Your OnDraw should look like
void CTestview::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
CDC draw_dc;
CBitmap draw_bitmap;
CBitmap* old_bitmap;
CRect draw_area;
pDC->GetClipBox(draw_area);
draw_dc.CreateCompatibleDC(pDC);
draw_bitmap.CreateCompatibleBitmap(pDC, draw_area.Width(), draw_area.Height());
old_bitmap = (CBitmap*)draw_dc.SelectObject(&draw_bitmap);
OnPrepareDC(&draw_dc, NULL);
pDC->LPtoDP(draw_area);
draw_dc.OffsetViewportOrg(-draw_area.left, -draw_area.top);
pDC->DPtoLP(draw_area);
draw_dc.IntersectClipRect(draw_area);
DoDisplayImage(&draw_dc);
pDC->BitBlt(draw_area.left, draw_area.top, draw_area.Width(), draw_area.Height(), &draw_dc, 0, 0, SRCCOPY);
draw_dc.SelectObject(old_bitmap);
DeleteObject(draw_bitmap);
DeleteDC(draw_dc);
}
You may have noticed that there is some clipping code; it makes drawing faster because it will not draw on places where it doesn't need to do it. The most important parts are the draw_dc.CreateCompatibleDC(pDC); which creates the memory DC; and the pDC->BitBlt( ... , SRCCOPY); which copies the contents from memory to the view.
Side note: I removed the lines you had above because they seemed useless to me.
Now your DoDisplayImage function should be:
void CTestview::DoDisplayImage(CDC* pDC)
{
CPoint pt;
CRect rectClient;
GetClientRect(rectClient);
int ii;
ii=slider_val;
(void) MagickCore::SetClientPath(fileposition);
InitializeMagick(fileposition);
Image m_Image;
Image m_blurgray;
int _imageHeight;
try {
//C:\work\mfc_test5\mfc_test5
m_Image.read(fileposition);
}
catch(Exception)
{
return ;
}
char str_x[10];
char str_y[10];
if (pDC != NULL)
{
m_blurgray.gaussianBlur(20,2); //blur
int nImageY;
int nImageX;
CSize sizeScaled;
// Clear the background
pDC->FillSolidRect(rectClient,pDC->GetBkColor());
pt = rectClient.TopLeft();
nImageX= m_Image.columns() ;
//nImageY = m_Image.rows();
CPoint aa;
aa = rectClient.Size();
// Extract the pixels from Magick++ image object
PixelPacket *pPixels = m_Image.getPixels(0,0,m_Image.columns(),m_Image.rows());
// Set up the Windows bitmap header
BITMAPINFOHEADER bmi;
bmi.biSize = sizeof(BITMAPINFOHEADER);
bmi.biWidth =m_Image.columns();
bmi.biHeight = (-1)*m_Image.rows();
bmi.biPlanes = 1;
bmi.biBitCount = 32;
bmi.biCompression = BI_RGB;
bmi.biSizeImage = 0;
bmi.biXPelsPerMeter = 0;
bmi.biYPelsPerMeter = 0;
bmi.biClrUsed = 0;
bmi.biClrImportant = 0;
// Blast it to the device context
SetStretchBltMode(pDC->m_hDC,COLORONCOLOR);
StretchDIBits(pDC->m_hDC,
0,
0,
m_Image.columns(),
m_Image.rows(),
0,
0,
m_Image.columns(),
m_Image.rows(),
pPixels,
(BITMAPINFO *)&bmi,
DIB_RGB_COLORS,
SRCCOPY);
//UpdateData(FALSE);
}
}
Side note: You seem to also have useless code here, namely the parts with aa and ii variables.
Related
I opened and upgraded a VC++6.0 project to VC2015. It compiles to this latest error, I've read through the posts pertaining this topic, didn't find a working solution.
This involves the following class: MemDC
#if !defined(AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_)
#define AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_
#pragma once
// MemDC.h : header file
class CMemDC : public CDC
{
public:
CMemDC(CDC* pDC);
~CMemDC();
CMemDC* operator->() {return this;}
operator CMemDC*() {return this;}
private:
CBitmap m_bitmap;
CBitmap* m_pOldBitmap;
CDC* m_pDC;
CRect m_rect;
BOOL m_bMemDC;
};
#endif
// MemDC.cpp : implementation of MemDC class
// This class implements a memory Device Context
#include "stdafx.h"
#include "MemDC.h"
CMemDC::CMemDC(CDC* pDC) : CDC()
{
ASSERT(pDC != NULL);
m_pDC = pDC;
m_pOldBitmap = NULL;
#ifndef WCE_NO_PRINTING
m_bMemDC = !pDC->IsPrinting();
#else
m_bMemDC = FALSE;
#endif
if (m_bMemDC) // Create a Memory DC
{
pDC->GetClipBox(&m_rect);
CreateCompatibleDC(pDC);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_bitmap);
#ifndef _WIN32_WCE
SetWindowOrg(m_rect.left, m_rect.top);
#endif
}
else // Make a copy of the relevent parts of the current DC for printing
{
#ifndef WCE_NO_PRINTING
m_bPrinting = pDC->m_bPrinting;
#endif
m_hDC = pDC->m_hDC;
m_hAttribDC = pDC->m_hAttribDC;
}
}
// Destructor copies the contents of the mem DC to the original DC
CMemDC::~CMemDC()
{
if (m_bMemDC)
{
// Copy the offscreen bitmap onto the screen.
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);
//Swap back the original bitmap.
SelectObject(m_pOldBitmap);
}
else {
// All we need to do is replace the DC with an illegal value,
// this keeps us from accidently deleting the handles associated with
// the CDC that was passed to the constructor.
m_hDC = m_hAttribDC = NULL;
}
}
This class is not referenced by any other classes in the project, but when compiling it give the following errors:
LNK2005 "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC##UAE#XZ) already defined in MemDC.obj myProj C:\dev\myproj\nafxcwd.lib(afxglobals.obj)
I couldn't find the nafxcwd.lib in my project folder either.
I don't really see where the problem is.
Hy i have build with MFC a interface dialog Box Simply with one radio button.
like this:
CONTROL " Encode",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | BS_RIGHT | BS_NOTIFY,35,20,41,10,WS_EX_TRANSPARENT in the RC file
i have create la class and with m_radio_0.SubclassDlgItem(IDC_RADIO1, this);.
I have writen my DrawItem. So I have a problem when i click on, i see the checkbow change but never stay check. And when i want getcheck() said 0.
My code is that on:
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CString strText;
int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top;
CRect rect(lpDrawItemStruct->rcItem.left + 2,
lpDrawItemStruct->rcItem.top + 2,
lpDrawItemStruct->rcItem.left + h - 3,
lpDrawItemStruct->rcItem.top + h - 3);
// just draws focus rectangle when listbox is empty
int selChange = lpDrawItemStruct->itemAction & ODA_SELECT;
int focusChange = lpDrawItemStruct->itemAction & ODA_FOCUS;
int drawEntire = lpDrawItemStruct->itemAction & ODA_DRAWENTIRE;
BOOL sel = lpDrawItemStruct->itemState & ODS_SELECTED;
// Draws background rectangle, color depends on transparency
pDC->FillSolidRect(&lpDrawItemStruct->rcItem,::GetSysColor((GetExStyle()&WS_EX_TRANSPARENT) ? COLOR_BTNFACE : COLOR_WINDOW));
if (lpDrawItemStruct->itemState & ODS_SELECTED) //
{
pDC->DrawFrameControl( rect, DFC_BUTTON, DFCS_CHECKED | DFCS_BUTTONRADIO);
CButton::SetCheck(TRUE);
}
else
{
pDC->DrawFrameControl( rect, DFC_BUTTON, DFCS_BUTTONRADIO);
CButton::SetCheck(FALSE);
}
// Draws item text
::SetTextColor(lpDrawItemStruct->hDC, m_crTextColor);
// DEFAULT ==> BS_RIGHT
UINT Option = DT_RIGHT;
if ((uStyle & BS_RIGHT) == BS_RIGHT) Option = DT_RIGHT;
if ((uStyle & BS_LEFT) == BS_LEFT) Option = DT_LEFT;
if ((uStyle & BS_CENTER) == BS_CENTER) Option = DT_CENTER;
GetWindowText(strText);
::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(),
&lpDrawItemStruct->rcItem, Option);
::SetBkColor(lpDrawItemStruct->hDC, m_crBkColor);
>
Do have a solution for me.
Thanks
Just my response :
#include the header:
<<
// This file was created on March 28th 2001. By Robert Brault
//
//
#if !defined(AFX_COLORBUTTON_H__714C19E7_EA25_42DF_928A_51AC901B813D__INCLUDED_)
#define AFX_COLORBUTTON_H__714C19E7_EA25_42DF_928A_51AC901B813D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ColorRadio.h : header file
//
#include "color.h"
/////////////////////////////////////////////////////////////////////////////
// ColorRadio window
class CColorRadioButton : public CButton
{
// Construction
public:
void SetTextColor(COLORREF crColor); // This Function is to set the Color for the Text.
void SetBkColor(COLORREF crColor); // This Function is to set the BackGround Color for the Text.
void SetCheck(UINT Value);
UINT GetCheck();
CColorRadioButton();
void PreSubclassWindow();
virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
DWORD Mystyle;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorRadio)
//}}AFX_VIRTUAL
virtual ~CColorRadioButton();
// Generated message map functions
protected:
//{{AFX_MSG(CColorStatic)
CBrush m_brBkgnd; // Holds Brush Color for the Static Text
COLORREF m_crBkColor; // Holds the Background Color for the Text
COLORREF m_crTextColor; // Holds the Color for the Text
BOOL m_rb1Checked;
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
UINT Value_Check;
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COLORSTATIC_H__614C19E7_EA25_42DF_928A_51AC901B813D__INCLUDED_)
>>
and the class
<<
// This file was created on March 28th 2001 by Robert Brault.
// I created this Class to be able change the Color of your Static Text.
// This is Derived from CButton.
//
// There are three functions available Currently:
// SetBkColor(COLORREF crColor)
// SetTextColor(COLORREF crColor)
//
// How To Use:
// Add three files to your project
// CColorRadioButton.cpp, CColorRadioButton.h and Color.h
// Color.h has (#define)'s for different colors (add any color you desire).
//
// Add #include "CColorRadioButton.h" to your Dialogs Header file.
// Declare an instance of CColorRadioButton for each button being modified.
// Ex. CColorRadioButton m_radio;
//
// In your OnInitDialog() add a SubclassDlgItem for each CColorStatic member variable.
// Ex. m_radio.SubclassDlgItem(IDC_ST_TEXT, this);
// In this same function initialize your color for each piece of text unless you want the default.
// CColorRadioButton.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "ColorRadioButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorRadioButton
CColorRadioButton::CColorRadioButton()
{
m_crBkColor = ::GetSysColor(COLOR_3DFACE); // Initializing the Background Color to the system face color.
m_crTextColor = BLACK; // Initializing the text to Black
m_brBkgnd.CreateSolidBrush(m_crBkColor); // Create the Brush Color for the Background.
}
CColorRadioButton::~CColorRadioButton()
{
}
BEGIN_MESSAGE_MAP(CColorRadioButton, CStatic)
//{{AFX_MSG_MAP(CColorStatic)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorRadioButton message handlers
HBRUSH CColorRadioButton::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH hbr;
hbr = (HBRUSH)m_brBkgnd; // Passing a Handle to the Brush
pDC->SetBkColor(m_crBkColor); // Setting the Color of the Text Background to the one passed by the Dialog
pDC->SetTextColor(m_crTextColor); // Setting the Text Color to the one Passed by the Dialog
if (nCtlColor) nCtlColor += 0;
return hbr;
}
void CColorRadioButton::SetBkColor(COLORREF crColor)
{
m_crBkColor = crColor; // Passing the value passed by the dialog to the member varaible for Backgound Color
m_brBkgnd.DeleteObject(); // Deleting any Previous Brush Colors if any existed.
m_brBkgnd.CreateSolidBrush(crColor); // Creating the Brush Color For the Static Text Background
RedrawWindow();
}
void CColorRadioButton::SetTextColor(COLORREF crColor)
{
m_crTextColor = crColor;
RedrawWindow();
}
void CColorRadioButton::SetCheck(UINT Value)
{
m_rb1Checked = Value;
RedrawWindow();
}
UINT CColorRadioButton::GetCheck()
{
return (m_rb1Checked);
}
void CColorRadioButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
UINT uStyle = Mystyle;
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CString strText;
UINT Option = DT_RIGHT;
CRect rcBullet(&lpDrawItemStruct->rcItem);
rcBullet.right = rcBullet.left + rcBullet.Height();
GetWindowText(strText);
pDC->FillSolidRect(&lpDrawItemStruct->rcItem,::GetSysColor((GetExStyle()&WS_EX_TRANSPARENT) ? COLOR_BTNFACE : COLOR_WINDOW));
UINT nState = DFCS_BUTTONRADIO|DFCS_ADJUSTRECT;
if (m_rb1Checked) nState |= DFCS_CHECKED;
pDC->DrawFrameControl(rcBullet, DFC_BUTTON, nState);
if ((uStyle & BS_RIGHT) == BS_RIGHT) Option = DT_RIGHT;
if ((uStyle & BS_LEFT) == BS_LEFT) Option = DT_LEFT;
if ((uStyle & BS_CENTER) == BS_CENTER) Option = DT_CENTER;
::SetTextColor(lpDrawItemStruct->hDC, m_crTextColor);
::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), &lpDrawItemStruct->rcItem, Option);
}
void CColorRadioButton::PreSubclassWindow()
{
CButton::PreSubclassWindow();
Mystyle =GetButtonStyle()| BS_OWNERDRAW;
SetButtonStyle(Mystyle);
}
in your's dlg header do
<<
CColorRadioButton m_radio_0;
>>
and then you can call it
<<`enter code here`
m_radio_0.SubclassDlgItem(IDC_RADIO1, this);
m_radio_0.SetTextColor(GREEN);
m_radio_0.SetCheck(BST_CHECKED);
>
It's Simply in fact
I am Getting this error "Error 2 error LNK2005: "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC##UAE#XZ) already defined in SkinHeaderCtrl.obj C:\Users\anthonyd\Desktop\ASPX\STP\nafxcwd.lib(afxglobals.obj) STP
"
I have read through many similar questions but can not find what fits. Could someone help please?
// SkinHeaderCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "STP.h"
#include "SkinHeaderCtrl.h"
#include "memdc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define BACKGROUND RGB(218,218,218)// was 218,218,218
#define HEIGHT 16
/////////////////////////////////////////////////////////////////////////////
// CSkinHeaderCtrl
CSkinHeaderCtrl::CSkinHeaderCtrl()
{
}
CSkinHeaderCtrl::~CSkinHeaderCtrl()
{
}
BEGIN_MESSAGE_MAP(CSkinHeaderCtrl, CHeaderCtrl)
//{{AFX_MSG_MAP(CSkinHeaderCtrl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSkinHeaderCtrl message handlers
void CSkinHeaderCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
}
void CSkinHeaderCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect, rectItem, clientRect;
GetClientRect(&rect);
GetClientRect(&clientRect);
CMemDC memDC(&dc, rect);
CDC bitmapDC;
bitmapDC.CreateCompatibleDC(&dc);
// memDC.FillSolidRect(&rect, RGB(76,85,118));
memDC.FillSolidRect(&rect, BACKGROUND);
CBitmap bitmapSpan;
bitmapSpan.LoadBitmap(IDB_COLUMNHEADER_SPAN);
CBitmap* pOldBitmapSpan = bitmapDC.SelectObject(&bitmapSpan);
// memDC.StretchBlt(rect.left+2, 0, rect.Width(), 12, &bitmapDC, 0, 0, 1, 12, SRCCOPY);
memDC.StretchBlt(rect.left+2, 0, rect.Width(), HEIGHT, &bitmapDC, 0, 0, 1, 12, SRCCOPY);
bitmapDC.SelectObject(pOldBitmapSpan);
bitmapSpan.DeleteObject();
int nItems = GetItemCount();
CBitmap bitmap;
CBitmap bitmap2;
CBitmap bitmap3;
Here is the skinheaderctrl.h
#if !defined(AFX_SKINHEADERCTRL_H__8B0847B1_B4E6_4372_A62D_038582FFEA5C__INCLUDED_)
#define AFX_SKINHEADERCTRL_H__8B0847B1_B4E6_4372_A62D_038582FFEA5C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SkinHeaderCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSkinHeaderCtrl window
class CSkinHeaderCtrl : public CHeaderCtrl
{
// Construction
public:
CSkinHeaderCtrl();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSkinHeaderCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual ~CSkinHeaderCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CSkinHeaderCtrl)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SKINHEADERCTRL_H__8B0847B1_B4E6_4372_A62D_038582FFEA5C__INCLUDED_)
Update
On the skinheaderctrl.cpp I have a includes #include "memdc.h" do I want to update this to CMemDC?
CMemDC is an internal helper class in MFC (see Internal Classes). You've apparently defined your own CMemDC class, with the result that the linker is seeing two destructors with the same name. You'll either have to rename your class to something else or put it in a namespace to avoid the conflict.
I am not able to access the private member variables from member function CAboutDlg::OnLButtonDown.
When I attempted to assign a new value to ellipseColor i get the undeclared identifier error. When I try to access it through its class CCSIT861a3VasilkovskiyDlg::ellipseColorthe compiler says that it is inaccessible.
What have I missed, and how can I access/modify these variable?
Header File:
#pragma once
// CCSIT861a3VasilkovskiyDlg dialog
class CCSIT861a3VasilkovskiyDlg : public CDialogEx
{
// Construction
public:
CCSIT861a3VasilkovskiyDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_CSIT861A3VASILKOVSKIY_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
private:
COLORREF ellipseColor;
COLORREF centerRectColor;
COLORREF rightRectColor;
CRect centerRect;
CRect rightRect;
CSize ellipse;
bool mouseCaptured;
};
Implementation File:
#include "stdafx.h"
#include "CSIT861a3 Vasilkovskiy.h"
#include "CSIT861a3 VasilkovskiyDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
// CCSIT861a3VasilkovskiyDlg dialog
CCSIT861a3VasilkovskiyDlg::CCSIT861a3VasilkovskiyDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CCSIT861a3VasilkovskiyDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
ellipseColor = RGB(255, 0, 0);
centerRectColor = RGB(0, 0, 0);
rightRectColor = RGB(255, 0, 0);
centerRect.left = 40;
centerRect.top = 20;
centerRect.right = 55;
centerRect.bottom = 80;
rightRect.left = 75;
rightRect.top = 35;
rightRect.right = 90;
rightRect.bottom = 50;
ellipse.cx = 10;
ellipse.cy = 10;
mouseCaptured = false;
}
void CCSIT861a3VasilkovskiyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CCSIT861a3VasilkovskiyDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
// CCSIT861a3VasilkovskiyDlg message handlers
BOOL CCSIT861a3VasilkovskiyDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CCSIT861a3VasilkovskiyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCSIT861a3VasilkovskiyDlg::OnPaint()
{
//Create pen and pointer to the old pen
CPen blackPen;
blackPen.CreatePen(PS_SOLID, 1, RGB (0, 0, 0));
//Create a bursh
CBrush blackBrush(centerRectColor);
CBrush redBrush(rightRectColor);
CBrush hatchRedBrush(HS_CROSS, ellipseColor);
//Set up object for painting
CPaintDC dc (this);
CRect rect;
GetClientRect (&rect);
dc.SetMapMode (MM_ANISOTROPIC);
dc.SetWindowExt (100, 100);
dc.SetViewportExt (rect.Width (), rect.Height ());
//select pen
dc.SelectObject(&blackPen);
//Rectangle red interior color
dc.SelectObject(&redBrush);
dc.Rectangle(rightRect); //(75, 35, 90, 50);
//Rectangel black interior
dc.SelectObject(&blackBrush);//Select Brush
dc.Rectangle( centerRect);//(40, 20, 55, 80);
//Ellipse
dc.SelectObject(&hatchRedBrush);//Select Brush
dc.Ellipse(ellipse.cx, ellipse.cy, (ellipse.cx) + 10, (ellipse.cy) + 10);//10, 10, 20, 20);
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCSIT861a3VasilkovskiyDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//SetCapture();
CClientDC dc(this);
CRect rect;
GetClientRect(&rect);
dc.SetMapMode(MM_ANISOTROPIC);
dc.SetWindowExt(100, 100);
dc.SetViewportExt(rect.Width(), rect.Height());
CRect rectEllipse(10, 10, 20, 20);
CDialogEx::OnLButtonDown(nFlags, point);
}
void CAboutDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ReleaseCapture ();
CDialogEx::OnLButtonUp(nFlags, point);
}
void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialogEx::OnMouseMove(nFlags, point);
}
Your OnLButtonDown() is a member function of CAboutDlg, but you are trying to access a private, non-static data member of CCSIT861a3VasilkovskiyDlg, which is a different class.
You probably meant to have functions OnLButtonDown(), OnLButtonUp(), and OnMouseMove() as member functions of CCSIT861a3VasilkovskiyDlg, and not as member functions of CAboutDlg.
in my application, i currently have 2 document types. The one i will be focusing on, will be the second. My application is a 3d engine editor, which is build in MFC MDI. The first document is the render window, which works perfect, because it's simple to extract the hwnd of it, and then send it to my graphics class. But my second window, which is scripting, is supposed (for now) just to have a rich edit. But for some reason, it doesn't render(actually it does, but only once :/).
CEditorScriptView.h
#pragma once
#include "CEditorDoc.h"
class CCEditorCntrItem;
class CCEditorScriptView : public CView
{
public: // create from serialization only
CCEditorScriptView();
DECLARE_DYNCREATE(CCEditorScriptView)
// Attributes
public:
CCEditorDoc* GetDocument() const;
static CCEditorScriptView * GetView();
// m_pSelection holds the selection to the current CCEditorCntrItem.
// For many applications, such a member variable isn't adequate to
// represent a selection, such as a multiple selection or a selection
// of objects that are not CCEditorCntrItem objects. This selection
// mechanism is provided just to help you get started
// TODO: replace this selection mechanism with one appropriate to your app
CCEditorCntrItem* m_pSelection;
CRichEditCtrl* m_rEdit;
int TYPE;
// 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 IsSelected(const CObject* pDocItem) const;// Container support
// Implementation
public:
virtual ~CCEditorScriptView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
afx_msg void OnDestroy();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnInsertObject();
afx_msg void OnCancelEditCntr();
afx_msg void OnFilePrint();
afx_msg void OnFilePrintPreview();
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in CEditorView.cpp
inline CCEditorDoc* CCEditorScriptView::GetDocument() const
{ return reinterpret_cast<CCEditorDoc*>(m_pDocument); }
#endif
CEditorScriptView.cpp:
#include "stdafx.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "CEditor.h"
#endif
#include "CEditorDoc.h"
#include "CntrItem.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CCEditorView
#pragma region CCEditorScriptView
IMPLEMENT_DYNCREATE(CCEditorScriptView, CView)
BEGIN_MESSAGE_MAP(CCEditorScriptView, CView)
ON_WM_DESTROY()
ON_WM_SETFOCUS()
ON_WM_SIZE()
ON_COMMAND(ID_OLE_INSERT_NEW, &CCEditorScriptView::OnInsertObject)
ON_COMMAND(ID_CANCEL_EDIT_CNTR, &CCEditorScriptView::OnCancelEditCntr)
ON_COMMAND(ID_FILE_PRINT, &CCEditorScriptView::OnFilePrint)
ON_WM_CONTEXTMENU()
ON_WM_RBUTTONUP()
END_MESSAGE_MAP()
// CCEditorView construction/destruction
CCEditorScriptView::CCEditorScriptView()
{
EnableActiveAccessibility();
m_pSelection = NULL;
// TODO: add construction code here
m_rEdit->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE,
CRect(10,10,500,500), this, 1);
//m_rEdit->SetFocus();
TYPE = ID_CEDITOR_VIEW_SCRIPT;
}
CCEditorScriptView::~CCEditorScriptView()
{
}
BOOL CCEditorScriptView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CCEditorView drawing
void CCEditorScriptView::OnDraw(CDC* pDC)
{
if (!pDC)
return;
CCEditorDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
// TODO: also draw all OLE items in the document
// Draw the selection at an arbitrary position. This code should be
// removed once your real drawing code is implemented. This position
// corresponds exactly to the rectangle returned by CCEditorCntrItem,
// to give the effect of in-place editing.
// TODO: remove this code when final draw code is complete.
m_rEdit->UpdateWindow();
if (m_pSelection != NULL)
{
CSize size;
CRect rect(10, 10, 210, 210);
if (m_pSelection->GetExtent(&size, m_pSelection->m_nDrawAspect))
{
pDC->HIMETRICtoLP(&size);
rect.right = size.cx + 10;
rect.bottom = size.cy + 10;
}
m_pSelection->Draw(pDC, rect);
}
}
// MDI view implementation file
CCEditorScriptView * CCEditorScriptView::GetView()
{
CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();
if ( !pChild )
return NULL;
CView * pView = pChild->GetActiveView();
if ( !pView )
return NULL;
// Fail if view is of wrong kind
/*if ( ! pView->IsKindOf( RUNTIME_CLASS(CCEditorRenderView) ) )
return NULL;*/
return (CCEditorScriptView *) pView;
}
void CCEditorScriptView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: remove this code when final selection model code is written
m_pSelection = NULL; // initialize selection
}
void CCEditorScriptView::OnDestroy()
{
// Deactivate the item on destruction; this is important
// when a splitter view is being used
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
{
pActiveItem->Deactivate();
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
CView::OnDestroy();
}
// OLE Client support and commands
BOOL CCEditorScriptView::IsSelected(const CObject* pDocItem) const
{
// The implementation below is adequate if your selection consists of
// only CCEditorCntrItem objects. To handle different selection
// mechanisms, the implementation here should be replaced
// TODO: implement this function that tests for a selected OLE client item
return pDocItem == m_pSelection;
}
void CCEditorScriptView::OnInsertObject()
{
// Invoke the standard Insert Object dialog box to obtain information
// for new CCEditorCntrItem object
COleInsertDialog dlg;
if (dlg.DoModal() != IDOK)
return;
BeginWaitCursor();
CCEditorCntrItem* pItem = NULL;
TRY
{
// Create new item connected to this document
CCEditorDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pItem = new CCEditorCntrItem(pDoc);
ASSERT_VALID(pItem);
// Initialize the item from the dialog data
if (!dlg.CreateItem(pItem))
AfxThrowMemoryException(); // any exception will do
ASSERT_VALID(pItem);
if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)
pItem->DoVerb(OLEIVERB_SHOW, this);
ASSERT_VALID(pItem);
// As an arbitrary user interface design, this sets the selection
// to the last item inserted
// TODO: reimplement selection as appropriate for your application
m_pSelection = pItem; // set selection to last inserted item
pDoc->UpdateAllViews(NULL);
}
CATCH(CException, e)
{
if (pItem != NULL)
{
ASSERT_VALID(pItem);
pItem->Delete();
}
AfxMessageBox(IDP_FAILED_TO_CREATE);
}
END_CATCH
EndWaitCursor();
}
// The following command handler provides the standard keyboard
// user interface to cancel an in-place editing session. Here,
// the container (not the server) causes the deactivation
void CCEditorScriptView::OnCancelEditCntr()
{
// Close any in-place active item on this view.
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL)
{
pActiveItem->Close();
}
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
// Special handling of OnSetFocus and OnSize are required for a container
// when an object is being edited in-place
void CCEditorScriptView::OnSetFocus(CWnd* pOldWnd)
{
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL &&
pActiveItem->GetItemState() == COleClientItem::activeUIState)
{
// need to set focus to this item if it is in the same view
CWnd* pWnd = pActiveItem->GetInPlaceWindow();
if (pWnd != NULL)
{
pWnd->SetFocus(); // don't call the base class
return;
}
}
CView::OnSetFocus(pOldWnd);
}
void CCEditorScriptView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL)
pActiveItem->SetItemRects();
}
void CCEditorScriptView::OnFilePrint()
{
//By default, we ask the Active document to print itself
//using IOleCommandTarget. If you don't want this behavior
//remove the call to COleDocObjectItem::DoDefaultPrinting.
//If the call fails for some reason, we will try printing
//the docobject using the IPrint interface.
CPrintInfo printInfo;
ASSERT(printInfo.m_pPD != NULL);
if (S_OK == COleDocObjectItem::DoDefaultPrinting(this, &printInfo))
return;
CView::OnFilePrint();
}
void CCEditorScriptView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
ClientToScreen(&point);
OnContextMenu(this, point);
}
void CCEditorScriptView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}
// CCEditorView diagnostics
#ifdef _DEBUG
void CCEditorScriptView::AssertValid() const
{
CView::AssertValid();
}
void CCEditorScriptView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCEditorDoc* CCEditorScriptView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCEditorDoc)));
return (CCEditorDoc*)m_pDocument;
}
#pragma endregion
#endif //_DEBUG
// CCEditorView message handlers
And this is currently what it outputs:
Now is seems ok, but it only renders it once, meaning if I would click on it(richEdit) nothing would happen, or if I tried to type in the richEdit, nothing would happen as well. So I'm wondering, why? Why doesn't it continue rendering, or updating the view?
Thank You
PS. If you wan't me to post anything, like code, please comment.
So, it seems that I've solved my problem, here's the solution:
I looked at the console and noticed that the window had failed to create. And i came to the solution that the m_rEdit was the fault(by testing). So i figured out that i had to initialize the pointer in the constructor, and use the m_rEdit->Create in the OnInitialUpdate(). And that fixed it.
Anyways, thank you for anyone who tried to solve this mystery.