|
I'm a bit new to Managed C++, (and frankly, am not overly experienced with C++ at all, being more conversant with Java) and so I was wondering what techniques are commonly used to separate the view from the model in Managed C++.
Specifically, we are working on a distributed application that is hoped to be very platform independent although we are using .NET for the initial implementation.
In addition, we would like to eventually be able to use a Software Engineering CASE Tool to generate as much of the "model" part of the code as possible. The tool we have in mind doesn't emit .NET Windows Forms code, which is another reason for wanting to separate the model from the view.
So the question is, what "patterns" or techniques are commonly used or considered "best practice" for using .NET forms to display and control other "workhorse" modules which are written in "pure" C++?
_________
. | homas
|
|
|
|
|
George L. Jackson wrote: This is just being introduced with the Windows Presentation Foundations (WPF) in .NET Framework 3.0.
If by "just" you mean "not prior to" that is not accurate. If you mean in a platform from MS then arguably MFC is very close to MVC and has been around for a long-long time. Also a discussion of MVC and a Controller framework has been available on the Microsoft Patterns and Practices for ??? not sure but at least two years.
led mike
|
|
|
|
|
tcompter wrote: I was wondering what techniques are commonly used to separate the view from the model in Managed C++.
Well I don't know how "common" it is, especially by people that frequent Code Project, but I have been using the MVC Pattern[^] for years with great success.
Another place you might want to check out is the Microsoft Patterns and Practices site[^].
led mike
|
|
|
|
|
I'm writing a programme for my final project which I have to finish in two days This programme includes a TCPListener to get some data over TCP/IP protocols. So I've made a second thread for this TCPListener. Otherwise, other components woudn't work at the same time due to infinite loop as u predict. But, now I have an other problem; When I start my thread as I wrote below;
Form1^ s = gcnew Form1();
ThreadStart^ serverDelegate = gcnew ThreadStart(s,&MyMessenger::Form1::ServerActivate);
Thread^ serverThread = gcnew Thread(serverDelegate);
serverThread->Start();
ServerActivate function (which includes TCPListener) works correctly, can call other functions, but while this thread is working I can not control the properties of components of Form1, such as textbox->text. I've tried many things, but I couldn't. Please help me, how can I solve this problem?
|
|
|
|
|
See if this[^] helps
led mike
|
|
|
|
|
I will study. I hope I find necessary things. Thanks...
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I am trying to automate Excel 2003. I can get the application and workbook and sheets and ranges but I can't seem to figute out what method to use to actually populate the cell with data. With MFC it used to be Range.SetValue but I can't find the new CLI method that does this. The Microsoft site has a location for the Application, Workbook, Worksheet, and Range interfaces but when I go to look at the details of these the documentation says "the methods are listed in the table below" and there is no table.
Buck
|
|
|
|
|
There seems to be a problem with the Office Documentation but somehow I found my way in, it wasn't pretty.
This[^] seems to indicate that (Value) is a property.
If you are not using the Primary Interop Assembly available from the MSDN web site you should be. It might make things a bit simpler.
Also if you are struggling with the CLI part start a C# project and reference Excel assembly in there so you can use it to see how to work with the Object Model then port to CLI. Alternatively you can build your own C# Library that encapsulates what you want to do with Excel and then use that interface in your CLI code.
led mike
|
|
|
|
|
Thanks Mike,
I will focus on this. I am using the PIA's.
Buck
Buck
|
|
|
|
|
Hello,
I am trying to implement a bit shift function that would shift bit positions either to the right or left using the codes below.
The bit shift is not working can someone help with why it is not working?
public: System::Void apply_BitShift(String ^myString, String ^direction, int numOfShifts)
{
bitShiftVal = "";
array<__wchar_t> ^shiftArray = gcnew array<__wchar_t> (myString>Length);
//copy characters from myString into shiftArray
myString->CopyTo(0, shiftArray, 0, myString->Length);
if(direction->Equals("left"))//Perform left shifts
{
bitShiftVal = gcnew String(shiftArray, numOfShifts, (myString->Length)-numOfShifts);
for(int indx=0; indx<numofshifts; indx++)
="" bitshiftval="String::Concat(bitShiftVal," "0");=""
="" }
="" else="" if(direction-="">Equals("right"))//perform right shifts
{
for(int indx=0; indx<numofshifts; indx++)
="" bitshiftval="String::Concat(bitShiftVal," "0");
=""
="" for(int="" indx="0;" indx<shiftarray-="">Length-numOfShifts; indx++)
bitShiftVal = String::Concat(bitShiftVal, shiftArray[indx].ToString());
}
}//end of apply_BitShift
dee
|
|
|
|
|
Have you stepped through your code to see what exactly is happening?
led mike
|
|
|
|
|
I'm not seeing any bit shifting going on in your code...
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
we probably aren't seeing the code correctly due to the '<' '>' characters. Also in my browser there is a giant Fish Filet obscuring his post.
led mike
|
|
|
|
|
I guess we use the same browser!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hello, I have an project which generate boxes(bin packing) and I want to save the results on the disk so I can use this results in matlab or to save this results in xml so i can use xml for further reaserch please..if you know how can i do this help me .... ...if you can give me some clues...
lavi
|
|
|
|
|
I'd say the first clue would be 'try the visual C++ forum'. It doesn't seem likely from your post that you're using C++/CLI
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
A wild number is a string containing digits and question marks (like 36?1?8). A number X matches a wild number W if they have the same length, and every non-question mark character in X is equal to the character in the same position in W (it means that you can replace a question mark with any digit). For example, 365198 matches the wild number 36?1?8, but 360199, 361028, or 36128 does not. Write a program that reads a wild number W and a number X from input, both of length n, and determines the number of n-digit numbers that match W and are greater than X.
Input (filename: B.in)
There are multiple test cases in the input. Each test case consists of two lines of the same length. The first line contains a wild number W, and the second line contains an integer number X. The length of input lines is between 1 and 10 characters. The last line of input contains a single character #.
Output (Standard Output)
For each test case, write a single line containing the number of n-digit numbers matching W and greater than X (n is the length of W and X).
Sample Input and Output
36?1?8
236428
8?3
910
?
5
#
B.in Standard Output
100
0
4
|
|
|
|
|
If your homework is not for .NET, then you've posted it in the wrong forum. either way, you need to do your own homework, post questions only when you've tried to write it yourself and are stuck on something specific.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a windows form based application, which creates an instance of another class, to which it passes a pointer to itself in the constructor as 'this'. The form has a couple of __property methods, and I'm trying to get the other class to use those methods to push some data back up to the parent form.
For example, let's say my Form1 has a method:
__property void set_MyNumber(int theNumber) {mynumber = theNumber;}
Form1 instantiates another class:
myThing = new CmyOtherClass(this);
Now, down in the other class, I try to access the properties like this:
myParent->MyNumber = 3;
What I get is the following error:
error C2039: 'MyNumber' : is not a member of 'System::Windows::Forms::Form'
I'm fairly sure that the pointers are right, because the following code works fine:
MessageBox::Show(myParent->Width.ToString());
However, it just doesn't seem to recognize the properties I created in the Form1 class. Is there some header or include or using thing that I need to add to make the properties work?
To broaden the question a bit, is this totally the wrong approach? I thought perhaps using delegates might be a better answer, but I seemed to run into similar problems with them as well.
What is the best way to pass information from a subordinate object to its parent?
Thanks for any insight.
_________
. | homas
|
|
|
|
|
Are you passing a 'System::Windows::Forms::Form' pointer to the CmyOtherClass constructor or
a pointer to an object of the type of your Form-derived class?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: Are you passing a 'System::Windows::Forms::Form' pointer to the CmyOtherClass constructor or
a pointer to an object of the type of your Form-derived class?
Ahhh, well, the constructor for the other class is like this:
CmyOtherClass::CmyOtherClass(System::Windows::Forms::Form* callingForm)
and back up in Form1, I'm passing 'this' to the constructor of the other class.
I'm inferring from your question that I should have the constructor look for a pointer to a Form1 object, but what's the syntax for that?
(And BTW, thanks for the quick reply )
_________
. | homas
|
|
|
|
|
tcompter wrote: CmyOtherClass::CmyOtherClass(System::Windows::Forms::Form* callingForm)
You'll need to change the constructor to take an object of the type being passed instead of a
'System::Windows::Forms::Form' (the base class) pointer.
Also, if you are storing the passed pointer in a CmyOtherClass member variable, you need to
change its type too.
That way the compiler will know the existence of your properties
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hey thanks a bunch for that, it worked.
_________
. | homas
|
|
|
|
|
Hi, I have an request: I need someone to create article with OpenGL. There is one, but it's very simple and many users have problems with it( me too ). Plz if You can: create a form with OpenGL rendering within and some edits witch will change rendered objects properties( size, color, rotation or something like that). I hope there will be someone who will be able to handle this request. Thanks!
|
|
|
|
|
How about posting this on the Article Requests and Ideas[^] board?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|