Recover files from ObjectARX app

Recover files from ObjectARX app

Anonymous
Not applicable
634 Views
5 Replies
Message 1 of 6

Recover files from ObjectARX app

Anonymous
Not applicable
Hi,

I want to recover several files from an ObjectARX app.
I have studied an earlier topic: http://discussion.autodesk.com/thread.jspa?messageID=5255836
which seems to deal with the problem.

But compiling the code:
// by Fenton Webb, DevTech, Autodesk
// my timer proc, this will pump the recover command when Autocad is ready
void CALLBACK EXPORT RecoverTimer (HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
CString cmd = _T("c:\\temp\\test.dwg\n");
// RegisterAPP() ;
COPYDATASTRUCT cmdMsg;
HWND hWndACAD;
hWndACAD = adsw_acadMainWnd();
cmdMsg.dwData = (DWORD)1;
cmdMsg.cbData = (DWORD)_tcslen(cmd) + 1;
cmdMsg.lpData = cmd.GetBuffer(cmd.GetLength()+1);
// Send the message to AutoCAD.
SendMessage(hWndACAD, WM_COPYDATA, (WPARAM)hWndACAD, (LPARAM)&cmdMsg);

acedGetAcadFrame()->KillTimer(nIDEvent);
}

void CFileRecovery::OpenDwgFromApplicationContext(void *pData)
{
if(acDocManager->isApplicationContext())
{
CString *dwgNameToOpen = reinterpret_cast(pData);
acDocManager->sendStringToExecute(curDoc(), _T("recover "));
//acDocManager->appContextOpenDocument(*dwgNameToOpen);
acedGetAcadFrame()->SetTimer(999, 1000, RecoverTimer);
}
else return;

acDocManager->setCurDocument(acDocManager->mdiActiveDocument());
}
//-----------------------------------------------------------------------------
// This is command 'OPENDWGDOC, by Fenton Webb [29/08/2003], DevTech, Autodesk
void CFileRecovery::asdkopendwgDoc()
{
CString dwgNameToOpen;
dwgNameToOpen = _T("c:\\temp\\test.dwg\n") ;

if(acDocManager->isApplicationContext())
{
acDocManager->appContextOpenDocument(dwgNameToOpen);
}
else acDocManager->executeInApplicationContext(CFileRecovery::OpenDwgFromApplicationContext, &dwgNameToOpen);
}

Result in the following compiler error:
error C3867: 'CFileRecovery::OpenDwgFromApplicationContext': function call missing argument list; use '&CFileRecovery::OpenDwgFromApplicationContext' to create a pointer to member

Does anyone have an idea of what I am missing?
Thanks
Johannes P. Hansen
0 Likes
635 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
> Does anyone have an idea of what I am missing?

The error message tells you the problem and how to fix it (add the '&'
prefix). You'll also need to change the two instances of "+ 1" to "+
sizeof(TCHAR)" in the RecoverTimer function. 🙂
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks Owen,

I tried the "&" one too, but that didn't help much :o((

I changed the code to:
else acDocManager->executeInApplicationContext(&CFileRecovery::OpenDwgFromApplicationContext, &dwgNameToOpen);

and got the error:

error C2664: 'AcApDocManager::executeInApplicationContext' : cannot convert parameter 1 from 'void (__thiscall CFileRecovery::* )(void *)' to 'void (__cdecl *)(void *)'

By "You'll also need to change the two instances of "+ 1" to "+
sizeof(TCHAR)" in the RecoverTimer function. " do you mean this:

cmdMsg.cbData = (DWORD)_tcslen(cmd)+ sizeof(TCHAR);
cmdMsg.lpData = cmd.GetBuffer(cmd.GetLength()+ sizeof(TCHAR));


Kind regards
Johannes P. Hansen
0 Likes
Message 4 of 6

Anonymous
Not applicable
Johannes:

> ...cannot convert parameter 1 from 'void (__thiscall
> CFileRecovery::* )(void *)'...

CFileRecovery::OpenDwgFromApplicationContext must be declared as a static
function, and correct on the "+ 1" bug. 🙂
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
0 Likes
Message 5 of 6

Anonymous
Not applicable
Thanks again Owen,

Great - I am getting closer :o))
I'm able to compile and get the app running.

Problem is that the recover dialog box pops up :o((

I'm not quite sure if I got corrected the "+1" bug in the right manner.

How would you type the code?

Kind regards
Johannes P. Hansen
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi Owen,

I almost got the app running now and everything seem to work, when I set FILEDIA to 0.
Last problem is that I get an annoying Autocad Messagebox telling me that Audit accepted recovered database.

I tried to send an other message just containing a CR - but that didn't help.

Do You have any idea how to get rid of the messagebox?

Kind regards
Johannes P. Hansen
0 Likes