Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dialog "Edit" control for HTML Pin
David Crow21-Jun-04 3:11
David Crow21-Jun-04 3:11 
GeneralDissalow a dir Pin
gamitech20-Jun-04 10:27
gamitech20-Jun-04 10:27 
GeneralRe: Dissalow a dir Pin
Ryan Binns20-Jun-04 18:17
Ryan Binns20-Jun-04 18:17 
GeneralRe: Dissalow a dir Pin
gamitech22-Jun-04 13:43
gamitech22-Jun-04 13:43 
GeneralRe: Dissalow a dir Pin
David Crow21-Jun-04 3:12
David Crow21-Jun-04 3:12 
GeneralRe: Dissalow a dir Pin
gamitech22-Jun-04 13:45
gamitech22-Jun-04 13:45 
GeneralRe: Dissalow a dir Pin
David Crow23-Jun-04 3:02
David Crow23-Jun-04 3:02 
GeneralDrawString and print preview Pin
Jorgen E.20-Jun-04 8:58
Jorgen E.20-Jun-04 8:58 
Hi,

I'm working on a MFC application with a CScrollView derived view class. Everything is working fine, except that when I use double buffering, the text comes out "blurry". I can't quite explain how it looks, but without double buffering, the text comes out as expected, but using double buffering, it kind of seems like everything is drawn twice, a pixel apart.... (I know it's not much of an explanation, but it's the best I got Roll eyes | :rolleyes: )

Any ideas's on why this is happening? It's not happening with any other drawing that I'm doing...

Another thing I need some help on is the print preview:

The regular print seems to be working fine, but in the print preview, everything is scaled down, and is displayed basically without margins. This probably has a easy solution, but anyways.... Smile | :)

Thanks!

Edit: Forgot that some migth enjoy a bit of source code to go along with my first problem: Blush | :O

<br />
void CITPAXpertView::OnDraw(CDC* pDC)<br />
{<br />
	CITPAXpertDoc* pDoc = GetDocument();<br />
	ASSERT_VALID(pDoc);<br />
	if (!pDoc)<br />
		return;<br />
<br />
	// Kode for å tegne opp rapporten<br />
	int nWidth = GetDocument()->GetDocSize().cx;<br />
	int nHeight = GetDocument()->GetDocSize().cy;<br />
	Graphics graphics(pDC->m_hDC);<br />
<br />
	// Test for drawing with double buffering<br />
	#ifdef _DEBUG<br />
	#undef new<br />
		Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
	#define new DEBUG_NEW<br />
	#else<br />
		Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
	#endif<br />
<br />
	Graphics* graph = Graphics::FromImage(bmp);<br />
<br />
	CRect area;<br />
	area.SetRect( 0, 0, 100, 100); TextPrint(&graphics, 10, 0, area, "Hello!", 1); // Clean<br />
	area.SetRect( 100, 0, 200, 100); TextPrint(graph, 10, 0, area, "Hello!", 1); // "Blurry"<br />
<br />
	// Tegner til skjermen, og sletter minnet av bitmapen<br />
	graphics.DrawImage( bmp, 0, 0, nWidth, nHeight);<br />
	delete graph;<br />
	delete bmp;<br />
}<br />

The TextPrint is as follows:
<br />
void CITPAXpertView::TextPrint(Graphics* pdc, int height, REAL rotation, CRect area, CString text, int alignment, Color fargen)<br />
{<br />
	FontFamily fontFamily(L"Arial");<br />
	Font font(&fontFamily, (REAL)height, FontStyleRegular, UnitPixel);<br />
	RectF areal( (REAL)area.left, (REAL)area.top, (REAL)(area.right - area.left), (REAL)(area.bottom - area.top));<br />
	StringFormat stringFormat;<br />
<br />
	// Skriver all teksten i sort skrift<br />
	SolidBrush  solidBrush(fargen);<br />
<br />
	// Formaterer strengen med hensyn på høyre, venstre eller midtstilt justering<br />
	if (alignment == 0) { stringFormat.SetAlignment(StringAlignmentNear);	}<br />
	else if (alignment == 1) { stringFormat.SetAlignment(StringAlignmentCenter); }<br />
	else { stringFormat.SetAlignment(StringAlignmentFar); }<br />
<br />
	// Midtstiller teksten på linjene<br />
	stringFormat.SetLineAlignment(StringAlignmentCenter);<br />
<br />
	// Assuming the string 'text' contains our string to print<br />
	// Converts datatypes and prints the text<br />
	WCHAR*  tekst = new WCHAR[text.GetLength()+1];<br />
	mbstowcs(tekst, text, text.GetLength()+1);<br />
<br />
	// Skriver teksten til skjermen, og sletter den etterpå<br />
   if( rotation != 0 ) {<br />
	    // Må ta noen spesielle hensyn hvis vi skal rotere teksten noe som helst<br />
	    pdc->TranslateTransform(-areal.X-areal.Width/2, -areal.Y-areal.Height/2, MatrixOrderPrepend);<br />
		pdc->RotateTransform(-rotation, MatrixOrderAppend);<br />
		pdc->TranslateTransform(areal.X+areal.Width/2, areal.Y+areal.Height/2, MatrixOrderAppend);<br />
		pdc->DrawString(tekst, -1, &font, areal, &stringFormat, &solidBrush);<br />
		pdc->ResetTransform();<br />
   }<br />
   else {<br />
		pdc->DrawString(tekst, -1, &font, areal, &stringFormat, &solidBrush);<br />
   }<br />
<br />
	delete tekst;<br />
}<br />


I hope this helps, and maybe, just maybe, someone can help me out...D'Oh! | :doh:
GeneralCatching All Exception Pin
AJ12320-Jun-04 5:15
AJ12320-Jun-04 5:15 
GeneralRe: Catching All Exception Pin
Michael Dunn20-Jun-04 5:51
sitebuilderMichael Dunn20-Jun-04 5:51 
GeneralAfxGetApp in a DLL Pin
MHillary20-Jun-04 4:32
MHillary20-Jun-04 4:32 
GeneralRe: AfxGetApp in a DLL Pin
Johan Rosengren20-Jun-04 4:53
Johan Rosengren20-Jun-04 4:53 
GeneralRe: AfxGetApp in a DLL Pin
MHillary20-Jun-04 5:02
MHillary20-Jun-04 5:02 
GeneralRe: AfxGetApp in a DLL Pin
Johan Rosengren20-Jun-04 20:58
Johan Rosengren20-Jun-04 20:58 
GeneralRe: AfxGetApp in a DLL Pin
MHillary23-Jun-04 3:32
MHillary23-Jun-04 3:32 
GeneralRe: AfxGetApp in a DLL Pin
Johan Rosengren23-Jun-04 3:49
Johan Rosengren23-Jun-04 3:49 
Generaldialog/window active/inactive Pin
Anonymous20-Jun-04 1:59
Anonymous20-Jun-04 1:59 
GeneralRe: dialog/window active/inactive Pin
Ravi Bhavnani20-Jun-04 4:27
professionalRavi Bhavnani20-Jun-04 4:27 
GeneralDLL loading and unloading Pin
SatyaKn20-Jun-04 0:37
SatyaKn20-Jun-04 0:37 
GeneralIconize the application Pin
SatyaKn20-Jun-04 0:26
SatyaKn20-Jun-04 0:26 
GeneralRe: Iconize the application Pin
Ravi Bhavnani20-Jun-04 4:21
professionalRavi Bhavnani20-Jun-04 4:21 
GeneralEnable Frontpage server extensions Pin
namvo19-Jun-04 22:45
namvo19-Jun-04 22:45 
GeneralProblem with select() I think Pin
Abo_Osama19-Jun-04 22:31
Abo_Osama19-Jun-04 22:31 
GeneralPlease help me re-compile the original Quake II source code from "ground-up". Pin
Link260019-Jun-04 17:53
Link260019-Jun-04 17:53 
GeneralRe: Please help me re-compile the original Quake II source code from &quot;ground-up&quot;. Pin
palbano19-Jun-04 18:49
palbano19-Jun-04 18:49 

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.