|
can anybody show me which tool can generate my code from VC to API document spec like javadoc from Sun
|
|
|
|
|
|
doxygen[^] + graphviz[^] is a good solution. It also permits to use java doc style.
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
|
how about the other tools like RationalRose or Together, i have tried with Doxygen but it is limited with class diagram showing that only detect inheritance relations, how about other relations like Association,Aggregation, ....
i would like to find a tool that not only support feature to generate API doc spec like Doxygen but also can generate class diagram as RationalRose.
|
|
|
|
|
Would anybody tell me what is virtual destructor?
|
|
|
|
|
Hi
if u have for example multiple inherited classes
and u need to to call the destructor for one of them
so virtual used to call ur specific function u want
and virtual destructor always used at the frmae and application class for document and view
MFC programmer
|
|
|
|
|
the virtual C++ keywowrd tells that a member function is called instead of the base class' one.
for example, let's see this case :
<font color=blue>class</font> CBaseClass {
<font color=blue>public</font>:
<font color=blue>void</font> print() {
printf(<font color=gray>"CBaseClass\n"</font>);
}
};
<font color=blue>class</font> A : <font color=blue>public</font> CBaseClass {
<font color=blue>public</font>:
<font color=blue>void</font> print() {
printf(<font color=gray>"A\n"</font>);
}
};
now, if you make this :
CBaseClass* p = <font color=blue>new</font> A();
p->print();
this will display CBaseClass .
now, imagine you would like to access A::print() through a pointer to the base class, here come virtual .
if we had coded this instead :
<font color=blue>virtual void</font> print() { <font color=green></font> }
this would call the 'correct' print() function (as p is assigned with a A object, p->print() will call A::print() , even if p is a CBaseClass pointer).
understand better now ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Per MSDN:
A destructor implemented by declaring a base class's destructor with the keyword virtual. A virtual destructor ensures that, when delete is applied to a base class pointer or reference, it calls the destructor implemented in the derived class, if an implementation exists.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
What complicated descriptions .
If class A is derived from class B, and you create class A, cast it to a B pointer and delete the B pointer.
If there is no virtual destructor, only the B destructor will be called.
Don't try it, just do it!
|
|
|
|
|
Back in the old days when I used to use VS6, there was a profiler extension that allowed us to produce code timing and coverage for our C++ programs. Now I've been told that this feature have been removed for VS7.1
What do you guys use (if any) to get similar optimisation reports now in VS7.1 ? I do not use the .NET framework.
I Dream of Absolute Zero
|
|
|
|
|
|
Sweet. I'll test it out on a few of my projects.
I Dream of Absolute Zero
|
|
|
|
|
Not used it, but I think there is a bit of a profiler beast in VS 2005 for C++. You can probably play with the Beta. By the sounds of things the compiler itself can use the profiler results to add its own extra optimisations to the code based off the results.
Either a case of waiting until November, or using the Beta now.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
I use Ado to connect SQL Server,when I deleted a record,the Provider report a Error Message:"Row handle referred to a deleted row or a row marked for deletion".
The following is my sample code:
pRecordset->delete(adAffectCurrent);
pRecordset->Update();
pRecordset->MoveFirst();
i=0;
while(!m_pRecordset->adoEOF)
{
varValue = pRecordset->GetCollect(long(i);
i++;
if (varValue.vt == VT_NULL)
bstrValue = "";
AfxMessageBox(bstrValue);
pRecordset->MoveNext();
}
|
|
|
|
|
This could be many things. Some people get it because they lack a primary key. Others because they are using a JOIN in their select and find they must set the UniqueTable and ResyncCommand and call Resync after a method. Others must call Refresh(). Others get it working using the SQL Command equivalents. This is just what I heard from groups.google.com, I don't use ADO.
|
|
|
|
|
I'm writing an application with Visual C++ that needs to use Window's task scheduler to launch another application at some time in the future.
My problem is that whilst I can create a task that is supposed to run in the future, the Next Run Time (when viewed through Control Panel->Scheduled Tasks) is always "Never".
I've found that if I open the task through Control Panel->Scheduled Tasks and then delete the last character of the 'Run' string and enter the character again (just so it flags the file as having changes made) then click OK, the "Next Run Time" field then has the correct date and time.
It seems that although I've been able to create the task as I need it, it needs to be 'enabled' somehow - something that happens when I save from the Windows GUI but not when its done through my code.
I've been using the example code on MSDN as a guide, however I haven't been able to find any differences that could indicate where I'm going wrong.
Does anyone have any ideas as to what I'm doing wrong?
My OS is Windows XP Professional with SP2 if thats significant.
Thanks,
Brian.
|
|
|
|
|
|
What does your code look like that creates the task?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I've pasted the contents of the file here. The scheduling code has not been integrated into my app yet - I'm trying to get it to work first.
--------------------------------------------------------------------------------------------------
#include <afx.h>
#include <objbase.h>
#include <initguid.h>
#include <ole2.h>
#include <mstask.h>
#include <msterr.h>
#include <objidl.h>
#include <wchar.h>
#include <stdio.h>
#include "AFXPRIV.H"
int scheduleTask(SYSTEMTIME Time,CString ExeAndPath,CString ArgList,CString name);
int CreateTrigger(CString name, SYSTEMTIME Time);
int main(int argc, char **argv)
{
USES_CONVERSION;
SYSTEMTIME Time;
Time.wYear = 2005;
Time.wMonth = 7;
Time.wDayOfWeek = 2;
Time.wDay= 27;
Time.wHour= 18;
Time.wMinute= 0;
Time.wSecond= 0;
Time.wMilliseconds=0;
CString ExeAndPath = "C:\\Program Files\\Exterity";
CString ArgList = "\"ExterityLimitedRecord.exe\" -a 239.192.64.105 -p 49408 -t 120 -d C:\\temp\\ScheduledRecord1.mpg";
CString name = "Scheduled Record1";
int result = scheduleTask(Time,ExeAndPath,ArgList,name);
return result;
}
int scheduleTask(SYSTEMTIME Time,CString ExeAndPath,CString ArgList,CString name)
{
HRESULT hr = S_OK;
ITaskScheduler *pITS;
USES_CONVERSION;
/////////////////////////////////////////////////////////////////
// Call CoInitialize to initialize the COM library and then
// CoCreateInstance to get the Task Scheduler object.
/////////////////////////////////////////////////////////////////
hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_CTaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskScheduler,
(void **) &pITS);
if (FAILED(hr))
{
CoUninitialize();
return 1;
}
}
else
{
return 1;
}
/////////////////////////////////////////////////////////////////
// Call ITaskScheduler::NewWorkItem to create new task.
/////////////////////////////////////////////////////////////////
ITask *pITask;
IPersistFile *pIPersistFile;
LPCWSTR pwszAccountName = L"";// run as local account
LPCWSTR pwszPassword = NULL;// run as local account
hr = pITS->NewWorkItem(A2CW(name),//pwszTaskName, // Name of task
CLSID_CTask, // Class identifier
IID_ITask, // Interface identifier
(IUnknown**)&pITask); // Address of task interface
pITS->Release(); // Release object
if (FAILED(hr))
{
CoUninitialize();
fprintf(stderr, "Failed calling NewWorkItem, error = 0x%x\n",hr);
return 1;
}
hr = pITask->SetWorkingDirectory(A2CW(ExeAndPath));
if(FAILED(hr)){
CoUninitialize();
fprintf(stderr, "Failed setting Working directory, error = 0x%x\n",hr);
return 1;
}
hr = pITask->SetParameters(A2CW(ArgList));
if(FAILED(hr)){
CoUninitialize();
fprintf(stderr, "Failed setting Parameters, error = 0x%x\n",hr);
return 1;
}
pITask->SetFlags(TASK_FLAG_DELETE_WHEN_DONE);
//run as local acocunt
hr = pITask->SetAccountInformation(pwszAccountName,pwszPassword);
if(FAILED(hr)){
CoUninitialize();
fprintf(stderr, "Failed setting Account Information, error = 0x%x\n",hr);
return 1;
}
/////////////////////////////////////////////////////////////////
// Call IUnknown::QueryInterface to get a pointer to
// IPersistFile and IPersistFile::Save to save
// the new task to disk.
/////////////////////////////////////////////////////////////////
hr = pITask->QueryInterface(IID_IPersistFile,
(void **)&pIPersistFile);
pITask->Release();
if (FAILED(hr))
{
CoUninitialize();
fprintf(stderr, "Failed calling QueryInterface, error = 0x%x\n",hr);
return 1;
}
hr = pIPersistFile->Save(NULL,
TRUE);
pIPersistFile->Release();
if (FAILED(hr))
{
CoUninitialize();
fprintf(stderr, "Failed calling Save, error = 0x%x\n",hr);
return 1;
}
printf("Created task.\n");
hr =CreateTrigger(name,Time);
return 0;
}
int CreateTrigger(CString name, SYSTEMTIME Time)
{
HRESULT hr = S_OK;
ITaskScheduler *pITS;
USES_CONVERSION;
/////////////////////////////////////////////////////////////////
// Call CoInitialize to initialize the COM library and then
// CoCreateInstance to get the Task Scheduler object.
/////////////////////////////////////////////////////////////////
hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_CTaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskScheduler,
(void **) &pITS);
if (FAILED(hr))
{
CoUninitialize();
return 1;
}
}
else
{
return 1;
}
///////////////////////////////////////////////////////////////////
// Call ITaskScheduler::Activate to get the Task object.
///////////////////////////////////////////////////////////////////
ITask *pITask;
hr = pITS->Activate(A2CW(name),//pwszTaskName,
IID_ITask,
(IUnknown**) &pITask);
if (FAILED(hr))
{
wprintf(L"Failed calling ITaskScheduler::Activate: ");
wprintf(L"error = 0x%x\n",hr);
CoUninitialize();
return 1;
}
pITS->Release();
ITaskTrigger *pITaskTrigger;
WORD piNewTrigger;
hr = pITask->CreateTrigger(&piNewTrigger,
&pITaskTrigger);
if (FAILED(hr))
{
wprintf(L"Failed calling ITask::CreatTrigger: ");
wprintf(L"error = 0x%x\n",hr);
CoUninitialize();
return 1;
}
//////////////////////////////////////////////////////
// Define TASK_TRIGGER structure. Note that wBeginDay,
// wBeginMonth, and wBeginYear must be set to a valid
// day, month, and year respectively.
//////////////////////////////////////////////////////
TASK_TRIGGER pTrigger;
ZeroMemory(&pTrigger, sizeof (TASK_TRIGGER));
// Add code to set trigger structure?
pTrigger.wBeginDay =Time.wDay; // Required
pTrigger.wBeginMonth =Time.wMonth; // Required
pTrigger.wBeginYear =Time.wYear; // Required
pTrigger.cbTriggerSize = sizeof (TASK_TRIGGER);
pTrigger.wStartHour = Time.wHour;
pTrigger.TriggerType = TASK_TIME_TRIGGER_ONCE;
pTrigger.Type.Daily.DaysInterval = 1;
///////////////////////////////////////////////////////////////////
// Call ITaskTrigger::SetTrigger to set trigger criteria.
///////////////////////////////////////////////////////////////////
hr = pITaskTrigger->SetTrigger (&pTrigger);
if (FAILED(hr))
{
wprintf(L"Failed calling ITaskTrigger::SetTrigger: ");
wprintf(L"error = 0x%x\n",hr);
CoUninitialize();
return 1;
}
///////////////////////////////////////////////////////////////////
// Call IPersistFile::Save to save trigger to disk.
///////////////////////////////////////////////////////////////////
IPersistFile *pIPersistFile;
hr = pITask->QueryInterface(IID_IPersistFile,
(void **)&pIPersistFile);
hr = pIPersistFile->Save(NULL,
TRUE);
wprintf(L"The trigger was created and IPersistFile::Save was \n");
wprintf(L"called to save the new trigger to disk.\n");
///////////////////////////////////////////////////////////////////
// Release resources.
///////////////////////////////////////////////////////////////////
pITask->Release();
pITaskTrigger->Release();
pIPersistFile->Release();
return 0;
} // End Create Trigger
Thanks,
Brian
|
|
|
|
|
At the end of CreateTrigger() right before Release() is called, have you checked with IScheduledWorkItem::GetNextRunTime() to see if a next-run time actually exists? It may just be a problem with the Scheduled Task applet not displaying it correctly.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am new to mfc. I have created a dialog "mydlg" and want to display it in a Splitted main Frame. How can I create a simple splitted frame?
Thanks in advance
Olgun
|
|
|
|
|
How can I create a simple splitted frame?
if u want to create splitted frame
at the beginning of MFC application wizard select SDI option
and after that at step 5 of 6
select the Base class CView
and create virtual function OnCreateClient() for the class CMainFrame
and intilalize boolean variable at the class and give it false value at hte constructor
after u created it delete all the code of OnCreateClient() function and write this instead
if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )<br />
{<br />
MessageBox( "Error setting up m_mainSplitter", "ERROR", MB_OK | MB_ICONERROR );<br />
return false;<br />
}<br />
if ( !m_mainSplitter.CreateView( 0,0,RUNTIME_CLASS(CLeftView),CSize(255, 0), pContext ) )<br />
{<br />
MessageBox( "Error setting up splitter view", "ERROR", MB_OK | MB_ICONERROR );<br />
return false;<br />
}<br />
if ( !m_mainSplitter.CreateView( 0, 1, RUNTIME_CLASS(CRightView),CSize(0, 0),Context ) )<br />
{<br />
MessageBox( "Error setting up splitter view", "ERROR", MB_OK | MB_ICONERROR );<br />
return false;<br />
}<br />
m_bInitSplitter = true;<br />
return true;
MFC programmer
|
|
|
|
|
m_fuad67 wrote:
if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )
You should probably indicate that m_mainSplitter is a CSplitterWnd object.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|