|
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!!!
|
|
|
|
|
It's a nothing-fancy MFC SDI app. The only thing I changed in the CDocTemplate was the view class.
What's really stupid is I've done this before, and I can't think of anything I'm forgetting.
The trace through IsDerivedFrom doesn't make any sense. It's comparing pointers to objects instead of doing something like checking the results of a dynamic_cast to the desired base class. Here's that function - the bold parts are the lines executed:
BOOL CRuntimeClass::IsDerivedFrom(const CRuntimeClass* pBaseClass) const
{
ENSURE(this != NULL);
ASSERT(AfxIsValidAddress(this, sizeof(CRuntimeClass), FALSE));
ENSURE(pBaseClass != NULL);
ASSERT(AfxIsValidAddress(pBaseClass, sizeof(CRuntimeClass), FALSE));
const CRuntimeClass* pClassThis = this;
#ifdef _AFXDLL
for ( ; ; )
#else
while (pClassThis != NULL)
#endif
{
if (pClassThis == pBaseClass)
return TRUE;
#ifdef _AFXDLL
if (pClassThis->m_pfnGetBaseClass == NULL)
break;
pClassThis = (*pClassThis->m_pfnGetBaseClass)();
#else
pClassThis = pClassThis->m_pBaseClass;
#endif
}
return FALSE;
}
If checks the following classes:
CTestGridView3
CView <------------ !!!!!
CCmdTarget
CObject
NULL
"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
|
|
|
|
|
In the DLL, I had to set the "Characterset" property (under Configuration Properties/General) to "Not Set". Then everything works. :/
"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
|
|
|
|
|
Yeah, I tried it and noticed that I get the same error if the DLL and main app are built with different settings. I guess that means you can not mix MBCS and DBCS.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I'm guessing that "not set" means that the build falls back to the default of SBCS, which should not be used anymore.
|
|
|
|
|
The app is set to MBCS. If I set the DLL to "not set" or "MBCS", it works. If I set the DLL to Unicode, it doesn't work.
"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
|
|
|
|
|
Hello,
I have some questions about using global (system wide) hooks in Win32. I've got a simple app loading my simple DLL which sets up a WH_MOUSE hook:
m_hhook=SetWindowsHookEx(WH_MOUSE,MouseProc,m_hmod,0); (inside DLL)
My MouseProc is: (also inside DLL)
HOOKTEST2DLL_API LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
MOUSEHOOKSTRUCT *mhs=(MOUSEHOOKSTRUCT *)lParam;
if(nCode < 0) // do not process the message
return CallNextHookEx(m_hhook, nCode, wParam, lParam);
else
{
if((nCode==HC_ACTION) && (wParam==WM_LBUTTONDBLCLK))
{
PostThreadMessage(m_appthreadid,WM_APP+1,0,0);
m_mouseproc_counter++;
}
return CallNextHookEx(m_hhook, nCode, wParam, lParam);
}
}
I have also some variables in shared section of DLL which are initialised using:
HOOKTEST2DLL_API void fnInit()
{
m_hwnd_app=NULL; //main application window HWND
m_hhook=NULL; //WH_MOUSE hook handle
m_hwnd_desktop=::GetDesktopWindow(); //desktop window handle
m_mouseproc_counter=0; //mouse-dblclicks counter
m_appthreadid=NULL; //main application's thread ID
m_hmod=GetModuleHandle("HookTest2DLL.dll"); //DLL module handle
}
My questions are:
1) Why PostMessage(m_hwnd_app,WM_APP+1,0,0) doesn't work? Variable m_hwnd_app is set up after DLL is loaded and points to the main window of my simple MFC app. PostThreadMessage(m_appthreadid,WM_APP+1,0,0) works fine.
2) When I detect a doubleclick on desktop screen, in my MOUSEHOOKSTRUCT structure hwnd is set to 0x10094 (::GetDesktopWindow() returns 0x10014) but even when I double-click on any desktop icon (ie My Computer) I'm getting this event. Is it possible to filter out those events connected with double-clicking on desktop icons??
3) What is the best way of communicating between DLL and host application in case, when DLL could be injected into other threads/processes? Can I use variables in shared data section of my DLL or only PostThreadMessage() should be used?
Thank for any help
Pat.
|
|
|
|