|
I wrote taht you had sad, but still at same line is that error
|
|
|
|
|
Would interesting to see, how you have done that. There are two possiblitites,
1. You have not allocated memory for it.
2. You are accessing invalid index.
|
|
|
|
|
Here is all code :
<br />
#pragma once<br />
namespace Littletanks {<br />
ref struct tank {<br />
int step_x, step_y; <br />
System::Windows::Forms::PictureBox^ pct;<br />
};<br />
using namespace System;<br />
using namespace System::ComponentModel;<br />
using namespace System::Collections;<br />
using namespace System::Windows::Forms;<br />
using namespace System::Data;<br />
using namespace System::Drawing;<br />
public ref class wnd_main : public System::Windows::Forms::Form {<br />
public: wnd_main(void) {<br />
InitializeComponent();<br />
}<br />
protected: ~wnd_main() {<br />
if (components) delete components;<br />
}<br />
private: System::ComponentModel::IContainer^ components;<br />
private: int max_x, max_y, min_x, min_y;<br />
private: tank usr, b_usr;<br />
private: static array<tank^>^ em; <br />
private: static array<tank^>^ b_em; <br />
<br />
#pragma region Windows Form Designer generated code<br />
void InitializeComponent(void)<br />
{<br />
this->components = (gcnew System::ComponentModel::Container());<br />
this->usr.pct = (gcnew System::Windows::Forms::PictureBox());<br />
this->b_usr.pct = (gcnew System::Windows::Forms::PictureBox());<br />
this->SuspendLayout();<br />
this->usr.pct->Location = System::Drawing::Point(235, 391);<br />
this->usr.pct->Size = System::Drawing::Size(50, 50);<br />
this->usr.pct->TabStop = false;<br />
array<tank^>^ em = gcnew array<tank^>(10);<br />
array<tank^>^ b_em = gcnew array<tank^>(10);<br />
for(int i=0; i <10; i++){<br />
this->em[i]->pct = gcnew System::Windows::Forms::PictureBox();<br />
this->em[i]->pct->Location = System::Drawing::Point(250, 250);<br />
this->em[i]->pct->Visible = true;<br />
this->em[i]->pct->Size = System::Drawing::Size(50, 50);<br />
this->b_em[i]->pct = gcnew System::Windows::Forms::PictureBox();<br />
this->b_em[i]->pct->Load("b_em[i]->jpg");<br />
this->b_em[i]->pct->Location = System::Drawing::Point(13, 64);<br />
this->b_em[i]->pct->Size = System::Drawing::Size(5, 5);<br />
this->b_em[i]->pct->Visible = false;<br />
this->Controls->Add(this->b_em[i]->pct);<br />
this->Controls->Add(this->em[i]->pct);<br />
} <br />
this->b_usr.pct->Load("b_usr.jpg");<br />
this->b_usr.pct->Location = System::Drawing::Point(97, 142);<br />
this->b_usr.pct->Size = System::Drawing::Size(5, 5);<br />
this->b_usr.pct->Visible = false;<br />
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);<br />
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;<br />
this->BackColor = System::Drawing::SystemColors::Window;<br />
this->ClientSize = System::Drawing::Size(500, 500);<br />
this->MaximizeBox = false;<br />
this->MinimizeBox = false;<br />
this->Controls->Add(this->b_usr.pct);<br />
this->Controls->Add(this->usr.pct);<br />
this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &wnd_main::wnd_main_KeyDown);<br />
this->Name = L"wnd_main";<br />
this->Text = L"Little tanks ";<br />
this->statusStrip1->ResumeLayout(false);<br />
this->statusStrip1->PerformLayout();<br />
this->menuStrip1->ResumeLayout(false);<br />
this->menuStrip1->PerformLayout();<br />
this->ResumeLayout(false);<br />
this->PerformLayout();<br />
}<br />
#pragma endregion<br />
|
|
|
|
|
Here, you had made couple of mistakes,
thesad wrote: array^ em = gcnew array(10);
array^ b_em = gcnew array(10);
Here, again you are defining local variables. It should be like this,
this->em = gcnew array<tank^>(10);
this->b_em = gcnew array<tank^>(10);
Again, simply defining array doesn't initializes its members, you need to allocate tank variable for each index. So, your code can be modified like this,
thesad wrote: for(int i=0; i <10; i++){
this->em[i]->pct = gcnew System::Windows::Forms::PictureBox();
this->em[i]->pct->Location = System::Drawing::Point(250, 250);
Modify this to,
for(int i=0; i <10; i++){
em[i] = gcnew tank;
this->em[i]->pct = gcnew System::Windows::Forms::PictureBox();
this->em[i]->pct->Location = System::Drawing::Point(250, 250);
|
|
|
|
|
thank you for your help
|
|
|
|
|
If you create a new Array, of 100 tank objects, you have an array with 100 instances of null. You need it iterate over the array, and say
myArray[x] = new gcnew tank();
to create the actual objects in the array.
where x is the index into the array ( you'd probably do this in a loop )
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 )
|
|
|
|
|
Christian Graus wrote: myArray[x] = new gcnew tank();
Typo.
|
|
|
|
|
Hi all,
I have an application in vc6,in that i am using XP style.
The way I am giving XP Style to my application is by adding an XML File
to my resource . The content of the Xml file is given below
/******************************************************************************/
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
="" manifestversion="1.0">
<assemblyidentity
version="1.0.0.0"
="" processorarchitecture="X86" name="Microsoft.Windows.YourApplication" type="win32">
<description>LitmusPro
<dependency>
<dependentassembly>
<assemblyidentity
type="win32"
="" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorarchitecture="X86" publickeytoken="6595b64144ccf1df" language="*">
/****************************************************************************/
It is working fine in VC6 .
But, when I compile my application in Visual Studio 2005 , this is not working . How can I make it work.
Please Help me
Thanks
Vinod
|
|
|
|
|
Remove the .manifest file from your resources (along with its reference in the .rc file). Then, go to Project Properties / Configuration Properties / Linker / Manifest File, and set Generate Manifest to Yes. Don't forget to call InitCommonControls in your InitInstance function.
This is not a C++/CLI question though, so you're in a wrong forum. Use Visual C++ / MFC[^] forum to discuss non-.NET C++ issues.
|
|
|
|
|
hey folks
I just found this old remote control from Pinnacle Systems and wanted to code an application (in C++/CLI) which uses the RC, means: respond to key presses on the RC (volume up/down etc).
It has an infrared receiver (no extra power or so is needed), which I connected to my serial port (luckily I got one on my new computer!).
The question is, how can I receive messages?
I already opened the port (COM1), but no messages were received
Is there any driver-stuff I need or something?
any C++/CLI code is appreciated!
thx in advance
|
|
|
|
|
I had written a program and I need use Random class, so I wrote :
Random^ i = gcnew Random();<br />
for(int i=0; i<10; i++) {<br />
em[i]->pct->Left = i->Next(min_x, max_x);<br />
em[i]->pct->Top = i->Next(min_y, max_y);<br />
}
em is static array< tank^ >^ em;
and tank is :
ref struct tank {<br />
int step_x, step_y; <br />
System::Windows::Forms::PictureBox^ pct;<br />
};
but I get an error : error C2227: left of '->Next' must point to class/struct/union/generic type type is 'int'
Where is problem??
|
|
|
|
|
thesad wrote: em[i]->pct->Left = i->Next(min_x, max_x);
i needs to be a number, an index into the array. Instead, it's an instance of the Random class.
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 )
|
|
|
|
|
thanks for your help
|
|
|
|
|
Hi all,
Could someone please give me a short insight or web reference on the following: how to get notified when a new email message has arrived (MS Outlook) using VC++.
Many thanx in advance.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Shouldn't this qualify for cross post and wrong forum ?
|
|
|
|
|
Not sure .. what do you think?
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Yesterday, you have asked same question in VC++ forum, which is right forum for this question. Did you say CLI or managed C++ some where ?
|
|
|
|
|
Programm3r wrote: insight or web reference on the following: how to get notified when a new email message has arrived (MS Outlook) using VC++.
you have to look MSoutlook com interface for that... try googling
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Can sombody help, i need source for capturing s-video from my pinnacle pci card to borland c++. Or can sombody tell me where to begin if i write it myself. Because i dont know how link other applications ed.
bozzim
|
|
|
|
|
Borland doesn't do C++/CLI AFAIK, so odds are, you're in the wrong forum. Try the visual C++ forum, but even then, Borland means you're pushing it to find someone here who can help.
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 )
|
|
|
|
|
Hi,
Does anyone know the function to get the Length of a file in CPP (Win32 Console Application).
Regards,
Vichitra
|
|
|
|
|
I know that you've described a program that is not appropriate to this forum. Try the visual c++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
GetFileSize()? Or for "Really Big®" files (according to the docs), GetFileSizeEx()?
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hi all.
I have some problem, I need class thet manage files as CFile in MFC, but in console.
can anyone help me.
Thanks for any help.
|
|
|
|
|
Wrong forum. Ask here[^].
|
|
|
|