Click here to Skip to main content
15,891,943 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Run Once Only Pin
Mark Salsbery30-May-07 14:52
Mark Salsbery30-May-07 14:52 
QuestionVC++ 6.0 Dialog Form with Picture Box Pin
rjrodrig30-May-07 13:51
rjrodrig30-May-07 13:51 
AnswerRe: VC++ 6.0 Dialog Form with Picture Box Pin
Hans Dietrich30-May-07 15:09
mentorHans Dietrich30-May-07 15:09 
Questiondirectsound,how to compress and decompress sound data Pin
kcynic30-May-07 13:17
kcynic30-May-07 13:17 
AnswerRe: directsound,how to compress and decompress sound data Pin
Mark Salsbery30-May-07 15:06
Mark Salsbery30-May-07 15:06 
GeneralRe: directsound,how to compress and decompress sound data Pin
kcynic30-May-07 22:31
kcynic30-May-07 22:31 
GeneralRe: directsound,how to compress and decompress sound data Pin
Mark Salsbery31-May-07 5:27
Mark Salsbery31-May-07 5:27 
QuestionMonochrome Bitmap Issue Pin
CoffeeAddict1930-May-07 12:23
CoffeeAddict1930-May-07 12:23 
I'm having a problem with memory device contexts and bitmaps in MFC. I've gotten to the point to where I can create and use them, but natrually they are all in black in white. See here:

http://img.photobucket.com/albums/v50/blackdwarf/piegraphcontrol.jpg[^]

With a CreateCompatibleDC(NULL) call, a monochrome bitmap gets created for and selected into the CDC. When I actually create my bitmap based off of that CDC, I'm stuck with the monochrome. So my question is, how do I initialize the bitmaps with color outside of OnPaint when I can't just use CPaintDC?

Here is some of the code...

Creating the two bitmaps without a CPaintDC (where I think the problem is):

BOOL CPieGraph::Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle /*=WS_VISIBLE*/)
{
	BOOL OverallSuccess = FALSE;
	BOOL CreateResult = FALSE,
		TextDCResult = FALSE,
		PieDCResult = FALSE;
	int SelectText = 0, SelectPie = 0;

	CreateResult = CWnd::Create(CPIEGRAPH_CLASSNAME, _T(""), dwStyle, rect, pParentWnd, nID);

	TextDCResult = TextMemDC.CreateCompatibleDC(NULL);
	PieDCResult = PieMemDC.CreateCompatibleDC(NULL);
	SelectText = m_textBitmap.CreateCompatibleBitmap(&TextMemDC, 250, 20);
	SelectPie = m_pieBitmap.CreateCompatibleBitmap(&PieMemDC, 300, 300);
	OldtextBitmap = TextMemDC.SelectObject(&m_textBitmap);
	OldpieBitmap = PieMemDC.SelectObject(&m_pieBitmap);
	TextMemDC.SetBkColor(RGB(255,255,255));
	PieMemDC.SetBkColor(RGB(255,255,255));
	if((CreateResult == TRUE) && (TextDCResult == TRUE) && (PieDCResult == TRUE) && (SelectText != 0) && (SelectPie != 0))
	{
		OverallSuccess = TRUE;
		ControlRect = rect;
	}
	else
		OverallSuccess = FALSE;

	return OverallSuccess;
}


And OnPaintDC:

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

	CDC ControlMemDC;
	CBitmap ControlBitmap;
	CBitmap* OldBitmap = NULL;

	ControlMemDC.CreateCompatibleDC(&dc);
	ControlBitmap.CreateCompatibleBitmap(&ControlMemDC, 300, 360);
	OldBitmap = ControlMemDC.SelectObject(&ControlBitmap);
	ControlMemDC.SetBkColor(RGB(255,255,255));

	if(UpdateNeeded == true)
	{
		RedrawPieText(TextMemDC);
		RedrawPieChart(PieMemDC);
		ControlMemDC.BitBlt(0, 0, 250, 20, &TextMemDC, 0, 0, SRCCOPY);
		ControlMemDC.BitBlt(0, 25, MainPieGraph.radius * 2, 
			MainPieGraph.radius * 2, &PieMemDC, 0, 0, SRCCOPY);
		//UpdateNeeded = false;
		UpdateNeeded = true;
	}

	dc.BitBlt(ControlRect.left, ControlRect.top, 250, 320, &ControlMemDC, 0, 0, SRCCOPY);
	ControlMemDC.SelectObject(OldBitmap);
}

AnswerRe: Monochrome Bitmap Issue Pin
Bram van Kampen30-May-07 14:28
Bram van Kampen30-May-07 14:28 
AnswerRe: Monochrome Bitmap Issue Pin
Mark Salsbery30-May-07 15:16
Mark Salsbery30-May-07 15:16 
GeneralRe: Monochrome Bitmap Issue Pin
CoffeeAddict1930-May-07 17:08
CoffeeAddict1930-May-07 17:08 
GeneralRe: Monochrome Bitmap Issue Pin
Mark Salsbery31-May-07 5:36
Mark Salsbery31-May-07 5:36 
GeneralRe: Monochrome Bitmap Issue Pin
CoffeeAddict1931-May-07 8:19
CoffeeAddict1931-May-07 8:19 
GeneralRe: Monochrome Bitmap Issue Pin
CoffeeAddict1931-May-07 8:38
CoffeeAddict1931-May-07 8:38 
GeneralRe: Monochrome Bitmap Issue Pin
Mark Salsbery31-May-07 8:53
Mark Salsbery31-May-07 8:53 
GeneralRe: Monochrome Bitmap Issue [modified] Pin
Mark Salsbery31-May-07 8:43
Mark Salsbery31-May-07 8:43 
GeneralRe: Monochrome Bitmap Issue Pin
CoffeeAddict1931-May-07 9:58
CoffeeAddict1931-May-07 9:58 
GeneralRe: Monochrome Bitmap Issue Pin
Mark Salsbery31-May-07 10:05
Mark Salsbery31-May-07 10:05 
Questiontable and vector, C++ Pin
C_Zealot30-May-07 11:39
C_Zealot30-May-07 11:39 
GeneralRe: table and vector, C++ Pin
C_Zealot30-May-07 11:42
C_Zealot30-May-07 11:42 
AnswerRe: table and vector, C++ Pin
Rajkumar R31-May-07 1:16
Rajkumar R31-May-07 1:16 
GeneralRe: table and vector, C++ Pin
C_Zealot31-May-07 1:18
C_Zealot31-May-07 1:18 
QuestionDirectshow : Connect to another process's graph... Pin
Akin Ocal30-May-07 11:36
Akin Ocal30-May-07 11:36 
AnswerRe: Directshow : Connect to another process's graph... Pin
Mark Salsbery30-May-07 15:19
Mark Salsbery30-May-07 15:19 
QuestionConnect to another process's graph... Pin
Akin Ocal30-May-07 11:35
Akin Ocal30-May-07 11:35 

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.