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.
// Return handle to our CBrush object
hbr = m_brush;
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);
pDC->GetClipBox(&rect); // Erase the area needed
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
Once again thank you for your great help. That did the Trick! I have one more issue in the static text. It doesn't properly update the text. I think it is writing over the old text in each iteration. I am using a static text to display the current time. In each second it is being updated with new time with the help of a timer. It was working fine before we went for the transparent background. now it seems to be overwriting. Do I need to clear the text before updating it? I mean use some thing like
SetDlgItemText(IDC_STATIC_DATE,_T(" ")//8 space characters
It is working nicely now.
But I could not set text colour for the Check boxes and Radio buttons. IT shows up as black always regardless of SetTextColor(). Is there any other thing I have to do in CtlColor method for it? Also how to control the colour of Tab control ?
Sorry for the late reply. I was on leave due to some health problems
I tried your suggestion for the check boxes. But it shows some strange behaviors. Okay I will go with the black letters. But can you please tell me how to change the Tab controls color and button colors?
Can we access session cookies from C++/VC++ code.
How to do that?
I need to store data in session cookies when I open any web based client, and I need to access the cookies from VC++ code, I need help in that whether we can
Do that? Please somebody can let me know how to do that if there is any solution.
I am hosting web browser on a dialog( which is MFC dialog) and navigating to a link ( link ->which is a client to a database of articles)
when I open an article in the browser which I hosted on MFC dialog I will save the article id ( somehow I will get it ) in a session cookie.
Later on I need to access the session cookie from MFC code.
how to do that any idea please?
I am using CWebBrowser2 calss object as web browser, and useing CWebBrowser2 ::Navigate2 interface method to navigate to the specified link.
in that post , i do not understand how to create m_piRequest object
before making a call "hr = m_piRequest->get_Cookies(&pDict);"
i am not that familier with COM.
I googled it : m_piRequest is The IRequest interface pointer ( if am not wrong)
please let me know how to create m_piRequest object before start using it,
do i need to do cocreate instance?
please help me in this.
basically.. i am hosting CWebBrowser2 derived class object on a dialog.
and using Navigate funtion to navigate to any URL of a web application.
I will be createing cookies thru aspx page of the webapplication.
My class which cooperates with MS Acces base looks like below:
In doted place I removed code as a not relevant for case:
Problem is that field mTekst in Acces is set as Memo type. And I wish
to place long report texts in.
My class can't transfer longer text then 255 chars otherwise it shows
an error. Temporarily I deal with it by cutting part of chars.
(Look in function LeftF()) . But a program is not functionally then.
What can I do to deal with problem? Help