|
Christian Graus wrote: That would explain it. I hate VC6...
Don't be surprised, I just fetched out this thread. I remembered you asking this question hence...
Well I am working in VC6 now so I did enable the "Tip of the Day" dialog. I just saw a tip saying that if you wish to goto a particular line you can press Ctrl + G . I don't know whether you knew this or not. Just trying to help.
It's a pretty useful dialog. Got lots of other options too (as if you don't know ).
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Hi
I used the md5 program described here http://www.codeproject.com/cpp/cmd5.asp in a dll
the output is supposed to be the hash of the current date is stored in the registry.
I'm pretty sure I'm doing something idiotic right here.
HashDate(SYSTEMTIME Date, CComBSTR& bstrHashValue)
{
CMD5 md5((const char *)& Date);
bstrHashValue += _bstr_t( md5.getMD5Digest());
}
Any insight is appreciated
thanks
|
|
|
|
|
I think you should translate the date to a string using CTime::Format(...) method and call the MD5 constructor with that string. Good luck and good coding!
|
|
|
|
|
thanks for your tip
turns out i wasnt doing anything wrong i was just testing it wrong.
i'll punch myself now
|
|
|
|
|
Hi all,
I've recently gotten VC++ 2005 and am having problems with the CString class. Here three examples and the errors I'm getting:
1.
AfxMessageBox("some text"); //none of the 2 overloads could convert all the argument types
2.
void MyFunction(int i, CString str);
...
MyFunction(1, "some text"); //cannot convert parameter 2 from 'const char [4]' to 'CString'
but
CString str;
str = "some text";
MyFunction(1, str); //works fine
3. Also, the declaration
CString str = "some text";
does not work. The error message is:
error C2440: 'initializing' : cannot convert from 'const char [26]' to 'ATL::CStringT<basetype,stringtraits>'
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> Constructor for class 'ATL::CStringT<basetype,stringtraits>' is declared 'explicit'
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
Anyone can tell me if there was a change to the CString class? Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
IIRC, VS2005 uses Unicode for new projects for default, so try:
AfxMessageBox(L"Some text");
Basically, insert L before your strings (to indicate it is a Unicode string), or change your default project settings to MBCS.
|
|
|
|
|
I would use the _T macro from <tchar.h> . i.e.
AfxMessageBox(_T("Some text"));
This way you can build ANSI or UNICODE builds without altering the code.
Steve
|
|
|
|
|
Indeed, but, personally, I only ever build for Unicode - using the UnicoWS library for (dwindling) Win9x support.
|
|
|
|
|
Thanks for the replies. Got the code up and running.
ralf.riedel@usm.edu
|
|
|
|
|
Does anybody know how to display left-aligned text and right-aligned image button in one subitem for CListCtrl?
Thanks.
denyi01
|
|
|
|
|
You got to draw them on the subitem.
Take a look at NM_CUSTOMDRAW .
Nibu thomas
Software Developer
|
|
|
|
|
Hi Thomas, can you explain a little more detail? Thanks.
|
|
|
|
|
How to have left-aligned text and right-aligned image button in one cell for list control (CListCtrl), LVCFMT_BITMAP_ON_RIGHT doesn't help.
Any help is appreciated.
Thanks.
denyi01
|
|
|
|
|
be careful while posting the question that is not posted previously
Knock out "T" from CAN'T
You 'CAN' if you think you 'CAN'
|
|
|
|
|
This is CxImage library question. For starters - I am asking you to refrain from discussion about virtues of other methods, please.
This library is officially no longer supported by the author. So I am asking general audience for help.
I need to convert the CxImage back to CDib. CxImage class has pDib member to do just that – however – I cannot figure out how to use pDib to accomplish that. The assertion is OK but my function fails with “illegal pointer passed”.
I am not including my code because I do not want to waste space. I’ll be happy to provide code for whoever knows something about CxImage and can help me.
Thanks for understanding.
Vaclav
|
|
|
|
|
What about GetDIB()? Thats all you'd need if you're using for StretchBlt or equiv. I've used CxImage quite a bit.
--
Joel Lucsy
|
|
|
|
|
I have a problem overloading the = operator. I think the problem is that after the assignment the array member data gets deleted by a call to the dtor. Then when dtor is called at the end of the program the array has already been deleted and i get an error. how to i overcome this. heree is my code...
<br />
<br />
class A {<br />
private : int* data;<br />
public : <br />
A() { data=new int[5] <br />
~A() { delete data; }<br />
A& operator =(const A &a)<br />
{ <br />
if (this == &a)<br />
return *this;<br />
for (int i=0; i<5; i++)<br />
data[i] = a.data[i];<br />
return *this;<br />
}<br />
.......<br />
<br />
main()<br />
.....<br />
A temp1;<br />
A temp2;<br />
cout << temp1 << endl;<br />
cout << temp2 << endl;<br />
temp1=temp2;<br />
cout << temp1 << endl;<br />
.....<br />
|
|
|
|
|
bilbobaggio wrote: I think the problem...
What problem?
bilbobaggio wrote: ...i get an error.
What error?
bilbobaggio wrote: ~A() { delete data; }
Use delete[] instead.
There's also a missing semicolon at the end of the class.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
ok, sorry for not indenting and explaining myself properly. i have the missing semicolon and am using delete []. when i run the program. the values from temp2 get copied to temp1 and this gets displayed. but then when the program exits i get a 'Debug Assertion failed error - file: dbgheap.d, line:1017,
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
When I debug the application I see that the A dtor gets called after the assignment operation which removes the reference to the array data. So when the program exits and the destructor is called again it gives an error. But i dont know why this is happening or how to overcome it. here is my code sample
extern int y;
class A {
private:
int* data;
public:
A() { data = new int[5]; for (int i=0; i<5; i++) data[i]=y+i; }
~A() { delete [] data; cout<<"a dtor"<<endl; }
A& operator= (const A a);
friend ostream& operator<< (ostream& out, const A &a);
};
A& A::operator =(const A a)
{
if (this == &a)
return *this;
for (int i=0; i<5; i++)
data[i] = a.data[i];
return *this;
}
ostream& operator<< (ostream& out, const A &a)
{
for (int i=0; i<5; i++)
out << a.data[i] << " ";
return out;
}
then the main
void main()
{
y=1;
A temp1;
y++;
A temp2;
cout << temp1 << endl;
cout << temp2 << endl;
temp1=temp2;
cout << temp1 << endl;
}
the program output is as follows
1 2 3 4 5
2 3 4 5 6
a dtor
2 3 4 5 6
then the error.
|
|
|
|
|
bilbobaggio wrote: A& operator= (const A a);
Your assignment operator should take a reference as argument, like this:
A& operator=( const A& a ) The way you've implemented it, when the operator= function is called a copy will be created on the stack. Since you don't have a copy constructor the stack copy will be a shallow copy, i.e. the stack copy's data member will point to the same location as temp2 in main(). The allocated data will be deleted by the stack copy dtor. The error occurs when temp2 dtor is called since the memory already has been deleted.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Roger Stoltz wrote: Your assignment operator should take a reference as argument...
Which is odd because that is what he had in the original code snippet. It really irks me when folks try and type code snippets into their posts rather than use copy/paste.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hmm, I saw that now when you mentioned it.
I just read your reply earlier and since you asked him for more info I figured I rather read the second post of his.
Well, given his explanation about the error it could be the assignment operator declaration and that his first post was erroneous.
--
Rog
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
There is no indentation - If you want people to help you make it easy for them be including formatting in your code. Apart from that, I can't see anything wrong (beyond the already mentioned fact that you're using delete instead of delete [] ). Looks like you'd be better off using a std::vector or std::valarray to me.
Steve
|
|
|
|
|
I noticed that in VS 2005, the return values of GetCount method of CList and CArray and their derived classes are of INT_PTR. I am wondering why INT_PTR not int or long? To me, that is getting messy of MFC 7.0 or higher in dealing with data types.
Thanks.
-- modified at 16:05 Tuesday 28th March, 2006
|
|
|
|
|
yellowine wrote: I am wondering why INT_PTR not int or long?
In basetsd.h , it is defined as an int (or __int64 ).
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|