|
if u are worried about CPU time taken for such a simple operation then i would check the ASM output that is generated from the code, i think u will find that a number of C code options will boil down to the same ASM in the end.
|
|
|
|
|
Hi. I'm using Visual Studio C++/CLI. I have a well developed class that now has a need to have a user interface for it. Normally I will determine if I need a form associated with a class when I create the class, so the class is created as a System::Windows::Forms::Form. But now I have a class that I did not think would need a form associated with it so it was defined as a simple C++ ref class. What is the proper way to add a form to the class? Should I create a new UI Forms based class and cut and paste everything in my existing class into it? Or is there a simple way to instantiate a new form as a method of the existing class?
Thanks,
Buck
|
|
|
|
|
BuckBrown wrote: Normally I will determine if I need a form associated with a class when I create the class, so the class is created as a System::Windows::Forms::Form. But now I have a class that I did not think would need a form associated with it so it was defined as a simple C++ ref class. What is the proper way to add a form to the class? Should I create a new UI Forms based class and cut and paste everything in my existing class into it? Or is there a simple way to instantiate a new form as a method of the existing class?
Buck, what's up dude? Ever heard of Object Oriented Design Principles, Best Practices, Separation of Concerns, Design Patterns, Model-View-Controller?
Any of this ringing any bells with you? You don't tightly couple a "class" with the presentation layer of your design, it's not considered Best Practice and there are Patterns like MVC that represent solutions for this.
led mike
|
|
|
|
|
Hi Mike,
Just so you know, I first learned programming using assembly on a state of the art Intel 8085 and our operating system was CP/M (that's what it was called before Microsoft bought it and renamed it MS-DOS). Over the years I have been forced to learn various programming languages on Data General, VAX, UNIX, and MS-DOS boxes, but all of the OO stuff was invented long after I got out of college. So the fact that I'm an over 50 microelectronics engineer with a EE degree and not a new Computer Science graduate, I can state with confidence that with the exception of Object Oriented Design Principles I've never heard of any of those terms before (nor whatever MVC means). You even mention a "presentation layer". I have never heard anyone use that term before. IO, User Interface, GUI sure, but "presentation layer"? I don't understand what you mean by "you don't tightly couple a class with the presentation layer". Visual Studio's forms designer seems to make things very tightly coupled. Anyways, if you could dumb down your responses for me that would be cool.
Thanks,
Old Buck
And my applications always work and do what they were designed to do.
|
|
|
|
|
|
Easy way would just be to make a new form class and make the class a member of the new form class. ugly? yes. best practise? no. will it do the trick? probably
|
|
|
|
|
How To create an array of form?
|
|
|
|
|
You create form array in the same way as you would create array of any other type.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Still another question:
I want to create a .NET equivalent to the MFC CDialogBar.
When I move a form which is a child of a panel,
the mouse position is bounded by the panel,
even if I set
Parent = nullptr;
TopLevel = true; on first Move-Event and even if the panel is not
visible any more. Is there a workaround?
Alex
|
|
|
|
|
Hello!
For the mouse, I found a solution:
The allowed mouse position is bounded by the Cursor->Clip property.
But still the window can not be moved completely out of the panel,
it stops at the border.
Alex
|
|
|
|
|
Ok, nearly solved.
When I override the WndProc-Method and process the WM_SYSCOMMAND(SC_MOVE) Message,
I can reset the Parent-property and the window is not bounded any more.
Alex
|
|
|
|
|
Hello!
I want to compare the type of an object to a class.
What is the correct syntax to use? In my case, I
want to know if a control is an instance of MdiClient.
GetType works on the pointer, but not on the class.
typeid(MdiClient) gives me error C3767.
Alex
|
|
|
|
|
if (some_ref_handle->GetType() == MdiClient::typeid)
{
}
|
|
|
|
|
Thank you!
At first I got an error because MdiClient is a private(?) member
of the class (which is not shown in the IntelliSense list).
But with
Windows::Forms::MdiClient::typeid
it works.
Alex
|
|
|
|
|
Cool
LionAM wrote: MdiClient is a private(?) member
of the class
MdiClient IS the class.
LionAM wrote: But with
Windows::Forms::MdiClient::typeid
it works.
Oops - I guess I assumed "using namespace Windows::Forms;"
typeid needs to know the type at compile time. You could also use something like
if (some_ref_handle->GetType() == Type::GetType("Windows::Forms::MdiClient"))
for a runtime check.
Cheers,
Mark
|
|
|
|
|
Hello!
::MdiClient::typeid works, but MdiClient::typeid
gives
error C3223: 'System::Windows::Forms::Form::MdiClient' : you cannot apply 'typeid' to a property
Alex
|
|
|
|
|
MdiClient is in the System::Windows::Forms namespace, not the
System::Windows::Forms::Form namespace (which doesn't exist -
System::Windows::Forms::Form is a class).
Either of these should work:
using namespace System::Windows::Forms;
...
if (objectref->GetType() == MdiClient::typeid)
or
if (objectref->GetType() == System::Windows::Forms::MdiClient::typeid)
Mark
|
|
|
|
|
Hi all,
I have a server application that sends a udp message to clients,
But it receives the message as well,
And I don't want this....
I want only other clients Receive the message.
Please help me,
Thank you.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
dSolariuM wrote: I have a server application that sends a udp message to clients
HoW?
Mark
|
|
|
|
|
Dear experts,
I have the following problem.
I have "C++ - unmanaged code" and I want to use it in my managed C#-Applications. Therefore I have a "managed C++" - wrapper around my "unmanaged C++ - Code"
At the end I have the following "call-sequence"
"Managed C#" -> "Managed C++" -> "Unmanaged C++"
All works fine, but the problem beginns at debugging the unmanged C++-Code.
a) I cannot step-into the "unmanged C++-Code"
b) The unmanged objects are not expanded in the debugger
Does somebody have any advice?
Kind regards
|
|
|
|
|
Ok,
I found the solution the "stop-into"-Problem by Myself: Just the the debugger-option to: "Enable unmanaged code debugging".
What remains is the second problem: The unmanaged objects are not expanded.
Kind regards
|
|
|
|
|
Hallo,
I found another part of solution.
If I set for all 3 components the debugger-option to "mixed mode" than I can expand the "unmanged objects" in the "managed C++"-Wrapper )))
But I still cannot expand my "unmanaged C++"-objects in my "manged C#"-Code.
I fear, this is not possible due to totally different languages
Kind regards
|
|
|
|
|
How can I get Decimal separator in the system that my program run
I use Visual c++ NET
|
|
|
|
|
Hello!
Have a look at:
System::Globalization::CultureInfo::CurrentCulture->NumberFormat->NumberDecimalSeparator
Alex
|
|
|
|
|