|
To reverse the effect of the first cast, cast the value back to the original type:
Instrument *instObject = (Instrument*) treeCtrl->GetItemData(hItem);
|
|
|
|
|
hey its not working ...
otherwise i would have done that ...
|
|
|
|
|
Then you've obviously done something else wrong, as Michael's suggestion is correct. How are you verifying that it does not work?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm guessing you are getting cannot convert DWORD_PTR to Instrument *.
Oh and allways try and use eplicit casting i.e. static_cast rather than C-Style casts.
Try this
Instrument *instObject = static_cast<Instrument *>((static_cast<void *>(treeCtrl->GetItemData(hItem))));
or if not
Instrument *instObject = dynamic_cast<Instrument *>((dynamic_cast<void *>(treeCtrl->GetItemData(hItem))));
Could you copy the exact compiler error into the thread.
|
|
|
|
|
reinterpret_cast is the right one for this situation, since you're converting between a pointer and a non-pointer type.
|
|
|
|
|
oh sorry its working now ... it was my mistake ...
Thanks a lot ...
|
|
|
|
|
Hi,
in the process of running my program is allocating a lot of memory (gigabytes). After it reaches a certain size strange things start to happen so I'm trying to debug it. I have some questions.
1. To my surprise new operator does not return NULL on error. It seems to throw an exception. When did this happen? What's the exception object? I'm using VS 8.
2. Is new a thread safe operator? What if I'm using some libraries that most likely use malloc. Is memory allocation still thread safe? I'm using dynamic link run time for my program and hopefully all the libraries. If some library is using a different run-time but I don't free its memory is that fine?
3. What is the memory allocation limit for a process in Windows XP? Is it 2 GB? Or RAM + swap space?
4. Any free GUI profilers out there?
Thanks for your help.
|
|
|
|
|
Budric B. wrote: To my surprise new operator does not return NULL on error. It seems to throw an exception. When did this happen?
I thought it was a lot longer ago, but according to the docs:
"In Visual C++ .NET 2002, the new function in the Standard C++ Library will support
the behavior specified in the C++ standard, which is to throw a std::bad_alloc exception
if the memory allocation fails. In Visual C++ 2005, the C Runtime Library's new function will also throw a std::bad_alloc
exception if the memory allocation fails.
If you still want the non-throwing version of new for the C Runtime Library, link your program
with nothrownew.obj. However, when you link with nothrownew.obj, new in the Standard C++
Library will no longer function."
Budric B. wrote: 2. Is new a thread safe operator?
In the Multithread CRT, Yes. Any third-party library, well...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sounds to me like you have some serious memory leakage. Make sure you call delete on every time you allocate using new.
Try this[^] utility, it's excellent for finding leaks.
As for your questions:
1. use try catch blocks.
2. yes.
3. Usually RAM, but not too sure...
4. www.google.com
Waldermort
|
|
|
|
|
Budric B. wrote: 1. To my surprise new operator does not return NULL on error. It seems to throw an exception. When did this happen? What's the exception object? I'm using VS 8.
That's the way it is supposed to work - it throws bad_alloc. If you want to get a NULL instead, use nothrow[^]
Budric B. wrote: 2. Is new a thread safe operator? What if I'm using some libraries that most likely use malloc. Is memory allocation still thread safe? I'm using dynamic link run time for my program and hopefully all the libraries. If some library is using a different run-time but I don't free its memory is that fine?
Yes. Yes. Yes.
Budric B. wrote: 3. What is the memory allocation limit for a process in Windows XP? Is it 2 GB? Or RAM + swap space?
In practice, less then 2GB[^] (BTW, who would vote down that text and why )
Budric B. wrote: 4. Any free GUI profilers out there?
Try GlowCode.
|
|
|
|
|
thanks for the heads up on the flag, I'll try it with my code.
|
|
|
|
|
Hello, I wanted to know if there's a way to embed databases into an executable file. How do you do it (I'd really appreciate it if you explain the way for both Sql Server and MySql, if they're different ways)? Is it recommended?
Thanks.
Perrin.
|
|
|
|
|
The engine ? Me think not really, but i'm no DB expert.
|
|
|
|
|
What I mean is to have a resulting exe that does not depend on the server (MySql or SQL Server) being installed in the user's computer, but still makes use of those databases.
|
|
|
|
|
SQL Server 2005 Express apperently can be embedded with an application. Look for the details at MSDN.
As for MySQL, it is easy: Embedded MySQL[^]
|
|
|
|
|
|
Hi everybody,
is it possible to get the console cursor position?
To set it, it works with SetConsoleCursorPosition(...)
Any ideas?
Thanks
|
|
|
|
|
|
Sh*** LOL
The first thing that i checked was GetConsoleScreenBufferInfo()
but i'v not seen the dwCursorPosition
Thanks for you help
|
|
|
|
|
No problem ....happens to me more than I care to admit.;)
|
|
|
|
|
I want hide or disable MyComputer or drives of the computer so that, after restarting the computer , MyComputer or drives is restored to normal state (visible/enable)
can any body help me?
H.R
|
|
|
|
|
you can hide MyComputer from the desktop or from the start menu by doing the following :
user key:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\
NonEnum]
sys key: [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\
NonEnum]
name: {20D04FE0-3AEA-1069-A2D8-08002B30309D}
type: REG_DWORD (Valeur DWORD)
value: (0 = show, 1 = hide)
|
|
|
|
|
Is there any API getting the filename and subfolder on a Folder?
|
|
|
|
|
Yes. Use the FindFirstFile() /FindNextFile() pair, or the CFileFind MFC class.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In case you are looking for sdk api, you can use FindFirstFile and FindNextFile.
|
|
|
|