|
'i' would have to be used in a "capture" class method. 'i' is not global.
button12_Click() is not a capture class method so you need to define an automatic variable 'i'.
Two examples (2 different scopes for 'i'):
for (int i=0;i<3;i++){...........}
or
int i;
for (i=0;i<3;i++){...........}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
But when i was modified in button12, i can't see the modification in back of button12,
i would declare i in capture.h, and use it in form1.h by adding #include "capture.h", but unfortunaly this variable can't be identifiable in form1.h
Help me,
Thank you verry mutch
|
|
|
|
|
A variable needs to be static to be used without a class instance that contains it.
A delegate is a better way to communicate between classes.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
As Christian mentioned, i would need to be static to access it without an object of the capture
class.
You're leavig something out of your posted code so it's hard to help you.
Is button12_Click() a delegate? Is it a class member function (method)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
hi,
i would use delegate with associate a function
public :delegate void deleg(Packet^ e);<br />
event deleg ^arr;<br />
<br />
<br />
<br />
arr += gcnew deleg(this, DisplayListbox(e.Packet));<br />
<br />
arr(e.Packet);<br />
}<br />
<br />
void DisplayListbox(Packet^ value)<br />
{.................. }
there are error : Error 1 error C3364: 'BHIDS00::Form1::deleg' : invalid argument for delegate constructor; delegate target needs to be a pointer to a member function c:\documents and settings\abbd\bureau\bhids0.4\bhids0.0\Form1.h 788
thank you verry mutch
|
|
|
|
|
As indicated in the error message, the second parameter of the constructor needs to be the
address of a method, something like:
&class::methodname
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
I know the reason that when we need to do shallow copy.But how copy constructor resolve this problem?I am not able to understand.
So please reply me as soon as possible.
Regards,
Pankaj Sachdeva
|
|
|
|
|
Please post questions not related to managed C++ on the
Visual C++/MFC board[^]
It's up to you to decide how objects are copied, either using the assignment operator or a copy
constructor. The difference between the two is right in the names -
An assignment operator assigns the "value" of one object to another object.
A copy constructor does the same but it's a constructor - it constructs the destination
object.
The compiler can only provide default copy semantics for objects based on the class of the object.
For any class which doesn't provide operators, this means a bitwise, binary copy.
In the case of pointers, this may not be what you want. You may want a copy of the data pointed
to by a pointer (deep copy), not just a copy of the pointer (shallow copy). To do this you need
to implement assignment operator(s) and/or a copy constructor for a class.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
I have to write the event handler for MSCOMM.OnComm who is listening to serial port for data, so that the event is fired 'OnComm' is executed when the data is arrived.
My understanding for the documentation is unclear as how to achieve this.
Does any one have the sample source code implementation in C# / C++?
Thanks and Regards.
Amar.
|
|
|
|
|
hello,
I have a problem with rebuild the message is :
Command line error D8045 : cannot compile C file '.\NeticaEx.c' with the /clr option
and I changed the common language runtime support but there is no result, what is solution in this cases?
thnk you
aef
|
|
|
|
|
Maybe set the project property for the file to "Compile as C++"
(Properties/C-C++/Advanced/CompileAs)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. If I start Visual Studio and click on file->new project to bring up the new project dialog box. Then I select project type C++/CLR and then select Windows Forms Application and click OK. The skeleton application is created. WITHOUT DOING ANYTHING ELSE, I add a menu item and double click on the menu item so Viual Studio will Automatically add the skeleton code in the Form1.h file. In the skeleton code I add "FileStream^ myStream = gcnew FileStream;". This does not compile! I get an "error C3767: 'System::IO::FileStream::FileStream': candidate function(s) not accessible". I have read on the internet that this has to do with a native type not explicitly made public, but where is my native type here! This is as basic as it gets, Visual Studio generated all of the code except the one line I added. What's wrong here?
Buck
|
|
|
|
|
FileStream doesn't have a public default constructor. You need to pick a constructor from the
list of overloads: FileStream Constructor[^]
For example, compare the compiler results of these two lines:
//FileStream ^strm = gcnew FileStream();
FileStream ^strm = gcnew FileStream(L"c:\\test", FileMode::Open);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Right on! Works like a champ. More than two hours searching and reading posts and no one mentioned this. The important part is that now when I see this general compiler message I have an idea of what the problem is.
Thanks loads,
Buck
|
|
|
|
|
Hi, Using Visual Studio 2005 C++/CLI. I am trying to read a file using FileStream class and when I try to difine a file stream like FileStream^ myStream = gcnew FileStream; When I try to compile this I get an error C3767: 'System::IO::FileStream::FileStream': candidate function(s) not accessible. I have been looking around on the internet for a good answer to this but havn't found anything yet. Does someone know not only why this is hapening but how to make the function accessible?
Buck
|
|
|
|
|
Hi, I am new to CLI. Using Visual Studio 2005 C++/CLI. I have a simple app that I am beginning to develop. I created a CLR Windows Form app and gave the form1.h design some menu options. Then double clicked on a menu item and went to the generated function to add an OpenFileDialog. Just above the definition of the Form1 class I have using namespace defined for System, System::IO, System::Windows::Forms, and some other namespaces that I don't believe apply here. If I qualify the dialog result as System::Windows::Forms::DialogResult::OK then after the last double colon the intellisense puts up a list of results (OK, ABORT, etc.). But if I just type DialogResult:: then intellisense simply lets me choose between get() and set() properties so if I type if(openFileDialog->ShowFileDialog() == DialogResult::get()) I guess my question is...if the namespace that includes DialogResult is included why doesn't DialogResult:: give me a list of the possible results? Another issue is that I have another machine that uses the notation of ::DialogResult but if I try this on this machine I get a "not part of the global namespace" error. Any insight would be appreciated.
Buck
|
|
|
|
|
I left out half a sentence. ...so If I type "if(openFileDialog->ShowDialog() == DialogResult::get()) the conditional fails even though I clicked the OK button. I guess my question is...
|
|
|
|
|
hello,
i have a problem in string format in this exemple is in c# and i would translate in visual c++ cli this is exemple
labelInfoCarte.Text = string.Format("Description: {0}\nIP: {1}\nMasque: {2}", dev[comboBoxDevice.SelectedIndex].Description,dev[comboBoxDevice.SelectedIndex].Ip,
dev[comboBoxDevice.SelectedIndex].Netmask);
please help me
thank you
aef
|
|
|
|
|
Hello aefmaaradji,
Use String::Format (String is in namespace System ) instead of string.Format .
|
|
|
|
|
So after much jubulation and sacrifices to the gods of managed/native code I continued on with my Outlook Addin.
The native code I have is working fine untill I introduce a thread to take the workload away from the GUI thread. Now the exact same code is throwing:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Once I have created the thread I grab a list of the items I'm interested in from Outlook (which is the main thread). I then take each of these managed object and retrive the native object (still reprisented as a System.Object) and pass them over to my C++/Cli. In the managed C++/Cli I use System::Runtime::InteropServices::Marshal::GetIUnknownForObject(iMessage); to retrive and IntPtr and then LPMESSAGE iMessageToSave = (LPMESSAGE)(ipMsg.ToPointer()); to convert it into a native object. The native object is passed to the native C++ method which dies as soon as I try to pIMessageToSave->CopyTo(), where pIMessageToSave is the same native object.
As I said ... it works fine without threading but dies with it :S
Any suggestions?
|
|
|
|
|
Hi
Can someone help me reading the .config file through vc++. Please remember that i don't want to use the Dot Net way of reading config files.
Regards
Saqib
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
saqib82 wrote: Please remember that i don't want to use the Dot Net way of reading config files.
In that case you have posted in incorrect forum
|
|
|
|
|
I gots some maps im trying to load for a game i'm trying to make.
these maps are in a folder called Data
I have a message box that comes up asking which of the two maps i have made i want to load.
I have made done char mapToLoad[200]; at the top.
<br />
if (MessageBox(NULL,"Load world 1?","Load World",MB_YESNO|MB_ICONQUESTION)==IDYES)<br />
{<br />
mapToLoad = "Data/World1.txt"; <br />
}<br />
else <br />
{ <br />
mapToLoad = "Data/World.txt";<br />
}<br />
Do i have to do mapToLoad[1] = D
mapToLoad[2] = A and so on? i was hoping there was an easier way thats why i tried this.
After that i have
filein = fopen(mapToLoad, "rt");
This should work right?
The majority of code i have in the project is from the NeHe opengl tutorial here http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10[^]
thx
|
|
|
|
|
Use a list view or a combo box to allow the user to choose the map he wants
|
|
|
|
|
I probly should have said this earlier. I am using bloodshed dev-cpp not microsoft visual studio. So i
don't have access to those sorts of things. And i think i mentioned before i'm using opengl. I dont
think a windows combo box will work with an opengl program?
The only other way i can think of doing it is to have a seperate loading thing for each map and go if
<br />
messagebox == true <br />
{<br />
whole loading procedure for world.txt<br />
}<br />
else<br />
{<br />
whole loading procedure for world1.txt<br />
}<br />
this seems like alot of extra code to be compiling to me.
So i don't think this is a viable option either.
I really just need to know how to stick the location of the file into a char and then use that char in
place of the first char argument of fopen(const char*, const char*)
thx
|
|
|
|