|
|
I just tried your code snippet on a modified c:\boot.ini file and it read fine. The tab character was in pBuf .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all
i am new member of this forum.I need some help for Get Active window name.Can any one give me API or function name?
Thank in advance.
|
|
|
|
|
|
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)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
pDC->SetTextColor(RGB(255, 0, 0));
pDC->SetBkMode(TRANSPARENT);
hbr = m_brush;
}
return hbr;
}
BOOL CTestDlg::OnEraseBkgnd(CDC* pDC)
{
CBrush backBrush(RGB(255, 128, 128));
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
PATCOPY);
pDC->SelectObject(pOldBrush);
return TRUE;
}
|
|
|
|
|
|
Randor wrote: return((HBRUSH)GetStockObject(NULL_BRUSH));
Dear Randor,
It done the job for static texts. Thank you very much. But the check boxes give COLOR_BTNFACE as background colour if I return it only for the static text.
if (pWnd->GetDlgCtrlID() == IDC_STATIC_DATE)
{
hbr = ((HBRUSH)GetStockObject(NULL_BRUSH));
}
return hbr;
If I return it for all controls, check boxes become black. What to do?
sorry if I am asking silly questions.. I am newbie
Thanks in advance!
Deepak
|
|
|
|
|
Hi Deepak,
Deepak.Prahlad wrote: If I return it for all controls, check boxes become black. What to do?
If you are custom coloring multiple controls in your WM_CTLCOLOR handler then it would be better to use a switch statement with a single call to the pWnd->GetDlgCtrlID() function.
To handle both the static and the checkbox try something like this:
int iCtrlID = pWnd->GetDlgCtrlID();
switch(iCtrlID)
{
case IDC_STATIC_DATE:
{
pDC->SetBkMode(TRANSPARENT);
hbr = ((HBRUSH)GetStockObject(NULL_BRUSH));
break;
}
case IDC_YOUR_CHECKBOX:
{
RECT r;
pWnd->GetClientRect(&r);
pDC->BitBlt(0, 0, r.right - r.left, r.bottom - r.top, pWnd->GetDC(), r.left, r.top, SRCCOPY);
hbr = ((HBRUSH)GetStockObject(NULL_BRUSH));
break;
}
default:
break;
}
|
|
|
|
|
Dear Randor,
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(" ")
SetDlgItemText(IDC_STATIC_DATE,_T("HH:MM:SS")
Thank you
Deepak
|
|
|
|
|
Hi Deepak,
Are you Invalidating the CStatic window after you update the text?
SetDlgItemText(IDC_STATIC_DATE,_T("HH:MM:SS"));
CWnd *pWnd = GetDlgItem(IDC_STATIC_DATE);
if(NULL != pWnd)
{
pWnd->Invalidate();
pWnd->UpdateWindow();
}
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: Invalidating the CStatic window
Hi David,
That has no effect.
Thanks
Deepak
|
|
|
|
|
Sorry... I somehow misunderstood what your trouble was.
Now I understand your problem. The parent needs to redraw what was under the child something like this:
CWnd *pWnd = GetDlgItem(IDC_STATIC_DATE);
if(NULL != pWnd)
{
RECT r;
pWnd->GetWindowRect(&r);
ScreenToClient(&r);
InvalidateRect(&r);
}
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
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 ?
Thank You
Deepak
|
|
|
|
|
Hi Deepak,
This tells me that your Windows theme is overriding the colors. You can disable the theme for an individual control using the SetWindowTheme Function[^]. Lets use your checkbox as an example:
case IDC_YOUR_CHECKBOX:
{
RECT r;
pWnd->GetClientRect(&r);
pDC->BitBlt(0, 0, r.right - r.left, r.bottom - r.top, pWnd->GetDC(), r.left, r.top, SRCCOPY);
pDC->SetBkMode(TRANSPARENT);
hbr = ((HBRUSH)GetStockObject(NULL_BRUSH));
pDC->SetTextColor(RGB(255, 0, 0));
SetWindowTheme(pWnd->m_hWnd, L"", L"");
break;
}
We have disabled the theme on this control. It might not be what you want, maybe it will be ugly in your eyes.
Best Wishes,
-David Delaune
|
|
|
|
|
Compiler complained that
Error 1 error LNK2001: unresolved external symbol __imp__SetWindowTheme@12 LoggerDlg.obj
Error 2 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\deepak.p\Desktop\Logger Working\Logger 13-Sep-2009
From the documentation you provided it says to include "uxtheme.h" but it din't solved the compile error.
Do we need any other includes ?
|
|
|
|
|
Add:
#include "uxtheme.h"
#pragma comment(lib, "uxtheme.lib")
Or you can add the uxtheme.lib into the project linker settings.
Best Wishes,
-David Delaune
|
|
|
|
|
Dear David,
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?
Thanks in advance
Deepak
|
|
|
|
|
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.
Thank you in advance.
|
|
|
|
|
Are you wanting to do it via a BHO, or are you just wanting to open the .txt file?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
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.
modified on Wednesday, September 16, 2009 1:01 PM
|
|
|
|
|
sarat wrote: ...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?
If you have code for creating a cookie, why can't you access it?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I create cookeies thru .aspx page and post it to local machine with another .aspx page. the code is in aspx now i need to access the cookies from MFC code
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanx a lot DavidCrow,
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.
|
|
|
|
|
sarat wrote: I googled it : m_piRequest is The IRequest interface pointer ( if am not wrong)
That is correct.
sarat wrote: 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.
See here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|