Click here to Skip to main content
15,896,421 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: data structure and algoritm Pin
jschell11-Sep-15 11:12
jschell11-Sep-15 11:12 
Questionfreestanding Pin
Member 1194028910-Sep-15 6:16
Member 1194028910-Sep-15 6:16 
QuestionRe: freestanding Pin
Richard MacCutchan10-Sep-15 7:04
mveRichard MacCutchan10-Sep-15 7:04 
AnswerRe: freestanding Pin
Member 1194028910-Sep-15 16:05
Member 1194028910-Sep-15 16:05 
GeneralRe: freestanding Pin
Richard MacCutchan10-Sep-15 21:41
mveRichard MacCutchan10-Sep-15 21:41 
AnswerRe: freestanding Pin
David Crow11-Sep-15 2:15
David Crow11-Sep-15 2:15 
GeneralRe: freestanding Pin
Member 1194028911-Sep-15 11:57
Member 1194028911-Sep-15 11:57 
QuestionDraw and re-pos CStatic controls in CDockablePane Pin
Member 85340359-Sep-15 4:55
Member 85340359-Sep-15 4:55 
Hi all,

I have spend already many hours to find the reason of my current problem.

I have a CDockablePane, in which I am placing a lot of CStatic controls. The CStatic controls I am using to display bitmaps. A dockable pane is designed for resizing at any time. Therefore I try to recalculate the positions of each CStatic after OnSize is called.

With some CStatic controls it is running well. But when I am adding an additional control, I am getting strange problems: The pane is not repainted properly and OnPaint is recalled cyclically.

My code (partially):

Header:
class CPaneCtrlPLC : public CDockablePane
{
	DECLARE_DYNAMIC(CPaneCtrlPLC)

public:
	CPaneCtrlPLC();
	virtual ~CPaneCtrlPLC();

protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);

private:
	CStatic m_Ctrl_PLCLED[6];
	CStatic m_SwitchCtrl;
	CStatic m_Ctrl_test;


C-File:

int CPaneCtrlPLC::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDockablePane::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_ColorSieGreen = RGB(0, 153, 153);
	m_ColorSieWhite = RGB(251, 253, 253);
	m_ColorText = RGB(230, 228, 193);
	m_ColorBgnd = RGB(119, 117, 127);
	m_BrushSieGreen.CreateSolidBrush(m_ColorSieGreen);
	m_BrushBgnd.CreateSolidBrush(m_ColorBgnd);

	m_BitmapSWITCHSTOP.LoadBitmapW(IDB_SWITCH_STOP);
	m_bitmapLEDOFF.LoadBitmapW(IDB_LEDOFF);
	m_bitmapLEDRED.LoadBitmapW(IDB_LEDRED);
	m_bitmapLEDGREEN.LoadBitmapW(IDB_LEDGREEN);
	m_bitmapTest.LoadBitmapW(IDB_LEDGREEN);

	// TODO:  Add your specialized creation code here
	DWORD dwStyle = WS_CHILD | WS_VISIBLE | TVS_SHOWSELALWAYS | SS_BITMAP;
	m_SwitchCtrl.Create(NULL, dwStyle, CRect(0, 0,0,0),this);
	m_SwitchCtrl.SetBitmap(m_BitmapSWITCHSTOP);

	int iLed;
	for (iLed = 0; iLed < MaxNumPLCLeds; ++iLed)
	{
		DWORD dwStyle = WS_CHILD | WS_VISIBLE | TVS_SHOWSELALWAYS | SS_BITMAP;
		m_Ctrl_PLCLED[iLed].Create(NULL, dwStyle, CRect(xPosPLCLEDS,(yPosPLCLEDS + (26* iLed)), 0, 0), this);
		m_Ctrl_PLCLED[iLed].SetBitmap(m_bitmapLEDOFF);
	}

	{
		DWORD dwStyle = WS_CHILD | WS_VISIBLE | TVS_SHOWSELALWAYS | SS_BITMAP;
		m_Ctrl_test.Create(NULL, dwStyle, CRect(xPosPLCLEDS + (17 * iLed), yPosPAELEDS + 20, 0, 0), this);
		m_Ctrl_test.SetBitmap(m_bitmapTest);
	}
...


I was able to strip the OnPaint(0) function to a minumum to reprocude the problem.
If I comment out the re-positioning of the m_Ctrl_test, everything works fine, but with this statement I have the problems.

void CPaneCtrlPLC::OnPaint()
{

	LOGMSG(LOG_TEST, _T("Repaint"));

	CPaintDC dc(this); // device context for painting

	CRect rect;
	GetClientRect(&rect);

	//Manual BG repaint
	dc.FillRect(&rect, &m_BrushBgnd);


	m_SwitchCtrl.SetWindowPos(NULL, 10,10, 0, 0,
		SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOCOPYBITS);

	m_Ctrl_test.SetWindowPos(NULL, 10, 100, 0, 0,
		SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOCOPYBITS);

	return;
}


Any ideas, what could be wrong?
AnswerRe: Draw and re-pos CStatic controls in CDockablePane Pin
Member 853403510-Sep-15 0:50
Member 853403510-Sep-15 0:50 
QuestionCustomize filter control of CHeaderCtrl Pin
aks.9-Sep-15 4:50
aks.9-Sep-15 4:50 
AnswerRe: Customize filter control of CHeaderCtrl Pin
Richard MacCutchan9-Sep-15 23:30
mveRichard MacCutchan9-Sep-15 23:30 
GeneralRe: Customize filter control of CHeaderCtrl Pin
aks.15-Sep-15 20:55
aks.15-Sep-15 20:55 
GeneralRe: Customize filter control of CHeaderCtrl Pin
Richard MacCutchan15-Sep-15 21:22
mveRichard MacCutchan15-Sep-15 21:22 
GeneralRe: Customize filter control of CHeaderCtrl Pin
aks.16-Sep-15 1:45
aks.16-Sep-15 1:45 
GeneralRe: Customize filter control of CHeaderCtrl Pin
Richard MacCutchan16-Sep-15 2:13
mveRichard MacCutchan16-Sep-15 2:13 
GeneralRe: Customize filter control of CHeaderCtrl Pin
aks.17-Sep-15 22:08
aks.17-Sep-15 22:08 
QuestionRadio Buttons, Lots of them Pin
golfbird8-Sep-15 3:03
golfbird8-Sep-15 3:03 
AnswerRe: Radio Buttons, Lots of them Pin
Eddy Vluggen8-Sep-15 3:38
professionalEddy Vluggen8-Sep-15 3:38 
GeneralRe: Radio Buttons, Lots of them Pin
golfbird8-Sep-15 7:47
golfbird8-Sep-15 7:47 
AnswerRe: Radio Buttons, Lots of them Pin
Richard MacCutchan8-Sep-15 4:46
mveRichard MacCutchan8-Sep-15 4:46 
GeneralRe: Radio Buttons, Lots of them Pin
golfbird8-Sep-15 10:15
golfbird8-Sep-15 10:15 
GeneralRe: Radio Buttons, Lots of them Pin
jeron18-Sep-15 10:47
jeron18-Sep-15 10:47 
GeneralRe: Radio Buttons, Lots of them Pin
golfbird8-Sep-15 13:46
golfbird8-Sep-15 13:46 
AnswerRe: Radio Buttons, Lots of them Pin
Peter Leow8-Sep-15 4:56
professionalPeter Leow8-Sep-15 4:56 
AnswerRe: Radio Buttons, Lots of them Pin
David Crow8-Sep-15 9:13
David Crow8-Sep-15 9:13 

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.