Click here to Skip to main content
15,567,585 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Code Help Pin
CPallini14-Sep-09 12:15
mveCPallini14-Sep-09 12:15 
AnswerRe: Code Help Pin
Richard MacCutchan14-Sep-09 12:43
mveRichard MacCutchan14-Sep-09 12:43 
AnswerRe: Code Help Pin
Adam Roderick J14-Sep-09 19:01
Adam Roderick J14-Sep-09 19:01 
Question[Message Deleted] Pin
Jim Fell14-Sep-09 10:45
Jim Fell14-Sep-09 10:45 
AnswerRe: Reading ASCII File TAB is Replace with NULL Pin
David Crow14-Sep-09 11:06
David Crow14-Sep-09 11:06 
QuestionActive windows Pin
mishudev14-Sep-09 9:58
mishudev14-Sep-09 9:58 
AnswerRe: Active windows Pin
Randor 14-Sep-09 10:52
professional Randor 14-Sep-09 10:52 
QuestionSetting a controls background to transparent Pin
Deepak.Prahlad14-Sep-09 8:47
Deepak.Prahlad14-Sep-09 8:47 
Hi I want to set the background of a static control to transparent. How to do this?

I tried the methode described in MSDN ( using the ON_WM_CTLCOLOR() and ON_WM_ERASEBKGND() ) but not working.

My intention is to set the background to a blue gradient or just a solid fill. I have lot of static controls and check boxes in my dialog. I mangaed to set the background of my dialog to solid blue with the help of MSDN documentation. But static control background becomes white whatever i do according to the documentation. Compailer complainted that m_brush is not declaired. I declaired it as CBrush m_brush; in .h file. I have not initialized and not sure how to initialise it.

Am i doing something wrong? Please help. Below is what I got from the MSDN (FYR)

HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
   // Call the base class implementation first! Otherwise, it may
   // undo what we're trying to accomplish here.
   HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

   // Are we painting the IDC_MYSTATIC control? We can use
   // CWnd::GetDlgCtrlID() to perform the most efficient test.
   if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
   {
      // Set the text color to red
      pDC->SetTextColor(RGB(255, 0, 0));

      // Set the background mode for text to transparent 
      // so background will show thru.
      pDC->SetBkMode(TRANSPARENT);

      // Return handle to our CBrush object
      hbr = m_brush;
   }
   return hbr;
}

BOOL CTestDlg::OnEraseBkgnd(CDC* pDC)
{
      // Set brush to desired background color
      CBrush backBrush(RGB(255, 128, 128));

      // Save old brush
      CBrush* pOldBrush = pDC->SelectObject(&backBrush);

      CRect rect;
      pDC->GetClipBox(&rect);     // Erase the area needed

      pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
          PATCOPY);
      pDC->SelectObject(pOldBrush);
      return TRUE;
}

AnswerRe: Setting a controls background to transparent Pin
Randor 14-Sep-09 10:50
professional Randor 14-Sep-09 10:50 
GeneralRe: Setting a controls background to transparent Pin
Deepak.Prahlad14-Sep-09 20:22
Deepak.Prahlad14-Sep-09 20:22 
GeneralRe: Setting a controls background to transparent Pin
Randor 15-Sep-09 1:19
professional Randor 15-Sep-09 1:19 
GeneralRe: Setting a controls background to transparent Pin
Deepak.Prahlad15-Sep-09 2:08
Deepak.Prahlad15-Sep-09 2:08 
GeneralRe: Setting a controls background to transparent Pin
Randor 15-Sep-09 4:06
professional Randor 15-Sep-09 4:06 
GeneralRe: Setting a controls background to transparent Pin
Deepak.Prahlad15-Sep-09 5:55
Deepak.Prahlad15-Sep-09 5:55 
GeneralRe: Setting a controls background to transparent Pin
Randor 15-Sep-09 6:42
professional Randor 15-Sep-09 6:42 
GeneralRe: Setting a controls background to transparent Pin
Deepak.Prahlad16-Sep-09 0:25
Deepak.Prahlad16-Sep-09 0:25 
GeneralRe: Setting a controls background to transparent Pin
Randor 16-Sep-09 2:50
professional Randor 16-Sep-09 2:50 
GeneralRe: Setting a controls background to transparent Pin
Deepak.Prahlad16-Sep-09 3:21
Deepak.Prahlad16-Sep-09 3:21 
GeneralRe: Setting a controls background to transparent Pin
Randor 16-Sep-09 3:57
professional Randor 16-Sep-09 3:57 
GeneralRe: Setting a controls background to transparent Pin
Deepak.Prahlad23-Sep-09 0:25
Deepak.Prahlad23-Sep-09 0:25 
QuestionCan we access session cookies from C++/VC++ code? Pin
sarat14-Sep-09 7:08
sarat14-Sep-09 7:08 
QuestionRe: Can we access session cookies from C++/VC++ code? Pin
David Crow14-Sep-09 8:05
David Crow14-Sep-09 8:05 
AnswerRe: Can we access session cookies from C++/VC++ code? [modified] Pin
sarat16-Sep-09 7:54
sarat16-Sep-09 7:54 
QuestionRe: Can we access session cookies from C++/VC++ code? Pin
David Crow16-Sep-09 7:59
David Crow16-Sep-09 7:59 
AnswerRe: Can we access session cookies from C++/VC++ code? Pin
sarat16-Sep-09 9:16
sarat16-Sep-09 9:16 

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.