|
LionAM wrote: is there any other way to find out if the object
pointed to by pt was destroyed?
pt is still valid in your code.
There's no "pointers" here - these are managed references.
You have created a new reference to t by assigning a tracking
reference of t to pt. As long as pt stays in scope it is a
valid Test reference.
You can assign nullptr to references...
Test^ pt;
{
Test t;
pt = %t;
}
pt = nullptr;
if (nullptr != pt)
{
pt->...
}
*edit* I played around with this and with stack based semantics<br />
the destructor is still called as you stated. This behavior makes code <br />
like your example dangerous.<br />
<br />
I'd prefer using all reference semantics if I was going to obtain additional<br />
references, something like
Test^ pt;
{
Test ^t = gcnew Test();
pt = t;
}
delete pt;
pt = nullptr;
That seems clearer to me *shrug*
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Monday, August 18, 2008 3:17 PM
|
|
|
|
|
Thank you.
I see that the local (ref) object is also on the managed heap
- the only difference is that the destructor is called.
In my case, I need the local object because it is a lock
(which has to be destroyed when leaving scope).
Alex
|
|
|
|
|
LionAM wrote: In my case, I need the local object because it is a lock
(which has to be destroyed when leaving scope).
Makes sense. Just for reference, there's other ways to
get the destructor called:
(from <a href="http://msdn.microsoft.com/en-us/library/ms177197(VS.80).aspx">Destructors and Finalizers in Visual C++</a>[<a href="http://msdn.microsoft.com/en-us/library/ms177197(VS.80).aspx" target="_blank" title="New Window">^</a>]):
Code authored in Visual C++ and compiled with /clr will run a type's destructor for the following reasons:
* If an object created using stack semantics goes out of scope.
* If an exception is thrown during the object's construction.
* If the object is a member in an object whose destructor is running.
* If you call the delete Operator (C++) on a handle (^ (Handle to Object on Managed Heap)).
* If you explicitly call the destructor.
If your type is being consumed by a client authored in another language, the destructor will be called when:
* A call to Dispose.
* Calling Dispose(void) on the type.
* If the type goes out of scope in a C# using statement.
Regardless, having a second reference outside the scope is a bad idea and
shouldn't be necessary
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I want to learn graphics programming in c++ .I don't kniw anything in graphics programming .I want to learn it
I know c and c++
Which is the best book that starts from NEWBIE level to MASTERING level .
Thanks
Edit/Delete Message
|
|
|
|
|
Hi all,
I have an application that's pulling data across an ethernet connection. It's ultimatelly coming from an SQL database but I can't access it directly. I have to go through some middle-ware software.
My problem is how to deal with lots of rows. I started with a ListView and could retrieve and display 363189 records in 1 min 54 secs. Not lightning fast but acceptable for my application. However, ListViews can't hide columns easily (as least I couldn't find a way) so I switched to a DataGridView. I've never let it finish inserting 363189 rows as I think it would take hours.
I've tried just manually called addrow (not adding any cell data yet) and using data binding. They seem equivalently slow.
I have 18 columns of data and would like to let the user show/hide whatever they want. Having the column data always present is what I think I'm after. That way I can just set a visible flag true/false.
I think I'm either doing something stupid with the DataGridView or I'm using it in a way that was not intended.
Any thoughts?
Thanks,
Brian
|
|
|
|
|
We've come across a similar case (although not quite as large a scale...) We have 150 possible columns, and usually up to 2000 rows. We keep and array of integers indicating our "visible" columns, and provide the user with a dialog of checkboxes to show/hide columns. For the ListView, "hiding" simply means setting the column width to 0. Any time the set of visible columns changes, we reload all the data, but only for those visible columns.
Probably not the most elegant solution, but it seems to work well for us. Loading data for 5 columns is a heck of a lot faster than loading it for 150!
I'm curious what other solutions people have as well. Always open to better ideas!
[Edit]: After looking back at the code, we actually update our list view by calling list->Clear(), which removes all rows and columns, then re-add any columns we want to show, then fill all our rows. May not be the best way, but it works.
Dybs
modified on Saturday, August 16, 2008 11:39 PM
|
|
|
|
|
Hello everybody!
I'm doing a bit of research concerning the JA2 v1.13 Project http://ja2v113.pbwiki.com/[^]. The source code for this ancient game has been released a couple of years ago. Since then people try to understand, debug and enhance the game. The game is written in C (using DirectDraw) but compiles with VS2008. That's for the introduction.
Since the code is rather unstructured and hard to read and maintain I am looking for a more convenient way of implementing the user interface. This seems necessary because the original developers basicly implemented their home brewn buttons, lists, labels ... but - in my opinion - with questionable success. To avoid a complete rewrite it would be necessary to embed/redirect parts of the DirectDraw canvas into some sort of Windows Forms Control. The icing on the cake would be the ability to overlay this canvas with windows forms controls such as context menus. Is such thing possible?
greetings from Germany
Arne
|
|
|
|
|
Anyone know of a decent Flow Diagram program for Managed C++? I tried using Crystal Flow[^], but it doesn't seem to know what to do with Managed code (i.e. the ^ operator). This doesn't really help much since most of my functions either take a managed type as at least one parameter, or return a managed type. It doesn't recognize the syntax, so it can't generate a flow diagram.
Can Doxygen do anything like this? or the Dot utility in GraphViz that it uses? It does a great job on my call/caller graphs, and inheritance and collaboration diagrams. It'd be great if it could do flow diagrams, too.
I'm looking online now, but just wanted to get people's opinions as well.
Thanks,
Dybs
|
|
|
|
|
I have a com object, created on c++ (using VS2005)
And another c# library that referenced to that object.
When I try to create new object - I get the follows:
Retrieving the COM class factory for component with CLSID {B1901D41-……….} failed due to the following error: 80040111
I googled for that error, and only found it out when using external programs, like Excel, IExplorer, etc.
I’m afraid in one of my tries I destroyed something in the registry…
Can someone help me with my problem? This is driving me crazy…
Moreover, I am looking for a good site who explains clearly about the COM objects, interop, and the correct use of them.
Thanks,
Sara
|
|
|
|
|
Your post might be more useful in the COM forum?
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
|
|
|
|
|
Hello ...
i need help with the sample code given by windows SDK.
there is this AMCAP code they provide.
but there seems to be 5 errors of the same type...
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\ctutil.h(278): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
and the line 278 of ctutil.h displays;
private:
COARefTime (LONG);
operator = (LONG);
};
anyone could help me to solve the error.. or any guidance?
please.
thanks in advance.
-sue.
|
|
|
|
|
How are you building the sample?
You should be using the makefile that's included in the
sample folder. Open a command prompt, run vcvars32.bat
(found in the Visual Studio folders), cd to the sample
folder, and run nmake.
You'll need to build the DirectShow base class libraries
as well (first) I believe (it looks like that sample has
the base classes library as a dependency).
suefyzah wrote: C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\ctutil.h
Also, the current DirectShow SDK is part of the Windows Platform SDK,
not part of the DirectX SDK - it looks like you're using an old version
(pre-2003).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am trying to produce an OEM version of my product without creating a separate branch of the source code. I have everything working with the exception of specifying a different application icon to be used for the executable using a Visual Studio build configuration for the OEM product, preprocessor definitions, and a custom resource language. Is there a compiler switch that I can use to specify a resource file other than app.rc or some other means to do this other than a branch of my existing code?
Thank you for your time.
|
|
|
|
|
|
|
Mark Salsbery wrote: You can host WPF content in a form, however...
You can also buy a Filet-O-Fish at McDonalds. Probably should have told him that.
led mike
|
|
|
|
|
You mean that's not in the posting guidelines yet?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
LMAO, Glad I didn't have a mouth full of coffee when I read that!
led mike
|
|
|
|
|
Hi All,
How does one export a function (not a class) in a managed Dll?
I'm catching a System.EntryPointNotFoundException. dumpbin confirms that the Dll is not exporting the function.
Does not work:
* declaring method as public: error C2059: syntax error : 'public'
* __declspec( dllexport ): incompatible with /clr and /clr:pur
* .def file: fatal link error LNK1310: Exports not supported for pure MSIL image
Thanks,
Jeff
bool Test( array<byte>^ );
bool Test( array<byte>^ a ) {...}
|
|
|
|
|
Wrapping in a public class is one option:
public ref class StaticFuncs
{
public:
static bool Test( array<byte>^ a )
{
...
}
};
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
i want to write a MDI application with 3 child windows. The left and right ones are fixed tool windows. The middle one should be moveable and sizeable between these other to child windows.
But if the user would maximize the middle Window it would maximize the the hole client area.
I tried something like that:
System::Drawing::Size szMax;
szMax.Width = 500;
szMax.Height = 300;
_middleChildWindow_->MaximumSize = szMax;
Rectangle boundRect(100, 10, 200, 200);
vcHG->MaximizedBounds = boundRect;
but I get following error
error C3767: "System::Windows::Forms::Form::MaximizedBounds::set": Auf mögliche Funktion(en) kann nicht zugegriffen werden.
(means the function cant be accessed)
Why is that? The function is protected so I should be able to access it.
I also don´t know how to prevent the user from moving the middle window over the other child windows.
I would appreciate any help
Thanks
|
|
|
|
|
Kyon86 wrote: vcHG->MaximizedBounds = boundRect;
but I get following error
error C3767: "System::Windows::Forms::Form::MaximizedBounds::set": Auf mögliche Funktion(en) kann nicht zugegriffen werden.
(means the function cant be accessed)
I have no idea what type vcHG is but the following code compiles for me in VS2005 where this is a System::Windows::Forms::Form
System::Drawing::Rectangle rect(10,10,10,10);
this->MaximizedBounds = rect;
led mike
|
|
|
|
|
I want to have registry access in limited user account in windows xp.
Could any one please help me
Thanks
Gayatri S
|
|
|
|
|
Run regedit.exe as an Administrator from within the limited user account.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
|
|
|
|
|
First off you are in the wrong forum. None of your questions are about managed or mixed mode development which this forum is intended for as one might see if they READ the first message in the forum.
Second, one interpretation of your collection of posts is that you believe the way to learn about subjects is to ask people in internet forums to teach them to you. In my opinion this about the worst way to attempt learning a subject. A more efficient method would be to read the documentation or even buy a book that covers the subject. Also there is a mountain of articles and blog entries on the internet that might provide introductory type explanations of subject. One can happily find them by using Google to search for them. There are actually a lot of these articles on CodeProject, the CodeProject articles are a primary purpose of this site. Look through the "CHAPTERS" menu on the site. Then once you have at least a beginner level grasp of the subject people in forums might be able to help you with specific problems if/when you get stuck on something.
led mike
|
|
|
|