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

C / C++ / MFC

 
GeneralRe: Draw image at another Application's HWND Pin
Christian Graus2-May-01 12:10
protectorChristian Graus2-May-01 12:10 
GeneralHiding a process in Task Manager ! Pin
yamini1-May-01 19:51
yamini1-May-01 19:51 
GeneralRe: Hiding a process in Task Manager ! Pin
AlexEg2-May-01 21:44
AlexEg2-May-01 21:44 
Question? Pin
yamini1-May-01 19:50
yamini1-May-01 19:50 
GeneralBitBlt on Win98 / WinNT Pin
Liam O'Hagan1-May-01 14:22
Liam O'Hagan1-May-01 14:22 
GeneralRe: BitBlt on Win98 / WinNT Pin
2-May-01 6:29
suss2-May-01 6:29 
GeneralRe: BitBlt on Win98 / WinNT Pin
Liam O'Hagan2-May-01 13:15
Liam O'Hagan2-May-01 13:15 
GeneralRe: BitBlt on Win98 / WinNT Pin
Christian Graus2-May-01 12:41
protectorChristian Graus2-May-01 12:41 
I've rewritten your function, I hope you find it a little neater Smile | :)

/*****************************************************/
/* draw some text */
/*****************************************************/

CRect rcWnd;
CFont TextFont, *oldFont;

CWnd *wnd = GetDlgItem(IDC_PLACEHOLDER); // find where to put the text (a static control)
ASSERT(wnd != NULL);
ASSERT(IsWindow(wnd->m_hWnd) != FALSE);
wnd->GetWindowRect(&rcWnd);
ScreenToClient(&rcWnd);

CDC placeDC;
if (!placeDC.Attach(wnd->GetDC()->GetSafeHdc()))
ASSERT(FALSE);

if (m_dc.GetSafeHdc() == NULL)
{
if (!m_dc.CreateCompatibleDC(&placeDC))
ASSERT(FALSE);
if (!m_bitmapTitle.CreateCompatibleBitmap(&placeDC, rcWnd.Width(), rcWnd.Height()))
ASSERT(FALSE);
m_pbitmapOldTitle = m_dc.SelectObject(&m_bitmapTitle) ;
m_dc.FillSolidRect(0, 0, rcWnd.Width(), rcWnd.Height(), ::GetSysColor(COLOR_3DFACE));
}

if (!TextFont.CreateFont (40, 0, 0, 0, 300, // Create the font
TRUE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Arial"))
ASSERT(FALSE);

oldFont = m_dc.SelectObject(&TextFont); // select the font

m_dc.SetTextColor (RGB(128, 0, 0)) ; // set a bunch of attributes of the dc
m_dc.SetBkMode(OPAQUE);
m_dc.SetBkColor(::GetSysColor(COLOR_3DFACE));
m_dc.SetTextAlign (TA_LEFT);

CString Title = "Test ";

m_dc.TextOut(0, 0, Title);

m_dc.SelectObject(oldFont) ;

placeDC.BitBlt(0, 0, rcWnd.Width(), rcWnd.Height(), &m_dc, 0, 0, SRCCOPY);


Basically your problem was that a CBitmap created under 98 using CreateCompatibleBitmap is full of random garbage. The line

m_dc.FillSolidRect(0, 0, rcWnd.Width(), rcWnd.Height(), ::GetSysColor(COLOR_3DFACE));

fixes this. You should have had text in the top corner though, but I'm not sure why you did not as I did a partial rewrite to get rid of unnecessary DC's, etc.

Where in Australia are you ? ( I'm in Tassie )

Christian

The content of this post is not necessarily the opinion of my yadda yadda yadda.

To understand recursion, we must first understand recursion.
GeneralRe: BitBlt on Win98 / WinNT Pin
Liam O'Hagan2-May-01 13:16
Liam O'Hagan2-May-01 13:16 
GeneralDrag and Drop tree view items Pin
wfalby1-May-01 10:35
wfalby1-May-01 10:35 
GeneralRe: Drag and Drop tree view items Pin
Tomasz Sowinski2-May-01 1:17
Tomasz Sowinski2-May-01 1:17 
GeneralActivating window Pin
F.Dost1-May-01 9:08
F.Dost1-May-01 9:08 
GeneralRe: Activating window Pin
1-May-01 9:55
suss1-May-01 9:55 
GeneralRe: Activating window Pin
Felix Cho1-May-01 11:35
Felix Cho1-May-01 11:35 
GeneralRe: Try this. Pin
Masaaki Onishi1-May-01 17:32
Masaaki Onishi1-May-01 17:32 
GeneralQuest on Flags... Pin
CMFC6.0VS.NETUser1-May-01 9:06
CMFC6.0VS.NETUser1-May-01 9:06 
GeneralRe: Quest on Flags... Pin
l a u r e n1-May-01 11:27
l a u r e n1-May-01 11:27 
GeneralRe: Quest on Flags... Pin
Michael Dunn1-May-01 16:29
sitebuilderMichael Dunn1-May-01 16:29 
GeneralRe: Quest on Flags... Pin
CMFC6.0VS.NETUser2-May-01 4:25
CMFC6.0VS.NETUser2-May-01 4:25 
Generalsimilar functions in vc++ for clreol and gotoxy Pin
1-May-01 8:55
suss1-May-01 8:55 
GeneralRe: similar functions in vc++ for clreol and gotoxy Pin
Christian Graus1-May-01 13:06
protectorChristian Graus1-May-01 13:06 
GeneralRe: similar functions in vc++ for clreol and gotoxy Pin
Tomasz Sowinski2-May-01 1:23
Tomasz Sowinski2-May-01 1:23 
GeneralHelp Topics Pin
kk91-May-01 8:46
kk91-May-01 8:46 
GeneralCOleControl and Office 200 Problem under NT4 Pin
Michael A Barnhart1-May-01 6:26
Michael A Barnhart1-May-01 6:26 
Generalw*fstream troubles Pin
Someone20021-May-01 5:43
Someone20021-May-01 5:43 

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.