Click here to Skip to main content
15,923,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart15-Sep-09 4:31
Neil Urquhart15-Sep-09 4:31 
AnswerRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Code-o-mat15-Sep-09 4:48
Code-o-mat15-Sep-09 4:48 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart15-Sep-09 6:02
Neil Urquhart15-Sep-09 6:02 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart15-Sep-09 6:09
Neil Urquhart15-Sep-09 6:09 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Code-o-mat15-Sep-09 6:13
Code-o-mat15-Sep-09 6:13 
AnswerRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog [modified] Pin
Moak15-Sep-09 14:09
Moak15-Sep-09 14:09 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart15-Sep-09 20:04
Neil Urquhart15-Sep-09 20:04 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart15-Sep-09 20:57
Neil Urquhart15-Sep-09 20:57 
Ah ha !

Got it sussed. I should have used SetParent on the picture control and all its overlaping buttons to make them all children of the CDialog. I had to set the WS_CLIPCHILDREN/WS_CLIPSIBLINGS for the dialog/picture control to make it work. Without setting these properties the buttons don't display.

My code now looks like this with no "button redraw's" in the buttons select function.

BOOL CDesignEditDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	
	// TODO: Add extra initialization here
	CWnd* pImage ;
	WINDOWPLACEMENT wpImage ;
	CRect rect;
	CPoint imgPos ;

	// Set CDesignEditDlg WS_CLIPCHILDREN
	ModifyStyle(0, WS_CLIPCHILDREN) ;

	// Get the current top left position of the picture control window
	pImage = GetDlgItem(IDC_PAGEIMAGE) ;
	pImage->GetWindowPlacement(&wpImage);
	imgPos.x = wpImage.rcNormalPosition.left ;
	imgPos.y = wpImage.rcNormalPosition.top ;

	// Set picture control WS_CLIPSIBLINGS
	pImage->ModifyStyle(0, WS_CLIPSIBLINGS);

	// Make picture control child to CDesignEditDlg
	pImage->SetParent(this) ;

	CWnd* pButton ;
	int b ;
	for(b = 0 ; cButPos[b].id > 0 ; b++) {
		// Move the button
		pButton = GetDlgItem(cButPos[b].id);
		pButton->GetWindowRect(rect);
		pButton->MoveWindow(imgPos.x + cButPos[b].x - (rect.Width()/2), imgPos.y + cButPos[b].y, rect.Width(), rect.Height(), TRUE);

		// Make each CButton a child to CDesignEditDlg
		pButton->SetParent(this) ;
	}

	
	// Load the page images
	cBmp[0].LoadBitmap(IDB_IMAGE0);	// This is the unselect version
	cBmp[1].LoadBitmap(IDB_IMAGE1);
/*	cBmp[2].LoadBitmap(IDB_IMAGE2);
	cBmp[3].LoadBitmap(IDB_IMAGE3);
	cBmp[4].LoadBitmap(IDB_IMAGE4);
	cBmp[5].LoadBitmap(IDB_IMAGE5);
	cBmp[6].LoadBitmap(IDB_IMAGE6);
	cBmp[7].LoadBitmap(IDB_IMAGE7);
	cBmp[8].LoadBitmap(IDB_IMAGE8);
	cBmp[9].LoadBitmap(IDB_IMAGE9);
	cBmp[10].LoadBitmap(IDB_IMAGE10);
	cBmp[11].LoadBitmap(IDB_IMAGE11);
	cBmp[12].LoadBitmap(IDB_IMAGE12);
	cBmp[13].LoadBitmap(IDB_IMAGE13);
	cBmp[14].LoadBitmap(IDB_IMAGE14);
	cBmp[15].LoadBitmap(IDB_IMAGE15);
	cBmp[16].LoadBitmap(IDB_IMAGE16);
	cBmp[17].LoadBitmap(IDB_IMAGE17);
	cBmp[18].LoadBitmap(IDB_IMAGE18);*/
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



void CDesignEditDlg::ButtonPressed(int btn)
{
	// Set the selected button Image
	m_ctrlPageImage.SetBitmap(cBmp[1]);

/*	CButton* pImage ;
	int b ;
	for(b = 0 ; cButPos[b].id > 0 ; b++) {
		// Move the button
		pImage = (CButton*)GetDlgItem(cButPos[b].id);
		pImage->RedrawWindow() ;
	}*/

	CColourFaderDlg dlg;
	dlg.iFaderLineNo = btn ;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Replace the original image
	m_ctrlPageImage.SetBitmap(cBmp[0]);

/*	for(b = 0 ; cButPos[b].id > 0 ; b++) {
		// Move the button
		pImage = (CButton*)GetDlgItem(cButPos[b].id);
		pImage->RedrawWindow() ;
	}*/

}


void CDesignEditDlg::OnButtonSel1() 
{
	// TODO: Add your control notification handler code here
	TRACE("Button 1\n") ;
	ButtonPressed(1) ;

}

GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Moak15-Sep-09 23:21
Moak15-Sep-09 23:21 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart16-Sep-09 2:53
Neil Urquhart16-Sep-09 2:53 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Moak16-Sep-09 3:19
Moak16-Sep-09 3:19 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart16-Sep-09 3:56
Neil Urquhart16-Sep-09 3:56 
QuestionRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Moak16-Sep-09 4:21
Moak16-Sep-09 4:21 
AnswerRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Neil Urquhart16-Sep-09 4:41
Neil Urquhart16-Sep-09 4:41 
GeneralRe: How can I force the redraw of buttons which overlay a picture bitmap in a Dialog Pin
Moak16-Sep-09 5:12
Moak16-Sep-09 5:12 
QuestionI want to know which os am using from C code.Is it is possible? Pin
mohant$.net15-Sep-09 2:20
mohant$.net15-Sep-09 2:20 
QuestionRe: I want to know which os am using from C code.Is it is possible? Pin
David Crow15-Sep-09 2:36
David Crow15-Sep-09 2:36 
JokeRe: I want to know which os am using from C code.Is it is possible? Pin
CPallini15-Sep-09 2:46
mveCPallini15-Sep-09 2:46 
GeneralRe: I want to know which os am using from C code.Is it is possible? Pin
mohant$.net15-Sep-09 3:17
mohant$.net15-Sep-09 3:17 
GeneralRe: I want to know which os am using from C code.Is it is possible? Pin
CPallini15-Sep-09 3:30
mveCPallini15-Sep-09 3:30 
GeneralRe: I want to know which os am using from C code.Is it is possible? Pin
Stuart Dootson15-Sep-09 7:07
professionalStuart Dootson15-Sep-09 7:07 
AnswerRe: I want to know which os am using from C code.Is it is possible? Pin
Moak15-Sep-09 23:26
Moak15-Sep-09 23:26 
QuestionGet pixel data from PBITMAPINFO struct? Pin
Sauce!15-Sep-09 2:15
Sauce!15-Sep-09 2:15 
AnswerRe: Get pixel data from PBITMAPINFO struct? [modified] Pin
CPallini15-Sep-09 2:31
mveCPallini15-Sep-09 2:31 
GeneralRe: Get pixel data from PBITMAPINFO struct? Pin
Sauce!15-Sep-09 2:58
Sauce!15-Sep-09 2:58 

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.