|
The parameter to the CloseDialog call (via your function pointer) is 'this ', or do I miss something?
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Hi all,
i am generating a word report using OLE Automation.It has all the things that a Detailed report can have from Header to footer.I am using mail merge to populate the data in the report.This data i am fetching from an access database.
My problem is with table of contents.The main document with all the fields contain the table of contents.This table of contents is not being merged
in the new merged document.It is displaying it like a normal text (not TOC Field) and showing values with mergefields name(not values) in the headings(the headings do have some mergefields in them).
Did anybody work on similar thing.
Please help me regarding this.
|
|
|
|
|
Hi,
How can I convert an int (or a double) to a CString, wich contains a hex value.
Example:
I've got an int, called 'a', with value 33.
And I need to get a String with the hexadeciaml value of 'a', wich means (in this case) that I need a CString containing "21".
Do you know wether is some fkind of function for this???
Thanks
|
|
|
|
|
Here you go.
As always thrown together and untested but should work.
int nValue = 33;
CString str;
str.Format("%x", nValue);
There are 10 types of people in the world
Those who understand binary, and those who don't
|
|
|
|
|
|
Hiya,
int a =33;
CString lHexValue;
lHexValue.Format("%x",a);
Cheers
Loz
|
|
|
|
|
Hey u can use this :
long str2hex(char *str)
{
long hwnd=0;
char ch;
::CharUpperBuff(str,8);
for(int i=0;i<8;i++)
{
ch = str[i];
if(ch>=48 && ch<=57) hwnd+=(ch-48)*1<<(4*(7-i));
else if (ch>=65 && ch<=70) hwnd+=(ch-65+10)*1<<(4*(7-i));
}
return hwnd;
}
-Vladimir India
|
|
|
|
|
What is wrong with this:
template <int I_location, class T_bound1, class T_bound2, class T_functor>
inline bind_functor<I_location, typename unwrap_reference<T_bound1>::type,
bind_functor<I_location?I_location+1 , typename unwrap_reference<T_bound2>::type, T_functor> >
bind(const T_functor& _A_functor, T_bound1 _A_b1, T_bound2 _A_b2)
{
return bind_functor<I_location, typename unwrap_reference<T_bound1>::type,
bind_functor<(I_location?I_location+1 ), typename unwrap_reference<T_bound2>::type, T_functor> >
(bind<(I_location?I_location+1 )>(_A_functor, _A_b2), _A_b1);
};
The compiler error message is:
error C2143: syntax error : missing ',' before '<end Parse>'
Thanks!
|
|
|
|
|
Where is "end Parse"?
Kuphryn
|
|
|
|
|
That's the funny thing, there isn't such a string in there...
|
|
|
|
|
How to Add/remove the Dialog caption and border at run time?
TIA
|
|
|
|
|
Change window style (GetWindowLong/SetWindowLong)
|
|
|
|
|
Hi there
Can anyone advise.
I have a class called Employee ok.
Now i want the user to create employees by adding
a name, empid and so on.
Creating an Employee object
// Employee *NewEmp = new Emp ??
I want the new employees details in a file .dat it keeps
on creating one employee overriding the previous info.
How can i create more than one employee
Hit me over the knuckles if im way of!
Am i using new wrong? or am i missing the hole new
concept totaly
thanks
|
|
|
|
|
if your class is written with contructor
Employee::Employee(CString strName, int iAge)
{
this->m_strName = strName;
this->m_iAge = iAge;
}
you probably could initiate your object as such
Employee *pEmp = new Employee(_T("Someone"), 22);
these are basic, man
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
See my previous post regarding CArray. Simply create your employees in a CObArray and call the Serialize member function of the CObArray with a valid CArchive. This will alloy you to read and write your array with minimal amount of code.
|
|
|
|
|
bhangie wrote:
// Employee *NewEmp = new Emp ??
I assume you meant Employee *NewEmp = new Employee ?
bhangie wrote:
I want the new employees details in a file .dat it keeps
on creating one employee overriding the previous info.
So do you have something akin to:
for each employee in list
{
open .dat file
write employee info to file
close .dat file
} In other words, after writing all employees to the .dat file, what one employee is in the file: the first one in the list or the last?
bhangie wrote:
Am i using new wrong? or am i missing the hole new
concept totaly
You are using it correctly. However, at this point, there is no way to know if your design is sound.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Why does more and more memory being allocated when running following function again and again:
void TestFunc()
{
CTaskData data; // My Own class
CArray<ctaskdata, ctaskdata&=""> arrData;
arrData.Add( data );
}
// Should not all memory be freed?
--------------------
// My Own class
class CTaskData : public CObject
{
DECLARE_SERIAL (CTaskData)
public:
CTaskData() {}
virtual ~CTaskData() {}
CTaskData( const CTaskData ©Data ) {
m_iDays = copyData.m_iDays;
m_oleTimeStart = copyData.m_oleTimeStart;
m_strName = copyData.m_strName;
}
virtual void Serialize(CArchive& ar);
CTaskData& operator=( const CTaskData ©Data ) {
m_iDays = copyData.m_iDays;
m_oleTimeStart = copyData.m_oleTimeStart;
m_strName = copyData.m_strName;
}
public:
CString m_strName;
int m_iDays;
COleDateTime m_oleTimeStart;
};
APe
|
|
|
|
|
Use std::vector instead. Vector is more efficient in memory management.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thanks.
I've had my plans doing that. You convinced me.
APe
|
|
|
|
|
Just a reminder.
One disadvantage of using the vector is that you can't serialize your object in the vector like the way you do it in the CArray or CObArray
Cause vector do not inherit the CObject.
with CArray/CObArray, you could do something like this in your Serialize function of your CDocument class without much effort.
void CYoutDoc::Serialize(CArchive& ar)
{
m_oaYourArray.Serialize(ar);
}
In the code above, each object in oaYourArray is being serialize one by one to CArchive. Of course, provided that the object you store in the oaYourArray has Serialize function overrided. It is almost effortless.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
OK.
does
m_oaYourArray.Serialize(ar);
work if I use CObject* in the array?
Thanks for your replys.
APe
|
|
|
|
|
No need to be CObject. Just make your object inherit CObject.
eg.
class CYourClass : public CObject
{
....
Serialize(...)
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I nearly thought if there should bee problems if I used CObject* (pointer) or inherited ones.
APe
|
|
|
|
|
It is difficult for me to explain bit by bit the detail of this but I could recommend you a book.
Try the SAMS publishing book.
"Learning Visual C++ 6.0 in 21 days"
The CArchive tutorial in chap 12. It should clear your doubt.
Although this is a not the best book for learning MFC but it is a good jump start for newbie.
Hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I usually use CObArray which would avoid constant copying of your data and will permit serialization.
<br />
CObArray arrData;<br />
<br />
CTaskData * pData =new CTaskData;<br />
...<br />
arrData.Add(pData);<br />
<br />
...<br />
<br />
for ( int nObj = 0; nObj < arrData.GetSize(); nObj++)<br />
delete arrData[nObj];<br />
<EDIT>I do not mind being voted down but please explain why </EDIT>
|
|
|
|