|
one time right shift is like divide with 2 and one time left shift is like multiple wiht 2. So How can you find 136 result
|
|
|
|
|
I am running my application in Visual Studio .NET & am getting the following error "It is illegal to call out while inside message filter"
What can be causing this error to occur?
Thanks
|
|
|
|
|
Hi,
From my experience - this is caused by COM re-entrancy.
For example, COM server has called back into your app (via eventing) and you are then calling back into the COM server.
COM's telling you its blocking the call because it hasn't finished processing the previous method call.
I did the following which still blocks but without the annoying message
class CBusyState
{
public:
CBusyState(BOOL bEnterBusyState = TRUE,
SERVERCALL scBusyReply = SERVERCALL_RETRYLATER)
: m_bBusy(FALSE)
{
m_pMessageFilter = AfxOleGetMessageFilter();
if (bEnterBusyState)
Begin(scBusyReply);
}
~COasisBusyState()
{
End();
};
BOOL Begin(SERVERCALL scBusyReply = SERVERCALL_RETRYLATER)
{
if (m_pMessageFilter && !m_bBusy)
{
m_pMessageFilter->SetBusyReply(scBusyReply);
m_pMessageFilter->BeginBusyState();
m_bBusy = TRUE;
}
return m_bBusy;
}
void End()
{
if (m_pMessageFilter && m_bBusy)
{
m_pMessageFilter->EndBusyState();
m_bBusy = FALSE;
}
}
private:
BOOL m_bBusy;
COleMessageFilter* m_pMessageFilter;
};
Then whenever we call the COM server, I'd put the object on the stack, e.g.
function xyzxyzxyz()
{
CBusyState blocker(TRUE);
MyCOMServer->method(xyz)
}
Hope this helps,
Andy
|
|
|
|
|
Thanks alot for your response, I will try your idea, for now I put some workaround in my code.
Thanks again for the info.
|
|
|
|
|
I am getting server errors when trying to download a CAB file from a webserver.
I think the problem is that the default headers don't allow for CAB file mime type.
What string do I need to use in my call to
CHttpFile.AddRequestheaders(); to get this file?
I believe this is the problem, because if I change the URL to point to an HTML page, but leave everything else the same, then the file downloads just fine.
Thanks!
(I am also posting this in the Web Develpment forum)
//placeholder for witty verbiage
|
|
|
|
|
does "GET /.../.../foo.cab" really not work?
Don't try it, just do it!
|
|
|
|
|
|
I have set a MSChart control in my dialog,a error happened.
m_Chart.SetColumn(i);
when i=5,compiler shows :index given is out of bound and i=4,all right. Why?
|
|
|
|
|
I think the default column count in the control is 4.You can set the number of columns from the properties of the control.
|
|
|
|
|
thanks a lot,I have resulved this problem.
|
|
|
|
|
How can i calculate the idle time of machine in VC++.
|
|
|
|
|
Does GetLastInputInfo() help?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i have used GetLastInputInfo() but its not working.
|
|
|
|
|
Anonymous wrote:
...its not working.
Meaning what? You get a compiler/linker error? It doesn't produce the desired result? Please explain further.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Use Profiler in Build menu.
It may help
Kamyar Souri
Booria CAD/CAM Systems
www.booria.com
|
|
|
|
|
I want to implement a funtion.The follwing is its prototype:
CRuntimeClass* FindClass(CString &strClassName)
Parameter strClassName is the name of some class. I want to get the CRuntimeClass member variable of the class whose name is strClassName.
For example :
CString strClassName="CMyView";
CRuntimeClass * pRtc=FineClass(strClassName);
~~~~~~~~ I hope that I can get the pointer of CRuntimeClass member variable of CMyView;
Thanks for your help
I love sea
|
|
|
|
|
Hi,
My first thought would be to add a CMapStringToPtr object into your CDocument class
Then, on the constructor of each and every object you'll need, add a call to the object, e.g.
CMyView::CMyView() : CFormView(CMyView::IDD)
{
CMyDoc* pDoc = GetDocument();
if (pDoc) pDoc->RegisterClass(GetRuntimeClass()->m_lpszClassName, GetRuntimeClass());
}
We then need to remember to add an 'unregister' to the destructor...MOST important if you have any objects that will get destroyed/recreated during the lifetime of the application - otherwise the pointer held in the map will point to junk memory
CMyView::~CMyView()
{
CMyDoc* pDoc = GetDocument();
if (pDoc) pDoc->UnregisterClass(GetRuntimeClass()->m_lpszClassName);
}
Here are the functions in the Document...
BOOL CMyDoc::RegisterClass(const CString& strClassName, const CRuntimeClass* pClass)
{
CRuntimeClass* pLookup = NULL;
if (m_mapRuntimeClasses.Lookup(strClassName, (void*&)pLookup))
UnregisterClass(strClassName);
m_mapRuntimeClasses.SetAt(strClassName, ( void*& )pClass);
return TRUE;
}
BOOL CMyDoc::UnregisterClass(const CString& strClassName)
{
BOOL bRet = FALSE;
CRuntimeClass* pLookup = NULL;
if (m_mapRuntimeClasses.Lookup(strClassName, (void*&)pLookup))
bRet = m_mapRuntimeClasses.RemoveKey(strClassName);
return bRet;
}
The m_mapRuntimeClasses is the CMapStringToPtr object - if you wanted to be all OO about it, then best to encapsulate the functions you want into a derived CMapStringToPtr object and have this in your CDocument.
For any objects that need access to the document (other than views that already do), then preferred approach is:
CFrameWnd* pFrame = (CFrameWnd*)AfxGetApp()->m_pMainWnd;
if (pFrame && pFrame->GetSafeHwnd())
{
CMyDoc* pDoc = (CMyDoc*)pFrame->GetActiveDocument();
if (pDoc) pDoc->Register(.....);
}
Hope this helps,
Andy
|
|
|
|
|
|
Your ModuleState has a public member m_classList that you can enumerate through to find what you want...
// search app specific classes
AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
AfxLockGlobals(CRIT_RUNTIMECLASSLIST);
for (pClass = pModuleState->m_classList; pClass != NULL;
pClass = pClass->m_pNextClass)
{
if (lstrcmpA(szClassName, pClass->m_lpszClassName) == 0)
{
AfxUnlockGlobals(CRIT_RUNTIMECLASSLIST);
return pClass;
}
}
AfxUnlockGlobals(CRIT_RUNTIMECLASSLIST);
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I have tried your code. But it does not work.
"pModuleState->m_classList" is always eaqual to 0x0000. Can you tell me the reason?
I love sea
|
|
|
|
|
The only reason it may not work is because you are using MFC in shared DLLs -- check _AFXDLL preprocessor definition and if it's defined you may use the following code:
// search app specific classes
AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
AfxLockGlobals(CRIT_RUNTIMECLASSLIST);
for (pClass = pModuleState->m_classList; pClass != NULL;
pClass = pClass->m_pNextClass)
{
if (lstrcmpA(szClassName, pClass->m_lpszClassName) == 0)
{
AfxUnlockGlobals(CRIT_RUNTIMECLASSLIST);
return pClass;
}
}
AfxUnlockGlobals(CRIT_RUNTIMECLASSLIST);
#ifdef _AFXDLL
// search classes in shared DLLs
AfxLockGlobals(CRIT_DYNLINKLIST);
for (CDynLinkLibrary* pDLL = pModuleState->m_libraryList; pDLL != NULL;
pDLL = pDLL->m_pNextDLL)
{
for (pClass = pDLL->m_classList; pClass != NULL;
pClass = pClass->m_pNextClass)
{
if (lstrcmpA(szClassName, pClass->m_lpszClassName) == 0)
{
AfxUnlockGlobals(CRIT_DYNLINKLIST);
return pClass;
}
}
}
AfxUnlockGlobals(CRIT_DYNLINKLIST);
#endif
For an example of usage check code for
CRuntimeClass* PASCAL CRuntimeClass::Load(CArchive& ar, UINT* pwSchemaNum)
in MFC ArcCore.cpp file -- above example is taken from it -- it's used to load class during serialization...
It just have to work, otherwise serialization cannot be achieved...
Regards,
Igor
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I'm trying to check the update list from my webserver and then determine whether to update the program.But when i try to write something into my current installed list,it will cause an error for the next move. here is my code:
void CProjectXDlg::CheckUpdate(void)
{
CInternetSession session("Update");
CStdioFile* pFile=NULL;
CStdioFile fUpdateList;
CString strBuf,strBuf2;
pFile=session.OpenURL(host+"updatelist.txt");
fUpdateList.Open("applied.txt",CFile::modeReadWrite|CFile::modeNoTruncate|CFile::modeCreate);
while(pFile->ReadString(strBuf))
{
fUpdateList.ReadString(strBuf2);
if(strBuf!=strBuf2)//not same,go update!
{
fUpdateList.WriteString(strBuf+"\n");
}
}
fUpdateList.Close();
pFile->Close();
if(pFile)delete pFile;
session.Close();
}
the applied.txt will have some weird characters stored in...
|
|
|
|
|
Chooikw wrote:
the applied.txt will have some weird characters stored in...
You are reading from and writing to the same file. What did you expect to happen?
What are the "weird characters" you mention?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
>You are reading from and writing to the same file. What did you expect to happen?
What should I do if I want to compare each line of the file and then correct the applied.txt when it isn't same with the updatelist.txt in my server?
>What are the "weird characters" you mention?
there is lot of "ÍÍÍÍ"
|
|
|
|
|
>What should I do if I want to compare each line of the file and then correct the applied.txt when it isn't same with the updatelist.txt in my server?
Think you can write this data to another file and rename it at the end.
|
|
|
|