Re: Can't write text on screen after upgrade to VS2005/Vista

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I think you just need to do a process of elimination.

I haven't used Visual Studio much myself, but from a GDI aspect, it looks
like it should work as you want, if I can assume that the methods of a CDC
that you are calling do what it looks like they should do. You could try
stepping into them in the debugger.

What's DrawBox? Perhaps it changes the background mode back to OPAQUE.

Does VS3 refer to Visual Studio 2003 and VS5 refer to Visual Studio 2005?
You could try your EXE built using Visual Studio 2003 on Windows XP and run
it on your Windows Vista machine. If it does the same thing, it would appear
to be a difference between the two machines (OS version, graphics driver,
graphics hardware, etc.). If not, you can eliminate all this and it would
appear to be a different in software (compiler version or settings, MFC
code, etc.).

Paul

"E-Jo" <EJo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5E746A12-0023-4063-8AF2-6674DEC78DC5@xxxxxxxxxxxxxxxx
Ever since I upgraded from VS3/WinXP to VS5/Vista the text labels that I
write
on the screen do not work properly. A white box now covers the area of the
text. It appears to me that there might be a problem with the call to
pDC->SetBkMode(TRANSPARENT);

However, it does return 2, which corresponds to TRANSPARENT.

Also, I tried upgrading to the latest NVidia driver and that didn't help.

Any suggestions on what might be wrong here, or what I should try next
would be greatly appreciated.

Some of the code is listed below.

Thanks,
E-Jo

void CMfcOglView::LabelNds()
//labels nodes
{
CPoint pt;
CString nm;
char buf[5];
node* pNd;

CDC* pDC= GetDC();
pDC->SelectObject(hFont); //hFont is global created by InitFont
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255, 255, 255));

//label all nodes on screen
for (int ind= 1; ind <= pNet1->nnd; ind++) //each node in netnodes
{
pNd= pNet1->pNetnode(ind);
pt= pNd->scrnloc; //dist from mouse position to ac cg
DrawBox(pt, 3);
_itoa(pNd->ndnm, buf, 10);
nm= CString(buf);
pDC->TextOut(pt.x, pt.y, nm);
}
ReleaseDC(pDC);
} //LabelNds

void CMfcOglView::DrawBox(CPoint pt, int size)
//draws a box of given size (>= 3) centered on pt
{
CSize sz(size, size);
pt.x-= size/2;
pt.y-= size/2;
CRect rect(pt, sz);

CDC* pDC= GetDC();
CPen* pOldPen= pDC->SelectObject(m_pCurrentPen);
pDC->Rectangle(rect);
pDC->SelectObject(pOldPen);
ReleaseDC(pDC);
} //DrawBox


.



Relevant Pages