Click here to Skip to main content
15,914,255 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAutomatic code comment in C++ Pin
Filousov5-Mar-04 13:09
Filousov5-Mar-04 13:09 
GeneralRe: Automatic code comment in C++ Pin
Anthony_Yio5-Mar-04 20:39
Anthony_Yio5-Mar-04 20:39 
Generalnetworking Pin
til rules5-Mar-04 11:49
til rules5-Mar-04 11:49 
GeneralRe: networking Pin
Rickard Andersson205-Mar-04 13:12
Rickard Andersson205-Mar-04 13:12 
GeneralRe: networking Pin
Prakash Nadar6-Mar-04 3:15
Prakash Nadar6-Mar-04 3:15 
GeneralMessage Maps in Services Pin
mmica5-Mar-04 10:59
mmica5-Mar-04 10:59 
GeneralRe: Message Maps in Services Pin
Prakash Nadar5-Mar-04 13:23
Prakash Nadar5-Mar-04 13:23 
GeneralHelp with OnPaint Pin
S van Leent5-Mar-04 10:56
S van Leent5-Mar-04 10:56 
Currently, I have this code in my on paint event in a view.

<br />
	CPaintDC dc(this);<br />
<br />
	CPoint originalSize = matrix.GetSize();<br />
	int y, x;<br />
<br />
	for (y = 0; y < size.y; y++)<br />
	{<br />
		for (x = 0; x < size.x; x++)<br />
		{<br />
			dc.SetPixelV(CPoint(x,y), obj.GetColorRef(CPoint(x, y)));<br />
		}<br />
	}<br />
<br />


As you can understand, this is pretty slow with soewhat bigger pictures where for example, tje size is over 1000 x 1000 pixels. A solution, as far as I know, is to use a memory DC. However, I am doing something wrong.

I want to create the memory DC with the following

<br />
	CPaintDC dc(this);<br />
	CDC pdc;<br />
	dc.CreateCompatibleDC(&pdc);<br />
<br />
	CPoint originalSize = matrix.GetSize();<br />
	int y, x;<br />
<br />
	for (y = 0; y < size.y; y++)<br />
	{<br />
		for (x = 0; x < size.x; x++)<br />
		{<br />
			pdc.SetPixelV(CPoint(x,y), obj.GetColorRef(CPoint(x, y)));<br />
		}<br />
	}<br />
<br />
	dc.BitBlt(0, 0, size.x, size.y, ...)	<br />
<br />


However, the first time only a black block was drawn then, when resizing things go wrong (the app crashes), where a colored block should be drawn. What am I doing wrong, and if I am doing it wrong, how should I do it?

LPCTSTR Dutch = TEXT("Double Dutch Smile | :) ");
GeneralRe: Help with OnPaint Pin
LunaticFringe5-Mar-04 12:46
LunaticFringe5-Mar-04 12:46 
GeneralRe: Help with OnPaint Pin
Prakash Nadar5-Mar-04 13:21
Prakash Nadar5-Mar-04 13:21 
GeneralRe: Help with OnPaint Pin
John R. Shaw6-Mar-04 6:18
John R. Shaw6-Mar-04 6:18 
GeneralRe: Help with OnPaint Pin
Joe Woodbury6-Mar-04 11:51
professionalJoe Woodbury6-Mar-04 11:51 
Generalplay music in the background of my program Pin
til rules5-Mar-04 10:41
til rules5-Mar-04 10:41 
GeneralRe: play music in the background of my program Pin
LunaticFringe5-Mar-04 12:41
LunaticFringe5-Mar-04 12:41 
Generalin confused Pin
til rules5-Mar-04 10:18
til rules5-Mar-04 10:18 
GeneralRe: in confused Pin
David Crow5-Mar-04 10:24
David Crow5-Mar-04 10:24 
GeneralRe: in confused Pin
BlackDice5-Mar-04 10:26
BlackDice5-Mar-04 10:26 
GeneralRe: in confused Pin
til rules5-Mar-04 10:31
til rules5-Mar-04 10:31 
GeneralDisplaying a list of CD/DVD drives Pin
Dev5785-Mar-04 10:06
Dev5785-Mar-04 10:06 
GeneralRe: Displaying a list of CD/DVD drives Pin
mmica5-Mar-04 10:09
mmica5-Mar-04 10:09 
GeneralRe: Displaying a list of CD/DVD drives Pin
David Crow5-Mar-04 10:19
David Crow5-Mar-04 10:19 
GeneralRe: Displaying a list of CD/DVD drives Pin
Prakash Nadar5-Mar-04 13:15
Prakash Nadar5-Mar-04 13:15 
GeneralRe: Displaying a list of CD/DVD drives Pin
David Crow5-Mar-04 10:17
David Crow5-Mar-04 10:17 
GeneralRe: Displaying a list of CD/DVD drives Pin
Michael Dunn5-Mar-04 13:53
sitebuilderMichael Dunn5-Mar-04 13:53 
QuestionHow do I establish a dial up connection Pin
glweid5-Mar-04 7:53
glweid5-Mar-04 7:53 

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.