|
I am writing a C++/CLI CLR Windows Forms application.
I'm able to write lots of evaluation programs and try out many features but I'm having trouble understanding how to architect my total application scope-wise.
I have one main form ( call it "Form1" ) and it may spawn some modal dialog boxes. In addition I want to create some classes, preferrably managed ref classes and refer to their methods and invoke their member functions from the event functions in Form1 (e.g. Form1_Load, button1_Click, etc.).
I'd like to code these ref classes in separate files. I also have an assembly from a third party which I've been able to use successfully (Galil motion controls DMCdNet.dll).
So my question: Is their a canonical way of coding managed C++/CLI ref classes in separate files in my Visual Studio project, instantiate those managed class objects (somewhere) and then be able to refer to them in the private member (event receiver) functions in Form1.h?
The books I've learned C++ from are:
- C++: How To Program by Deitel & Deitel (very early edition)
- Pro Visual C++ /CLI and the .NET Platform by Stephen G. Fraser
Jeff Cooper
modified on Friday, May 23, 2008 10:30 AM
|
|
|
|
|
aa1ww wrote: but I'm having trouble understanding how to architect my total application scope-wise.
That only means you have not yet studied Object Oriented Programming well enough yet. It does take time so don't get discouraged. However most if not all of the issues you seem to be asking about are covered in the classic Design Patterns book.[^] Most if not all of these patterns can also be seen in some level of detail on Wikipedia. And of course there are a multitude of other sites as well that discuss Patterns.
Just to be clear there may not be anything specific to C++/CLI about your question, the answer you seek is a combination of fundamental C++ file management, .NET Platform fundamentals and Object Oriented Design. The bad news is there is no short cut to understanding the information. You must study it all until you have a sound grasp of all the concepts. Anything short of that will leave you constantly running into problems that you don't understand if you start trying to work on a production project.
led mike
|
|
|
|
|
I'm sure I don't have my arms around the design idioms one might choose from but some of the architecting does indeed seem to be Visual C++ & C++/CLI dependent.
Some examples of this:
- Form1 is instantiated and launched by Application::Run
which is passed a managed Application Context handle.
So that requires an understanding of the specifics of
the Application class. Would the descriptions in the
"Design Patterns" book take that mechanism into account?
- Managed classes cannot be instantiated at global file scope.
This isn't as high-level a concept but it impacts
the implementation as creating a lot of nonmanaged objects
misses the advantages of the managed heap and creates a lot
of messy typecasting and patching code bewteen the user
defined nonmanaged classes and the managed Windows Forms
classes.
I'll look at Wikipedia. I was hoping that a few very common patterns more complicated than example programs but still idiomatic and popular might be in the code extant. I'll keep looking.
Coop
Jeff Cooper
|
|
|
|
|
aa1ww wrote: but some of the architecting does indeed seem to be Visual C++ & C++/CLI dependent.
Not tying to be mean but I suggest you stop using the word architecture until you have a better grasp on Object Oriented Design.
aa1ww wrote: Some examples of this:
- Form1 is instantiated and launched by Application::Run
which is passed a managed Application Context handle.
So that requires an understanding of the specifics of
the Application class.
As I stated in my last post, that is an aspect of the .NET Platform and the .NET Framework, it is NOT specific to C++/CLI.
led mike wrote: Just to be clear there may not be anything specific to C++/CLI about your question, the answer you seek is a combination of fundamental C++ file management, .NET Platform fundamentals and Object Oriented Design.
aa1ww wrote: Would the descriptions in the
"Design Patterns" book take that mechanism into account?
That does not make any sense. My reference to Object Oriented Design and Patterns was directed at your need to design your own code, not your need to understand the .NET Framework design. Although it could be applied that way because the .NET Framework uses many of the Design Patterns, that was not the intention of my statement.
aa1ww wrote: I'll look at Wikipedia. I was hoping that a few very common patterns more complicated than example programs but still idiomatic and popular might be in the code extant. I'll keep looking.
I have no idea what that means but as I stated in my last post, this is a large subject and it takes time. So if you are looking for some sort of three hour tour that imparts the type of experiential knowledge that takes years for most of us to obtain I believe you are going to be spinning your wheels.
led mike
|
|
|
|
|
Your kidding right? I take the time to reply thoughtfully to your post and you vote a 1 on it, f*** off a**hole.
led mike
|
|
|
|
|
Hi, I am using Visual Studio 2005 8.0 C++/CLI. I am getting a strange error when I try to set the Icon property of a Form. I can change the Icon property and compile but when I run the app it bombs on the line...
this->Icon = (cli::safe_cast<system::drawing::icon^>(resources->GetObject(L"$this.Icon")));
I have read in forums that I need to change the Build Action property of the icon file to Embedded but I cant find any Build Action property. It seems my VS 2005 is different than other versions. Does anyone know the correct procedure to get this icon embedded into my solution/project?
Thanks,
Buck
|
|
|
|
|
I'm using VS2005 Professional
Project->Add->New Item (select Icon from the list)
In Solution Explorer right click the Icon1.ico file and select "Properties" from the context menu.
In the PropertyGrid there is a "Build Action" row.
led mike
|
|
|
|
|
Hi Mike,
I'm also using VS 2005 Professional. I read your reply as "Click on Project, Click on Add, Click on New Item". If I click on Project the menu has 'Add Class', 'Add New Item', and 'Add Existing Item'. If I click on 'Add New Item' I get an 'Add New Item' dialog Box that has 'Categories:' and 'Templates:'. Under 'Categories:' I select 'Resource' where an 'Icon File (.ico)' template shows in the 'Templates:' window. I can select that and add it and it appears in the Solution Explorer in the Resources folder. In the Solution Explorer if I right click on the icon file and select Properties from the context menu I don't get a PropertyGrid, I get an icon.ico Property Pages dialog box that list 'Configuation Properties' and 'Custom Build Setup' in a tree structure (much like when I go to Solution/Properties or Project/Properties). This is so typical for me to have the odd flavor of a Microsoft product. What say you?
Buck
|
|
|
|
|
BuckBrown wrote: I get an 'Add New Item' dialog Box that has 'Categories:' and 'Templates:'. Under 'Categories:'
Under Templates choose 'Icon File'
led mike
|
|
|
|
|
The previous post was when I was within the project and I AM CHOOSING ICON FILE. If I highlight the Solution and select 'Add New Item' an 'Add New Item - Solution Items' dialog box appears and I can select 'Icon File' and add it to the 'Solution Items' folder. Right clicking on this icon file and selecting Properties now displays a PropertyGrid that has 5 properties listed... (name), Active Config, Description, Path, and Startup Project, but NO Build Action.
|
|
|
|
|
BuckBrown wrote: The previous post was when I was within the project and I AM CHOOSING ICON FILE.
Yes that is correct.
BuckBrown wrote: If I highlight the Solution
Why did you switch to 'Solution'? Add the Icon File to the Project.
led mike
|
|
|
|
|
I tried switching to solution because I have added the icon file to the project a half dozen times now. There simply is no Build Action property to be found.
|
|
|
|
|
My full version number is 8.0.50727.42. I bet it does not match yours.
Have a great Memorial Day weekend.
|
|
|
|
|
BuckBrown wrote: number is 8.0.50727.42. I bet it does not match yours.
It does match.
led mike
|
|
|
|
|
I all,
need to convert a MFC app to .net, would it be wise to strip out the MFC stuff first to just have normal ANSI C++ code and then wrap it in MC++?
not sure if i'll run into problems later.
thanks
|
|
|
|
|
Fu Manchu wrote: need to convert a MFC app to .net, would it be wise to strip out the MFC stuff
You have an entire application written using MFC, what would be left if you "stripped" it out?
led mike
|
|
|
|
|
well, i guess the windows stuff etc.. the code is an API for currency forex exchange - but i want to extract the main functionality of the API code and convert this to .net.
the application is a sample app, it just has a menu with some basic functions - nothing fancy.
|
|
|
|
|
Fu Manchu wrote: the code is an API for currency forex exchange - but i want to extract the main functionality of the API code and convert this to .net.
well that statement is not at all equal to your original post
Fu Manchu wrote: need to convert a MFC app to .net
You have just won the home edition of our game "Who Wants to be a Programmer", thanks for playing.
led mike
|
|
|
|
|
eh,
Sounds like you’re just in here for a laugh, I’ve been programming in many DIFFERENT languages for over 10 years, if you have nothing useful to add then don't question my ability...
I’ve done this before and i'm not in anyway a beginner - i came here for advice but it seems to me know one here has the knowledge or the qualifications to help!
|
|
|
|
|
Fu Manchu wrote: I’ve been programming in many DIFFERENT languages for over 10 years, if you have nothing useful to add then don't question my ability...
I’ve done this before and i'm not in anyway a beginner - i came here for advice but it seems to me know one here has the knowledge or the qualifications to help!
Yet you could not manage to formulate an intelligent question in your initial post that accurately represents your situation. And then you think it's ok to cast aspersions at me? Your like one of those assholes that cuts people off in traffic and then blames them for the incident, you are the problem in this thread ass wipe not me, f*** off.
led mike
|
|
|
|
|
You can simply compile your MFC application with the /CLR switch (project property, Configuration Properties|General|Common Language Runtime support.)
If I must move an application from native to .NET, my own preference is to understand how the application works and then rewrite it in C# and fully leverage .NET. (I've had some code move almost straight across with mostly cosmetic changes--like having to put public in front of methods and so forth.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hai
I just want to highlight the keywords while typing itself,
For that i am using rtf format,can you tell me, Is any other way is there to highlight the key word.
In richtextformat what is mean by cf1,cf2,cf0 ?
Is it is a color reprasentation.
I saw the msdn i choudn't understand.
Thanks.
|
|
|
|
|
open or create usertype.dat file in a notepad and defined your keyword and save in folder where devenv.exe exist.
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\usertype.dat
Nigah M Manzoor
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I guess my previous question on the autoscroll was a real stumper, so I'll try something else. When writing an application I will get quite a ways into the development when, at the insistance of my boss, I need to create a new version that I can continue development on. So I will go through the tedious process of creating a new folder and copying 'mySolution1 Version 1' to 'mySolution1 Version2' and then renaming the individual solution and project files (that isn't why I am posting but if someone knows an easier way to do that I would love to know). On to the question. While working on an app I did this through a 'mySolution1 Version5' at which time I added an icon of our company logo to appear on the forms and everything was good. Then I needed to use a copy of 'mySolution1 Version5 to begin a new and different application called 'mySolution2 Version1' again renaming the solution and project files accordingly. It compiled fine but crashed with a 'MissingManifestResourceException' on the 'Windows Form Designer' generated code "this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));". If I remark out the line the app compiles and runs fine using the default icon. If I go into the 'Forms Designer' and change the Icon property the way I did before then the app crashes. The syntax of the line is the same. Anyone see what I am doing wrong?
Thanks,
Buck
|
|
|
|
|
BuckBrown wrote: I will get quite a ways into the development when, at the insistance of my boss, I need to create a new version that I can continue development on. So I will go through the tedious process of creating a new folder and copying 'mySolution1 Version 1' to 'mySolution1 Version2' and then renaming the individual solution and project files (that isn't why I am posting but if someone knows an easier way to do that I would love to know).
Umm, ever heard of source control.
led mike
|
|
|
|