Click here to Skip to main content
15,921,959 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need help with this little C program Pin
CPallini14-Sep-15 3:40
mveCPallini14-Sep-15 3:40 
SuggestionRe: Need help with this little C program Pin
David Crow14-Sep-15 4:40
David Crow14-Sep-15 4:40 
GeneralRe: Need help with this little C program Pin
Member 1197963714-Sep-15 6:10
Member 1197963714-Sep-15 6:10 
QuestionC++ lambda callbacks, how to initialize with NULL pointer ? Pin
Member 853403512-Sep-15 0:45
Member 853403512-Sep-15 0:45 
AnswerRe: C++ lambda callbacks, how to initialize with NULL pointer ? Pin
Richard Andrew x6414-Sep-15 11:36
professionalRichard Andrew x6414-Sep-15 11:36 
GeneralRe: C++ lambda callbacks, how to initialize with NULL pointer ? Pin
Member 853403514-Sep-15 21:42
Member 853403514-Sep-15 21:42 
Questiondata structure and algoritm Pin
Member 1197512010-Sep-15 10:26
Member 1197512010-Sep-15 10:26 
AnswerRe: data structure and algoritm Pin
Afzaal Ahmad Zeeshan10-Sep-15 10:41
professionalAfzaal Ahmad Zeeshan10-Sep-15 10:41 
GeneralRe: data structure and algoritm Pin
Member 1197512010-Sep-15 10:55
Member 1197512010-Sep-15 10:55 
QuestionRe: data structure and algoritm Pin
CPallini10-Sep-15 21:19
mveCPallini10-Sep-15 21:19 
AnswerRe: data structure and algoritm Pin
David Crow11-Sep-15 2:11
David Crow11-Sep-15 2:11 
QuestionRe: data structure and algoritm Pin
CPallini11-Sep-15 2:35
mveCPallini11-Sep-15 2:35 
AnswerRe: data structure and algoritm Pin
jschell11-Sep-15 11:08
jschell11-Sep-15 11:08 
AnswerRe: data structure and algoritm Pin
David Crow11-Sep-15 2:10
David Crow11-Sep-15 2:10 
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 

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.