|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
u expect to see
(LPBYTE) foo = 9180016 and its true.. remeber m_buff is a ptr, so just check its address (using &m_buff). Hope u will see it is same as (LPBYTE)foo Means m_buff is just a ptr which holds an address somewhere in heap.
And while printing (LPBYTE)foo it provides garbage, because both foo & m_buff is dynamically allocated, so we can never say where they r in heap. To become more clear make m_buff an array, say m_buff[10], then (LPBYTE)foo will print 0123.. as u expected. Also see (void*)&m_buff = (void*)foo Hope now things are clear to u..
|
|
|
|
|
I'm clear that m_buff is a pointer, and what I want is for (LPBYTE) foo to point to the same place m_buff points, not to point to m_buff itself.
My class uses the buffer size to sometimes have m_buff point to a dynamically allocated BYTE array and sometimes point to a MMF, but to allow the given buffer to be accessed as an LPBYTE regardless of the buffer 'implementation.'
It seems, though, that (LPBYTE) foo gives a pointer to the testClass object, rather than the memory pointed to by m_buff .
I think I said it in the original post, but I could accomplish this easily with a member function like
LPBYTE getBuff() { return &this->m_buff[0]; };
..but I thought this was a good opportunity to learn about operator overloading.
Thanks!
MZR
|
|
|
|
|
As Moak said, try :
cout << foo->LPBYTE()[0]; virtual void BeHappy() = 0;
|
|
|
|
|
This:
LPBYTE bar = foo->operator LPBYTE();
for (int i = 0; i < 10; i++)
cout << bar[i];
cout << "\n";
Gives the expected output
0123456789
....it's like my overloaded operator isn't being called when I try to explicitly cast to (LPBYTE) .
|
|
|
|
|
Very good
And now, as Moak said, try :
LPBYTE lpOut = *foo;
cout << lpOut[0]; virtual void BeHappy() = 0;
|
|
|
|
|
hi,
i have a char array in which i m getting path of current module.i want to convert it into string before loading it.hw can i do that?
|
|
|
|
|
You actually asked this question 10 minutes ago in C# forum.
If you want to convert char array to string in C++ you could use:
1) The constructor of std::string - here[^].
2) The assignment operator of std::string - hete[^].
Example:
const char* szChars = "ABCD";
std::string strFromChars(szChars);
std::string strFromChars;
strFromChars = szChars;
|
|
|
|
|
char arr[MAX_PATH];
std::string str = arr; OR
wchar_t arr[MAX_PATH];
std::wstring str = arr; OR
TCHAR arr[MAX_PATH];
CString str = arr;
|
|
|
|
|
Which type of string you mean.?
CString or std::string?
for CString---
CString strPath(szPathName);
for std::string--
const char* szPathName;
std::string strPath;
...
szPathName = "c:\\Test";
strPath = szPathName;
|
|
|
|
|
thanx all and nuri ismail i mistakenly posted in c# forum i m doing it in vc++
|
|
|
|
|
|
The given link works fine for me.
Maybe you should try again and if you have no success I'll send you the downloaded code.
Regards
|
|
|
|
|
Nope, still not working
I can download C# and Java examples, but C++ lib that I need is "silent"
Must be than some odd firewall rule, or something by my side. I though that maybe link was wrong...
If it's not too much bother, please send me the lib!
|
|
|
|
|
I've just sent the lib to your mail.
|
|
|
|
|
Thank you very much, you are the man!!!
Best regards,
Kresimir.
|
|
|
|
|
You're welcome!
|
|
|
|
|
is there any microsoft provided mfc class to fetch data from xls file Trioum
|
|
|
|
|
nope
But this link will help you achieve your task [^]Величие не Бога может быть недооценена.
|
|
|
|
|
try . odbc Failure is Success If we learn from it!!
|
|
|
|
|
Genarate wrapper classes for Excel type library. Select 'MFC class from TypeLib' option while adding a class. Select 'From file' radio btn and browse for excel type library. For MsOffice 2003 & 2007 type library is in Excel.Exe itself, for older versions it may vary. see how to use the generated classes http://support.microsoft.com/kb/186122[^]
|
|
|
|
|
but problem is that it always open new file I want to read data from a excel which is already open Trioum
|
|
|
|
|
don't worry as long as there is GetActiveObject() API, u can get the running instance of excel and handle the sheets already opened in it . Have a look at http://support.microsoft.com/kb/238975 and
http://support.microsoft.com/kb/196776modified on Wednesday, March 17, 2010 10:54 AM
|
|
|
|
|
Still doing lot of r&d I am not able to get that excel object to read values of cells Trioum
|
|
|
|