|
Well, since I used the .net designer to create all of the views, it doesn't seem to lend itself to mvc. Are there any examples of how to use mvc with studio/net generated forms?
Thanks for the reply
|
|
|
|
|
mrhonus wrote: it doesn't seem to lend itself to mvc.
That makes no sense.
mrhonus wrote: Are there any examples of how to use mvc with studio/net generated forms?
Sure the Microsoft UI Composit Application Block[^]
|
|
|
|
|
I agree, it makes no sense.
Well, I am looking for C++ examples.
Thanks
|
|
|
|
|
mrhonus wrote: Well, I am looking for C++ examples.
You are using .NET WinForms
mrhonus wrote: Application::Run(new DataForm(lpCmdLine));
The application block is .NET library so you can use it. If you can't translate C# samples into Managed C++ why are you doing Managed Development in C++?
|
|
|
|
|
Mainly because so many things which I know about C++ don't seem to apply in the .Net environment. I'm doing Managed Devlopment in C++ because I wasn't allowed to choose the development environment. I would have chosen Java, which is much more straightforward. But since you're now getting snide, I guess you've helped me enough--thanks for your time.
|
|
|
|
|
mrhonus wrote: But since you're now getting snide
Not at all. So many times in message based communications people leave out reasons for things that create gaps in understanding. I was just trying to understand how you arrived in your situation to see if a different view might help. It does not appear so.
mrhonus wrote: I would have chosen Java, which is much more straightforward.
Much more straight forward than Managed C++ but very similar to C#. Perhaps you could use C# Research apps as a way of learning the .NET libraries you need and then translate your own C# code into managed C++. That would also allow you to apply samples you can find to the C# research application. It's not real pretty but after time you probably won't need the C# step as you would be able to translate the samples directly to C++.
Also on the MSDN2 web site many of the .NET Framework Documentation contains short samples in C++.
|
|
|
|
|
Hi,
I've got a rather strange question that I've been trying to figure out. Perhaps some of you can give me some hints.
I'd like to call a java method from C++ (or any other language for that matter). The java method is compiled into a java bean which is contained in an applet. I've got no control over the applet and I have full control over the bean which contains a callback method to the applet. This is the method i'd like to call, is it possible?
Cheers!
|
|
|
|
|
Hi,
Check out JNI (Java Native Interface) for this.
|
|
|
|
|
hi everybody.I am newbie in managed c++.I have few questions for you.how do i send data to serial port with using event handler. Before sending the data, do I need to create an object class for serial port or is it already in windows library.I mean in .NET 2005 with framework 2.0 there is a namespace System::IO::Port but I use framework 1.1 with .net 2003 and i haven`t find something like that.
I post what I write below without comments sorry about it
Moreover when the mouse cursor is in the panel coordinates cpu usage rises 100% what should i do to decrease that usage
thanks a lot for your help
Note: Sorry about my pour english
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitForm();
InitializeComponent();
MouseWheel+=new MouseEventHandler(this,Wheeled);
panel1->MouseUp += newMouseEventHandler(this,Joystick_MouseUp);
panel1->MouseMove += new MouseEventHandler(this,Joystick_MouseMove);
panel1->MouseDown += new MouseEventHandler(this,Joystick_MouseDown);
this->panel1->SetStyle( ControlStyles::AllPaintingInWmPaint, true);
this->panel1->SetStyle( ControlStyles::DoubleBuffer, true );
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Panel * panel1;
private: System::Windows::Forms::Label * label1;
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::Button * button2;
private: System::Windows::Forms::Button * button3;
private: System::Windows::Forms::Button * button4;
private: System::Windows::Forms::Button * button5;
private: System::Windows::Forms::Button * button6;
private: System::Windows::Forms::Button * button7;
private: System::Windows::Forms::Button * button8;
private: System::Windows::Forms::Button * button9;
private: System::Windows::Forms::Button * button10;
private: System::Windows::Forms::Button * button11;
private: System::Windows::Forms::Button * button12;
private: System::Windows::Forms::Button * button13;
private: System::Windows::Forms::Button * button14;
private: System::Windows::Forms::Button * button15;
private: System::Windows::Forms::Button * button16;
private: System::Windows::Forms::Button * button17;
private: System::Windows::Forms::OpenFileDialog * openFileDialog1;
private: System::Windows::Forms::VScrollBar * vScrollBar1;
private: System::Windows::Forms::TextBox * textBox1;
private: static int x=40;//x degeri
private: static int y=88;//y degeri
private: double diameter;
private: Pen* rubberband;
private: Graphics* g;
private: Point offset;
private: LineCap endCap;
private: bool mouseLock;
private: bool mouseDown;
private: double magnitude;
private: int radius;
private: SolidBrush* insideColor;
private: Point cursorLocation;
private:
///
/// Required designer variable.
///
System::ComponentModel::Container * components;
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
System::Resources::ResourceManager * resources = new System::Resources::ResourceManager(__typeof(HaloControl::Form1));
this->panel1 = new System::Windows::Forms::Panel();
this->label1 = new System::Windows::Forms::Label();
this->button1 = new System::Windows::Forms::Button();
this->button2 = new System::Windows::Forms::Button();
this->button3 = new System::Windows::Forms::Button();
this->button5 = new System::Windows::Forms::Button();
this->vScrollBar1 = new System::Windows::Forms::VScrollBar();
this->textBox1 = new System::Windows::Forms::TextBox();
this->button6 = new System::Windows::Forms::Button();
this->button7 = new System::Windows::Forms::Button();
this->button8 = new System::Windows::Forms::Button();
this->button9 = new System::Windows::Forms::Button();
this->button10 = new System::Windows::Forms::Button();
this->button11 = new System::Windows::Forms::Button();
this->button12 = new System::Windows::Forms::Button();
this->button13 = new System::Windows::Forms::Button();
this->button14 = new System::Windows::Forms::Button();
this->button15 = new System::Windows::Forms::Button();
this->button16 = new System::Windows::Forms::Button();
this->button17 = new System::Windows::Forms::Button();
this->openFileDialog1 = new System::Windows::Forms::OpenFileDialog();
this->SuspendLayout();
//
// panel1
//
this->panel1->BackColor = System::Drawing::SystemColors::Desktop;
this->panel1->Cursor = System::Windows::Forms::Cursors::Cross;
this->panel1->Location = System::Drawing::Point(272, 136);
this->panel1->Name = S"panel1";
this->panel1->Size = System::Drawing::Size(160, 160);
this->panel1->TabIndex = 0;
this->panel1->Paint += new System::Windows::Forms::PaintEventHandler(this, panel1_Paint);
//
// label1
//
this->label1->BackColor = System::Drawing::SystemColors::Desktop;
this->label1->Image = (__try_cast<system::drawing::image *="">(resources->GetObject(S"label1.Image")));
this->label1->Location = System::Drawing::Point(16, 16);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(152, 64);
this->label1->TabIndex = 1;
//
// button1
//
this->button1->BackColor = System::Drawing::SystemColors::Desktop;
this->button1->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button1.BackgroundImage")));
this->button1->Cursor = System::Windows::Forms::Cursors::PanWest;
this->button1->Location = System::Drawing::Point(224, 208);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(40, 25);
this->button1->TabIndex = 2;
this->button1->Click += new System::EventHandler(this, button1_Click);
//
// button2
//
this->button2->BackColor = System::Drawing::SystemColors::Desktop;
this->button2->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button2.BackgroundImage")));
this->button2->Cursor = System::Windows::Forms::Cursors::PanEast;
this->button2->Location = System::Drawing::Point(440, 208);
this->button2->Name = S"button2";
this->button2->Size = System::Drawing::Size(40, 25);
this->button2->TabIndex = 3;
//
// button3
//
this->button3->BackColor = System::Drawing::SystemColors::Desktop;
this->button3->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button3.BackgroundImage")));
this->button3->Cursor = System::Windows::Forms::Cursors::PanNorth;
this->button3->Location = System::Drawing::Point(336, 88);
this->button3->Name = S"button3";
this->button3->Size = System::Drawing::Size(25, 40);
this->button3->TabIndex = 4;
//
// button5
//
this->button5->BackColor = System::Drawing::SystemColors::Desktop;
this->button5->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button5.BackgroundImage")));
this->button5->Cursor = System::Windows::Forms::Cursors::PanSouth;
this->button5->Location = System::Drawing::Point(336, 304);
this->button5->Name = S"button5";
this->button5->Size = System::Drawing::Size(25, 40);
this->button5->TabIndex = 11;
//
// vScrollBar1
//
this->vScrollBar1->BackColor = System::Drawing::SystemColors::Desktop;
this->vScrollBar1->Location = System::Drawing::Point(512, 160);
this->vScrollBar1->Maximum = 40;
this->vScrollBar1->Name = S"vScrollBar1";
this->vScrollBar1->Size = System::Drawing::Size(24, 112);
this->vScrollBar1->TabIndex = 7;
this->vScrollBar1->Value = 20;
this->vScrollBar1->Scroll += new System::Windows::Forms::ScrollEventHandler(this, vScrollBar1_Scroll);
//
// textBox1
//
this->textBox1->BackColor = System::Drawing::SystemColors::InactiveCaptionText;
this->textBox1->Location = System::Drawing::Point(32, 216);
this->textBox1->Name = S"textBox1";
this->textBox1->Size = System::Drawing::Size(176, 20);
this->textBox1->TabIndex = 9;
this->textBox1->Text = S"textBox1";
//
// button6
//
this->button6->BackColor = System::Drawing::SystemColors::Desktop;
this->button6->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button6.BackgroundImage")));
this->button6->Cursor = System::Windows::Forms::Cursors::Default;
this->button6->Location = System::Drawing::Point(624, 152);
this->button6->Name = S"button6";
this->button6->Size = System::Drawing::Size(40, 25);
this->button6->TabIndex = 12;
//
// button7
//
this->button7->BackColor = System::Drawing::SystemColors::Desktop;
this->button7->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button7.BackgroundImage")));
this->button7->Cursor = System::Windows::Forms::Cursors::Default;
this->button7->Location = System::Drawing::Point(680, 152);
this->button7->Name = S"button7";
this->button7->Size = System::Drawing::Size(40, 25);
this->button7->TabIndex = 13;
//
// button8
//
this->button8->BackColor = System::Drawing::SystemColors::Desktop;
this->button8->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button8.BackgroundImage")));
this->button8->Cursor = System::Windows::Forms::Cursors::Default;
this->button8->Location = System::Drawing::Point(568, 272);
this->button8->Name = S"button8";
this->button8->Size = System::Drawing::Size(40, 25);
this->button8->TabIndex = 14;
//
// button9
//
this->button9->BackColor = System::Drawing::SystemColors::Desktop;
this->button9->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button9.BackgroundImage")));
this->button9->Cursor = System::Windows::Forms::Cursors::Default;
this->button9->Location = System::Drawing::Point(680, 192);
this->button9->Name = S"button9";
this->button9->Size = System::Drawing::Size(40, 25);
this->button9->TabIndex = 15;
//
// button10
//
this->button10->BackColor = System::Drawing::SystemColors::Desktop;
this->button10->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button10.BackgroundImage")));
this->button10->Cursor = System::Windows::Forms::Cursors::Default;
this->button10->Location = System::Drawing::Point(624, 192);
this->button10->Name = S"button10";
this->button10->Size = System::Drawing::Size(40, 25);
this->button10->TabIndex = 4;
//
// button11
//
this->button11->BackColor = System::Drawing::SystemColors::Desktop;
this->button11->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button11.BackgroundImage")));
this->button11->Cursor = System::Windows::Forms::Cursors::Default;
this->button11->Location = System::Drawing::Point(568, 192);
this->button11->Name = S"button11";
this->button11->Size = System::Drawing::Size(40, 25);
this->button11->TabIndex = 4;
//
// button12
//
this->button12->BackColor = System::Drawing::SystemColors::Desktop;
this->button12->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button12.BackgroundImage")));
this->button12->Cursor = System::Windows::Forms::Cursors::Default;
this->button12->Location = System::Drawing::Point(568, 232);
this->button12->Name = S"button12";
this->button12->Size = System::Drawing::Size(40, 25);
this->button12->TabIndex = 16;
//
// button13
//
this->button13->BackColor = System::Drawing::SystemColors::Desktop;
this->button13->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button13.BackgroundImage")));
this->button13->Cursor = System::Windows::Forms::Cursors::Default;
this->button13->Location = System::Drawing::Point(624, 232);
this->button13->Name = S"button13";
this->button13->Size = System::Drawing::Size(40, 25);
this->button13->TabIndex = 4;
//
// button14
//
this->button14->BackColor = System::Drawing::SystemColors::Desktop;
this->button14->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button14.BackgroundImage")));
this->button14->Cursor = System::Windows::Forms::Cursors::Default;
this->button14->Location = System::Drawing::Point(680, 232);
this->button14->Name = S"button14";
this->button14->Size = System::Drawing::Size(40, 25);
this->button14->TabIndex = 4;
//
// button15
//
this->button15->BackColor = System::Drawing::SystemColors::Desktop;
this->button15->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button15.BackgroundImage")));
this->button15->Cursor = System::Windows::Forms::Cursors::Default;
this->button15->Location = System::Drawing::Point(624, 72);
this->button15->Name = S"button15";
this->button15->Size = System::Drawing::Size(96, 25);
this->button15->TabIndex = 17;
//
// button16
//
this->button16->BackColor = System::Drawing::SystemColors::Desktop;
this->button16->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button16.BackgroundImage")));
this->button16->Cursor = System::Windows::Forms::Cursors::Default;
this->button16->Location = System::Drawing::Point(624, 272);
this->button16->Name = S"button16";
this->button16->Size = System::Drawing::Size(96, 25);
this->button16->TabIndex = 18;
//
// button17
//
this->button17->BackColor = System::Drawing::SystemColors::Desktop;
this->button17->BackgroundImage = (__try_cast<system::drawing::image *="">(resources->GetObject(S"button17.BackgroundImage")));
this->button17->Cursor = System::Windows::Forms::Cursors::Default;
this->button17->Location = System::Drawing::Point(568, 152);
this->button17->Name = S"button17";
this->button17->Size = System::Drawing::Size(40, 25);
this->button17->TabIndex = 19;
//
// Form1
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->BackColor = System::Drawing::SystemColors::ControlDarkDark;
this->ClientSize = System::Drawing::Size(744, 358);
this->Controls->Add(this->button17);
this->Controls->Add(this->button16);
this->Controls->Add(this->button15);
this->Controls->Add(this->button12);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->vScrollBar1);
this->Controls->Add(this->button5);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Controls->Add(this->panel1);
this->Controls->Add(this->button10);
this->Controls->Add(this->button11);
this->Controls->Add(this->button13);
this->Controls->Add(this->button14);
this->Font = new System::Drawing::Font(S"Franklin Gothic Book", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
this->ForeColor = System::Drawing::SystemColors::ControlText;
this->Icon = (__try_cast<system::drawing::icon *="">(resources->GetObject(S"$this.Icon")));
this->Name = S"Form1";
this->Text = S"Form1";
this->ResumeLayout(false);
}
void InitForm()
{
//pen
this->rubberband = new Pen(Color::Blue, 5);
//point offset
//this->offset= Point(,0);
this->insideColor = new SolidBrush(Color::Thistle);
this->mouseDown = false;
this->mouseLock = false;
}
private: System::Void Joystick_MouseUp(Object* sender, MouseEventArgs* e)
{
mouseDown = false;
if(!mouseLock)
{
this->panel1->Refresh();//Invalidate();
}
}
private: System::Void Wheeled (Object *sender,MouseEventArgs* e)
{
// i will use here later
}
private: System::Void Joystick_MouseMove(Object* sender, MouseEventArgs* e)
{
//static Point offset;
offset = System::Drawing::Point(e->X,e->Y);
if(e->Button == MouseButtons::Left || e->Button == MouseButtons::Right)
{
String *text = new String("");
//text = text->Concat( S" Veli ", S" Veli" );
text = text->Concat(offset.X.ToString(), S",", offset.Y.ToString());
this->textBox1->Text = text;
}
if(mouseDown)
{
offset.X = e->X;
offset.Y = e->Y;
this->panel1->Refresh();// same as Invalidate(System::Drawing::Rectangle(0,0,160,160), false);
}
else if( !mouseLock)
{
offset.X = radius;
offset.Y = radius;
this->panel1->Refresh();
}
//this->Invalidate(System::Drawing::Rectangle(100,100,150,150), false);
}
private: System::Void Joystick_MouseDown(Object* sender, MouseEventArgs* e)
{
if(e->Button == MouseButtons::Left)
{
mouseDown = true;
mouseLock = false;
offset.X = e->X;
offset.Y = e->Y;
this->panel1->Refresh();// same as Invalidate();
}
else if(e->Button == MouseButtons::Right)
mouseLock = true;
}
/* GUI joystick (mouse stick) in panel */
private: System::Void panel1_Paint(System::Object * sender, PaintEventArgs * e)
{
this->g = e->Graphics;
GraphicsPath* serge = new GraphicsPath();
SolidBrush *sb = new SolidBrush(Color::Cornsilk);
SolidBrush *sb2= new SolidBrush(Color::Blue);
serge->AddEllipse(this->panel1->ClientRectangle);
g->FillEllipse(sb2,System::Drawing::Rectangle(0,0,160,160));
g->FillEllipse(sb,System::Drawing::Rectangle(5,5,150,150));
this->panel1->Region = new System::Drawing::Region(serge);
g->DrawLine(rubberband,offset.X,offset.Y,80,80);
// in order to solve flickering i have to use double buffering
this->SetStyle( ControlStyles::AllPaintingInWmPaint, true);
this->SetStyle( ControlStyles::UserPaint, true);
this->SetStyle( ControlStyles::DoubleBuffer, true );
}
};
}
|
|
|
|
|
In C# project I could include any file in my assembly and access them with
Assembly.GetManifestResourceStream(...)
Is it possible to do the same thing in ManagedC++ projects?
How?
|
|
|
|
|
found it:
project properties => configuration properties => linker => input => embeded managed resource file
|
|
|
|
|
Hi
I have a project where by I define a pre-processor variable entitled PROEDITION. In the project where I define this variable some .cpp files seem to understand that the variable PROEDITION has been defined. Unfortunately one of the most important .cpp files does not seem to pick up this pre-processor variable. Is there a reason why this would happen? It's not just this pre-processor variable, it could be any of them that I define at project scope. It just seems that one of my .cpp files does not understand the pre-processor variables at all.
Any help on this would be appreciated.
Dave
|
|
|
|
|
Where did you define PROEDITION?
Best,
Jun
|
|
|
|
|
I defined PROEDITION in the Pre Processor Definitions
WIN32;_DEBUG;_WINDOWS;_USRDLL;PROEDITION
That is what is in there currently.
Dave
test
|
|
|
|
|
Is the last separator a ":" or a ";"? I am asking because there is a smiley there and I am not sure if this forum uses (thats a test - Semicolon P) as a smiley or :P (another test - Colon P) or maybe both.
Edit: OK. It uses both.
Worth a try, though.
*Test ends*
|
|
|
|
|
Is there a possible redefinition / undef of the same variable in that .cpp file ?
Darka [Xanya]
|
|
|
|
|
no unfortunately not.. It just seems to be ignoring anything that I put in as a preprocessor variable.
|
|
|
|
|
bugger, i suppose you've checked spelling, etc.
Darka [Xanya]
|
|
|
|
|
Yeah, it's the wierdest thing. I mean it uses precompiled headers via stdafx.h
I am not sure why this is not working. The other thing that is sort of unique is that the MIDL compiler has a preprocessor variable as well. I don't think that should matter though, but I am pretty sure that is rare.
The IDL is compiling correctly though with the preprocessor doing what it should.
|
|
|
|
|
Can anyone tell me how can I overcome the following error:
Error 39 error C2440: '=' : cannot convert from 'void *' to 'System::Data::DataColumn ^'
Here is the code which is generating error:
CPtrList* MYpclFields; // this is working fine
POSITION MYposField; // is having the right value
DataColumn^ pColumnInfo; // System::Data::DataColumn object
...
...
...
pColumnInfo = MYpclFields->GetNext (MYposField); // error lies here
actually GetNext() fn. returns a (void *) and I want to convert that into (DataColumn^).
Plz...
Thanks...
|
|
|
|
|
Handle (^) and pointer (*) are not castable. The former is managed; the latter is unmanaged.
Best,
Jun
|
|
|
|
|
What should I do to get rid of it?
I need to convert void* to System::Data::DataColumn^
It's very important.
-- modified at 8:32 Thursday 13th July, 2006
Eariler I converted managed (^) to unmanaged (*)
pclFields->AddTail ((void *) pclFieldInfo);
Where pclFiledInfo is of type DataColumn^ and it's working perfectly fine.
|
|
|
|
|
Handle(^) walks through the managed heap, while pointer(*) walks through the unmanaged heap. They don't see eye to eye.
arvindbhateja wrote: I need to convert void* to System::Data::DataColumn^
You can't.
arvindbhateja wrote: Eariler I converted managed (^) to unmanaged (*)
pclFields->AddTail ((void *) pclFieldInfo);
This is wrong. By doing so, you may have corrupted GC (garbage collection) on the managed heap. On the other hand, the managed C++ provides a mechanism to pin an object on the managed heap. The pinning is a process to temporarily keep the contant address of an object on the managed heap. Here is some sample code extracted from the C++/CLI spec:
void f(int* p) { *p = 100; }
int main() {
array<int>^ arr = gcnew array<int>(100);
pin_ptr<int> pinp = &arr[0];
f(pinp);
}
You could consider this as a temporary "conversion" from managed to unmanaged. But I'm not aware of any "conversion" in the reverse direction.
Best,
Jun
|
|
|
|
|
Thanks for the response.
Is there any alternate to CPtrList which I can use in C++/CLI?
|
|
|
|
|
Yes, there are a whole bunch of collection tyeps you can choose from: link.
Best,
Jun
|
|
|
|
|