Hello! :)

I have a CMDIChildWnd (CStatusFrame) with a richedit on it. I am resizing the richedit when CStatusFrame is resized. Originally it was..

// Code from CStatusFrame PreCreateWindow:

cs.style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP;
cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 
                                   NULL, (HBRUSH) (COLOR_WINDOW), NULL);


// Function for resizing richedit:

void CStatusFrame::OnSize(UINT nType, int cx, int cy) {
	if (::IsWindow(m_RichEd.GetSafeHwnd())) {
		m_RichEd.MoveWindow(0, 1, cx - 1, cy - 21);
	}
	return;
}

Worked OK. No flickering when I drag to resize. Then I noticed a problem - when I maximized the window, the maximize, minimize and close buttons did not appear on the menu frame and the windows caption was not appended to the programs. So I read that I should change the Onsize to..

void CStatusFrame::OnSize(UINT nType, int cx, int cy) {
	if (::IsWindow(this->m_hWnd)) {
                // Insert evil flicker.
		CMDIChildWnd::OnSize(nType, cx, cy);
		m_RichEd.MoveWindow(0, 1, cx - 1, cy - 21);
	}
	return;
}

Now the menu/caption showed up properly, but the richedit is flickering loads when I resize it. I've tried some work arounds from different suggestions I've read (Invalidate, map OnEraseBkgnd + return false) but they either didn't work, or I used them incorrectly.

I'm wondering if either I can simulate the action of showing the menu/caption without calling CMDIChildWnd::OnSize, or else, what exactly is happening here to cause the new flickering and how might I fix it?

Thanks!

(And can I just add - these forums are incredibly nice looking :o )

I'm obviously not an expert on this but from playing around a bit, it seems like once CMDIChildWnd::OnSize is called, it's joining CStatusFrame in redrawing the window (using the x/y cx/cy the window had when it was called) and this under coat is causing the flickering. Does that make any sense or am I talking rubbish? :p

If I can provide any more information/code, please ask.

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.