|
Your first mistake is to write it in VB.Net
Seriously,
at first sight it seems ok. Could you check whether the VB.Net '>>' is equal to the c/c++ '>>'.
Because the c/c++ '>>' behaves differently used on a signed variable then on a unsigned variable.
Shift right with 8 is equal to divide by 256 if i'm not mistaking. So you could replace
mCheckSum >> 8 by mCheckSum / 256
Hope that his helps
codito ergo sum
|
|
|
|
|
Hi Thanks for this. I do get a different result with /256 and >>8 but neither are right. It's very difficult to debug because I have nothing to check at any part of the process!
I'm thinking if I put the C++ into a project and got it working in VS2005, then I could step through it, and that would surely get me to the answer, because i could watch it step by step.
Sadly, I have never used C++ before so I wouldn't know how to get it running in a project (even). How sad for us VB developers, been shielded for too long from the real problems of prgramming!!
Thanks for your help, there must be a walkthrough I can find to get the check_sum routine running. See - I wouldn't know how to pass in the file_ptr, even though I have the files that this solution intends to use!!
|
|
|
|
|
Hi,
I'm sorry i didn't think thought of this in my previous reply.
But I think i have found a problem in your code.
The c code uses an unsigned integer (32 bit) wich ranges from 0 - 4294967295.
The vb code uses for the same data a long value (32 bit) but this is a signed value, hence the range is from -2,147,483,648 to 2,147,483,647.
This could lead to some unpredictable results when shifting or dividing.
Maybe you could use a Double instead of a Long to hold the checksum, but im not sure about it. I will try to test this.
codito ergo sum
|
|
|
|
|
Hey BadKarma. I really appreciate your efforts but this didn't help.
I set about trying to get the C++ code working in VS.NET, and I'm tearing my hair out with it!! I got so close, and it was building okay, then I had to read in from a text file. I thought this would be easy, particularly as Microsoft provided a very useful walkthrough. But no matter where I put this line of code;
StreamReader *objReader = new StreamReader("c:\\test.txt");
I get this error;
C3699: '*' cannot use this indirection on type 'System::IO::StreamReader'
I am 'using' System::IO and System::Collections in the header file but this error means I cannot compuile and therefore go any further. I got so close too!
It must be something relatively simple but I am totally unfamiliar with managed C++ (or any C++).
If you can help me to read up from my text file, I will be able to watch the original C++ code in action which will enable me to work out whats going on.
Yours gratefully
Richard
|
|
|
|
|
I'm not familiar with Managed C++, but i think that when using managed types like the StreamReader you can't use pointers (*), you should use a handle/reference/managed pionter (^) or wathever they call it.
The following should work
StreamReader ^objReader = new StreamReader("c:\\test.txt");
or
StreamReader ^objReader = gcnew StreamReader("c:\\test.txt");
-- modified at 13:56 Friday 9th November, 2007
codito ergo sum
|
|
|
|
|
Try to debug and go step by step if everything does what you are expecting them to do. Isolate where the problem is, and if you don't know why... ask more specifically. You will have a faster/better answer
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Yes, you're right. I received the C++ code in a text file and I hope to get it running in VS2005 somehow. Thanks very much, I'm off to find a walkthrough!
Rich
|
|
|
|
|
<br />
_ConnectionPtr* CEGraphApp::GetConn()<br />
{<br />
return &m_pConn;
}<br />
error info:
Compiling...
EGraph.cpp
C:\EGraph\EGraph.cpp(154) : error C2440: 'return' : cannot convert from 'struct _Connection ** ' to 'class _com_ptr_t<class _com_iiid<struct="" _connection,&struct="" __s_guid="" _guid_00000550_0000_0010_8000_00aa006d2ea4=""> > *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
amazing...
I think it should be right anyhow.
-- modified at 9:18 Tuesday 6th November, 2007
|
|
|
|
|
if m_pConn is declared with _ConnectionPtr *m_pConn
then your return statement should be : return m_pConn; without the & operator
|
|
|
|
|
Sorry, a typing error
m_pConn is declared as _ConnectionPtr m_pConn
|
|
|
|
|
and what is _ConnectionPtr defined like ?
|
|
|
|
|
It's a type in ADO.
What's in msado15.tlh:
<br />
_COM_SMARTPTR_TYPEDEF(_Connection, __uuidof(_Connection));<br />
I think it's not for reading.
|
|
|
|
|
It is smart pointer, I think you should define function like this:
_ConnectionPtr CEGraphApp::GetConn()
{
return m_pConn;
}
don't use pointers to smart pointers
rrrado
|
|
|
|
|
It is ok. I suppose returning a pointer is more efficient.
|
|
|
|
|
I'ts against COM philosophy. You are giving away reference to object without incrementing reference count. Any query you execute on that connection is 1000x slower than creating new smart pointer which calls AddRef and Release on destruction.
rrrado
|
|
|
|
|
Hello All,
I prepared a SDI application by using MFC and Directx 3D now i have to add functionality of print.
for that i am using print command which is default provided by editor it shows print diaolog and command fire to the printer also but i am not getting any contents or picture printed out. printer out a blank paper.
can anybody tell me what i have to do for taking printout of which is shown into the view area of my application.
thanks
Bankey
|
|
|
|
|
Have you had a look through the C++ / MFC Printing article section here on Code Project?
|
|
|
|
|
The principles are "simple", get a DC to the printer device and send the datas to it like you make with your View.
The things complicate themselves a bit because the every printer is different (I mean that it is quite easy to get output to the screen, but to ensure the output to any printer... could be hard work).
I guess that you are missing to do things in Device-Independant mode and/or missing the correct MAPMODE.
Take a look in the articles of the printing section (I personally like articles from Roger Allen and Joseph M. Newcomer)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hello,
i am trying to attach an dialog to Document/View application? but i
cannt,
how can i attach the dialog to the Document? is there a way?
thanks
|
|
|
|
|
What do you mean by attach ?
|
|
|
|
|
Hello,
by default, I want My dialog to be displayed in the place of the view,
i never done it before, that is why i used the word "attach".
Is it possible to do?
thanks
|
|
|
|
|
Dialog in Dialog is support by MS.
Dialog in a View seems not supported by MS.
You can make a copy from the dlg to the view, that's totally possible.
|
|
|
|
|
Are you wanting to have a CFormView ?
|
|
|
|
|
I dont know what is CFormView, so, i dont know what u mean, could u explain me? thanks
|
|
|
|
|
CFormView is a CView derived class that has CDialog aspect, you can use it like a Dialog in your resources adding controls like EditBoxes, Buttons... The big difference is that CFormView has almost all the Doc-View relations by default and you don't have to complicate yourself replacing a view with a dialog.
I suggest you to create a new Project, in the last step of wizard select CFormView as the base class for your CMyAppView and make test on your own. You can always ask when you stuck in something.
Take a look in your documentation to read what CFormView is would not be a bad idea as well.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|