|
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.
|
|
|
|
|
If the new string is exactly the same length as the old string, you can call Seek() in between the two ReadString() calls. Otherwise, I'd go with *Dreamz's suggestion.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
thx for reply,i'm going with *Dreamz's suggestion.
|
|
|
|
|
I've run into a problem when trying to distribute my application. I'm using a freeware installer called Innno Setup, which is very nice. I have made sure that all of my dlls, config files and even the MSVC redistributable dlls are in the executable directory after install. But still the program dies with a MS VC++ errror. Abnormal program termination. It will not even start. I've gotten it to work on 1 machine which had MSVC7 installed. But machines with MSVC6 installed will not run the program unless it is run from the development environment. The target machines without any development environment throw the same error. So you see, I'm in a bind. Has anyone seen similar behavior?
nay
|
|
|
|
|
This sounds like either the application was built in debug mode and thus requires the debug MFC files, or the application is using an ActiceX control that is not present.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I made sure the app was release mode. Also there are no activex controls in this app. I've followed the directions given in the "Redistributing Microsoft Visual C++ 6.0 Applications" article on MSDN, but still no luck. The thing that's really bothering me is that it's not telling me there's a DLL missing. It's just crashing.
nay
|
|
|
|
|
So have you used the Depends utility to make sure all implicitly-loaded DLLs are present on the target machine?
Can you create a smaller version of your application that reproduces the problem?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
HI, I'm using GDI+ to draw curves and i want to erase them too, typically in GDI i would have used SetROP2 using R2_XORPEN but i dont find any such thing in GDI+ can anyone help me out erase a particular drawing say a circle or rectangle etc.. instead of erasing and redrawing the whole screen any help would be greatly appreciated.
|
|
|
|
|
Yes , Thre is not any raster operation in GDI+!
If you are drawing the curve pixel by pixel, add the pixels behind the curve to a list, and redraw them after.
else redraw only the rect that covers by the curve.
but somewhere I have read that It may be better to switch back to GDI somtimes;)
Kamyar Souri
Booria CAD/CAM Systems
www.booria.com
|
|
|
|
|
I have a toolbar button that I want to change dynamically to different solid blocks of colour. I can get a handle to the current image using
tbbi.dwMask = TBIF_IMAGE;
SendMessage(hTB,TB_GETBUTTONINFO,(WPARAM)TB_COLOUR,(LPARAM)&tbbi);
himl = (HIMAGELIST)SendMessage(hTB,TB_GETIMAGELIST,0,0L);
ImageList_GetImageInfo(himl,tbbi.iImage,&ii);
and I can replace the image and tell the toolbar to use the new one using
ImageList_Replace(himl,tbbi.iImage,hbm,NULL);
SendMessage(hTB,TB_CHANGEBITMAP,TB_COLOUR,MAKELPARAM(tbbi.iImage,0));
but in between how do I change the bitmap or create a new one? I've tried
hbm = (HBITMAP)CopyImage(ii.hbmImage,IMAGE_BITMAP,size.cx,size.cy,LR_COPYRETURNO);
selecting into a HDC, and using FillRectEx but it doesn't work. I'm using C and win32 (I don't know C++ or MFC).
Any help appreciated.
thanks
Dave Risley
|
|
|
|
|
Hi all, i would like to know how to create a function that takes a variable number of arguments (parameters), you know, like the CString::Format(LPCTSTR lpszFormat, ... ).
Please note that i do NOT use MFC (i use W32-API and WTL), so even if theres some class, typedef, or whatever that helps with this, but is part of MFC, it wont do me any good.
Any idea of where i should start looking?
Thanks!
|
|
|
|