Click here to Skip to main content
15,912,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to display Text in Chinese? Pin
Software200722-Oct-09 10:19
Software200722-Oct-09 10:19 
GeneralRe: How to display Text in Chinese? Pin
Nemanja Trifunovic22-Oct-09 10:50
Nemanja Trifunovic22-Oct-09 10:50 
AnswerRe: How to display Text in Chinese? [modified] Pin
Michael Schubert22-Oct-09 11:20
Michael Schubert22-Oct-09 11:20 
QuestionSolving a repaint problem in VS2005 [modified] Pin
SimplCodr22-Oct-09 6:24
SimplCodr22-Oct-09 6:24 
QuestionRe: Solving a repaint problem in VS2005 Pin
CPallini22-Oct-09 8:19
mveCPallini22-Oct-09 8:19 
AnswerRe: Solving a repaint problem in VS2005 Pin
SimplCodr22-Oct-09 10:13
SimplCodr22-Oct-09 10:13 
GeneralRe: Solving a repaint problem in VS2005 Pin
CPallini22-Oct-09 10:53
mveCPallini22-Oct-09 10:53 
GeneralRe: Solving a repaint problem in VS2005 Pin
SimplCodr22-Oct-09 10:54
SimplCodr22-Oct-09 10:54 
I hope this clarifies a bit, if not I am too stupid to ask a question so I'll give up.

The following code works great to redraw (i think that's right) the screen anytime it is resized, minimized or covered by another window as long as the application uses the method below for creating a window.

The problem I am having is when I add the CClientDC dc(this); to a wizard generated Single or multiple document MFC application my application crashes at run-time with a debug assertion error.

How can achieve the same results in a single or multiple document MFC application created in VS2005 using the wizard?

CMainWin::CMainWin()
{
	RECT r;
	r.top = 200;
	r.left = 300;
	r.bottom = 500;
	r.right = 700;

	Create(NULL, "COM View", WS_OVERLAPPEDWINDOW, r,
			NULL, "TextMenu");

	// Load accelerator table
	if(!LoadAccelTable("TextMenu"))
		MessageBox("Cannot load accelerator table.", "Error");



	
	// Setup virtual screen for storing the view
	m_X = m_Y = 0;

	maxX = GetSystemMetrics(SM_CXSCREEN);
	maxY = GetSystemMetrics(SM_CYSCREEN);

	CClientDC dc(this);

	m_memDC.CreateCompatibleDC(&dc);
	m_bmp.CreateCompatibleBitmap(&dc, maxX, maxY - 10);
	m_memDC.SelectObject(&m_bmp);

	m_bkbrush.CreateStockObject(WHITE_BRUSH);
	m_memDC.SelectObject(&m_bkbrush);

	m_memDC.PatBlt(0, 0, maxX, maxY, PATCOPY);

	m_AnsiVarFont.CreateStockObject(ANSI_VAR_FONT);
	m_SystemFont.CreateStockObject(SYSTEM_FONT);
}

afx_msg void CMainWin::OnPaint()
{
	CPaintDC dc(this);

	dc.BitBlt(0, 0, maxX, maxY, &m_memDC, 0, 0, SRCCOPY);
}

void CMainWin::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	strcpy_s(str, "Hello World");
	m_memDC.TextOutA(point.x, point.y, str, strlen(str));
	InvalidateRect(NULL);
	OnPaint();
	CFrameWnd::OnLButtonDblClk(nFlags, point);
}

Header File Stuff

class CMainWin : public CFrameWnd
{
public:

	int m_X, m_Y;
	char m_str[255];
	DCB dcb;
	CDC m_memDC;
	CBitmap m_bmp;
	CBrush m_bkbrush;
	CFont m_SystemFont, m_AnsiVarFont;
	
	HANDLE Ser1;

	CMainWin();
	
	afx_msg void OnPaint();
	
	afx_msg void OnExit();

	DECLARE_MESSAGE_MAP()
	
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
public:
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
private:
	CToolBar m_wndToolBar;
	CStatusBar m_wndStatusBar;
};


I hope someone help, thanks again.
QuestionRe: Solving a repaint problem in VS2005 Pin
CPallini22-Oct-09 11:06
mveCPallini22-Oct-09 11:06 
AnswerRe: Solving a repaint problem in VS2005 Pin
SimplCodr22-Oct-09 11:25
SimplCodr22-Oct-09 11:25 
GeneralRe: Solving a repaint problem in VS2005 Pin
CPallini22-Oct-09 12:02
mveCPallini22-Oct-09 12:02 
GeneralRe: Solving a repaint problem in VS2005 Pin
SimplCodr22-Oct-09 12:20
SimplCodr22-Oct-09 12:20 
GeneralRe: Solving a repaint problem in VS2005 Pin
CPallini22-Oct-09 20:38
mveCPallini22-Oct-09 20:38 
QuestionRe: Solving a repaint problem in VS2005 Pin
SimplCodr23-Oct-09 3:51
SimplCodr23-Oct-09 3:51 
AnswerRe: Solving a repaint problem in VS2005 Pin
SimplCodr22-Oct-09 11:32
SimplCodr22-Oct-09 11:32 
GeneralRe: Solving a repaint problem in VS2005 Pin
theCPkid22-Oct-09 16:57
theCPkid22-Oct-09 16:57 
AnswerRe: Solving a repaint problem in VS2005 Pin
SimplCodr23-Oct-09 4:05
SimplCodr23-Oct-09 4:05 
GeneralRe: Solving a repaint problem in VS2005 Pin
theCPkid23-Oct-09 5:07
theCPkid23-Oct-09 5:07 
GeneralRe: Solving a repaint problem in VS2005 Pin
SimplCodr23-Oct-09 5:49
SimplCodr23-Oct-09 5:49 
GeneralRe: Solving a repaint problem in VS2005 Pin
CPallini23-Oct-09 5:41
mveCPallini23-Oct-09 5:41 
GeneralRe: Solving a repaint problem in VS2005 Pin
SimplCodr23-Oct-09 6:03
SimplCodr23-Oct-09 6:03 
QuestionRe: Solving a repaint problem in VS2005 Pin
SimplCodr23-Oct-09 8:21
SimplCodr23-Oct-09 8:21 
AnswerRe: Solving a repaint problem in VS2005 Pin
CPallini23-Oct-09 10:05
mveCPallini23-Oct-09 10:05 
GeneralRe: Solving a repaint problem in VS2005 Pin
SimplCodr23-Oct-09 10:29
SimplCodr23-Oct-09 10:29 
GeneralRe: Solving a repaint problem in VS2005 Pin
CPallini23-Oct-09 10:50
mveCPallini23-Oct-09 10:50 

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.