|
How to get the currrent view's bk color. I have used pDC->GetBkColor() in OnDraw() of the form view class but it gave white color.
How can this be done?
Thank you.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: but it gave white color.
How you are determining this ? Show code.
It gives actual color of form.
|
|
|
|
|
This is the code
void CCallLoggerClientView::OnDraw(CDC* pDC)
{
CRect rc;
GetClientRect(&rc);
CString str= "date";
COLORREF clr;
clr = pDC->GetBkColor();
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(DATE_COLOR);
pDC->FillSolidRect(rc.Width()*3/4+9,2,rc.Width()*3/4+50,15,clr);
pDC->TextOut(rc.Width()*3/4+10,2,str);
}
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: pDC->FillSolidRect(rc.Width()*3/4+9,2,rc.Width()*3/4+50,15,clr);
Why you are using this function here. You are filling rect with color , which is already thre.
Even with this call, GetBkColor returns color of form view.
|
|
|
|
|
Actually i am calling the same bunch of lines in a timer function. So the text is getting a whilte background every time.So i did like that.
Is there another way to do this?
KIRAN PINJARLA
|
|
|
|
|
And how you are creating DC there ?
|
|
|
|
|
i used
CClientDC dc(this);
KIRAN PINJARLA
|
|
|
|
|
Use CPaintDC instead.
Additionally, you need to Invalidate the rect before using this. i.e.
void CMyView::OnTimerProc()
{
Invalidate();
CPaintDC(this);
}
|
|
|
|
|
Invalidate() causes flickering in my window.
KIRAN PINJARLA
|
|
|
|
|
OK. I called InvalidateRect() in the rect region in which the text falls. Not it looks ok.
Thank you.
KIRAN PINJARLA
|
|
|
|
|
What should i do if i want to show a bigger text and with a different font?
KIRAN PINJARLA
|
|
|
|
|
Create font of your choice.
And select it in DC.
CFont *pOld = pDc->SelectObject(&Font);
pDc->SelectObject(pOld);
|
|
|
|
|
how to get one of the system default fonts which are availabel with OS?
KIRAN PINJARLA
|
|
|
|
|
Use GetStockObject .
HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT);
|
|
|
|
|
Thank you so much prasad.
KIRAN PINJARLA
|
|
|
|
|
Hello
I want to search specified string in a text(*.txt) and count the numbers of the string in this text.
what functions or methods could be supported for the question??
Thanks a lot.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
|
Hello
I am sorry that I don't how to use the function. I try to use it in MFC, but I can't find CString can open the txt file.
If possible, please tell me how to open the txt file and search the specified string in detail ,or what steps and functions I must do for the question.
Thanks your help again.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
Use CFile class to open and read the file. Then use CString class to work upon string values, as already pointed out by WhiteSky.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Thanks your help. I will try it to the question.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
|
Hello All
I want my apllication to have unicode support, so i run apllication using _UNICODE,UNICODE preprocessor. I have following queries as
1) Should i convert all char. data type to wchar_t ,TCHAR.
2) When i compile code char. datatype not allowed, this means that i can not use char. data in unicode?
So anybody have answers of these queries plz send me.
Thanks
Atul
Atul
|
|
|
|
|
|
Using VS2005/SP1 and MFC...
I have a SDI app and I'm trying to use a CView-derived class from a MFC extension DLL in the document template object. Everything compiles fine with no warnings).
When the app hits the CDocTemplate constructor, it asserts on this line:
ASSERT(pViewClass == NULL ||
pViewClass->IsDerivedFrom(RUNTIME_CLASS(CView)));
The pViewClass pointer isn't NULL, so the assert is triggering on the IsDerivedFrom() function. The view I'm trying to use IS derived from CView. Why would it assert? What am I not seeing?
NOTE: If I move the view into the application project, it starts up just fine. And yes, I'm exporting the class, using class __declspec(dllexport) CTestView : public CView .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Have you stepped through the IsDerivedFrom() function?
How are you calling the CSingleDocTemplate c'tor?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|