|
Also, those C# articles can be helpful - The .NET framework is the same - so is the code logic. The
code syntax is pretty similar too....
The first two errors are pretty obvious (or should be) from the error message. ..In C++ you don't get the address
of a member function that way anymore - you use the address-of operator, as shown in the error message.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark, the c# articles really useful to get me in c++/cli.
Can u simply show me how to use the address of operator for a function to solve that error? Thx.
|
|
|
|
|
did you try this?
m_mainSocket->BeginAccept(gcnew AsyncCallback(&ServerChat::Form1::OnClientConnect), null);
AsynCallback^ pfnWorkerCallBack = gcnew AsyncCallback(&ServerChat::Form1::OnDataReceived);
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
By doing AsyncCallback(&Form1::OnClientConnect) the problems is solved but it still prompt a strange errors like this:
error C3352: 'void ServerChat::Form1::OnClientConnect(System::IAsyncResult ^)' : the specified function does not match the delegate type 'void (System::IAsyncResult ^)'
It is exactly the same type why it still happen to be an error?
I try put static void OnClientConnect(IAsyncresult^ ar) as fuction can solve it somehow but it prompt out error after put static to the function like this:
error C2227: left of '->Text' must point to class/struct/union/generic type
by right richTextBoxRcvMsg->Text don't have any problem.
error C2227: left of '->EndAccept' must point to class/struct/union/generic type
by right m_Socket->EndAccept(ar) don't have problem.
Someone help pls..
modified on Monday, March 10, 2008 6:36 AM
|
|
|
|
|
Are these the new questions you referred to?
Can you provide some relevant code that causes the errors?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yup.
The relevant code i already stated at the new question thread. I will make it more clear here.
I try solve error:
(1)error C3352: 'void ServerChat::Form1::OnClientConnect(System::IAsyncResult ^)' : the specified function does not match the delegate type 'void (System::IAsyncResult ^)'
by putting static to function void OnClientConnect(IAsyncResult^ ar) and relevant functions.
The error gone but doing this the statement within the function:
richTextBoxRcvMsg->Text = str;
come out error:
(2)error C2227: left of '->Text' must point to class/struct/union/generic type
I just don't understand that even richTextBoxRcvMsg is a form component within the class this still happen. Is that i need to make the ref class static also?
Instead of using static to the function, i just got a suggestion to try with this code:
Asynchronous(this, &Form1::OnClientConnect);
Later i back home only can try.
modified on Wednesday, March 12, 2008 11:11 PM
|
|
|
|
|
Hi,
I need to create a file inside the directory.I have to get the directory name and file name from the textbox. How to do this ? Can you help me.
Note:-
I can able to create a file(getting the file name from the textbox).
I can able to create a directory also(getting the directory name from the separate textbox).
|
|
|
|
|
Specify the full path to the file when you create it. Otherwise, you will create it in your working directory
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am creating a modeldialogbox,I wrote the code as follows.
void Mform::newToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
Form ^dlgl= gcnew Form();
this->btn = gcnew Button();
this->btn->Text = L"OK";
this->btn->Location = System::Drawing::Point(100,160);
this->btn->Click += gcnew System::EventHandler(this,&Mform::bt1_Click);
this->label = gcnew Label();
this->label->Text = L"Enter the filename : ";
this->label->Location = System::Drawing::Point(45,20);
this->label->Size = System::Drawing::Size(113,13);
this->textbox = gcnew TextBox();
this->textbox->Location = System::Drawing::Point(178,20);
this->textbox->Text = "";
this->textbox->Multiline = true;
this->textbox->AcceptsReturn = true;
this->textbox->AcceptsTab = false;
this->textbox->WordWrap = true;
dlgl->AcceptButton=btn;
dlgl->CancelButton = btn1;
dlgl->MaximizeBox = false;
dlgl->MinimizeBox = false;
dlgl->Controls->Add(this->btn);
dlgl->Controls->Add(this->btn1);
dlgl->Controls->Add(this->label);
dlgl->Controls->Add(this->textbox);
dlgl->ShowDialog();
}
void Mform::bt1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->rtext = gcnew RichTextBox();
String ^path1;
path1=textbox->Text::get();
if(path1 == "")
{
MessageBox::Show("Enter the filename","Error",MessageBoxButtons::OK);
}
else{
FileInfo ^fi = gcnew FileInfo(path1);
if(fi->Exists)
{
MessageBox::Show(" filename exists","Error",MessageBoxButtons::OK);
}
else
{
FileStream ^fs = fi->Create();
this->f = gcnew Form();
this->f->MdiParent = this;
this->f->Show();
this->rtext->Dock = DockStyle::Fill;
this->f->Controls->Add(this->rtext);
}
}
}
In this code when i press ok button, it perform needed the operation but the dialog box is not closed.
help me. where i done a mistake.
|
|
|
|
|
In Winforms, you need to either close the form in code, or set the AcceptButton and CancelButton properties, etc, in the forms designer, to set up which button(s) close the form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Can you tell me how to create a model. I need a step by step process.
I read msdn already i couldn't understand. Can you guide me.
Thanks,
|
|
|
|
|
Do not repost your questions. it's rude.
led mike
|
|
|
|
|
I am doing project using visual c++ 2005 clr windows form application.I used a treeview& a contextmenustrip. On right clicking the rootnode the strip contains "Add&Find" item.I need some code samples to add & find a node using visual c++.Send me the same.
Thanks in advance
|
|
|
|
|
readwrite wrote: I need some code samples to add & find a node using visual c++.Send me the same.
I see you are new to CodeProject, welcome.
As to your request you should read the first post in the Visual C++ / MFC forum titled "How to get an answer to your question". Pay attention to item #2. Also this Posting Guidelines Article[^] might be helpful as well.
led mike
|
|
|
|
|
Hi,
I am trying to create a model dialog box "in managed c++".
I don't know the basic steps.
Can you give the steps,and tell how to add this to form.
I read the msdn already. I couldn't understand.
Helpme.
Thanks,
rose
|
|
|
|
|
rose196 wrote: Can you give the steps,and tell how to add this to form.
I read the msdn already. I couldn't understand.
"The following code example creates a new instance of a Form and calls the ShowDialog method to display the form as a dialog box."
They hide those samples in the documentation[^]
led mike
|
|
|
|
|
Hi,
Thanks for replaying.
I did already,as per the example,but i have a problem.
Actually i am developing IDE.
when i was pressing the new button the dialogbox has to be open.
My problem is when i press ok button in the dialodbox it perform some operation at the same time it has to be close know,but in my project it is not closed but it perform the needed operation. if i give close to close the dialogbox, the entire form was closed.
Now what i have to do.
Thanks
|
|
|
|
|
I am searching for files in a particular drive..
However, the search is very slow..
Can I use threads to accomplish this??
Can anybody tell me how to do this or send me a helpful link??
|
|
|
|
|
ptr2void wrote: However, the search is very slow..
Can I use threads to accomplish this??
So are you assuming that using threads will speed up the process?
led mike
|
|
|
|
|
Yes I am assuming that threqads would make it faster..
Am I wrong? Please correct me..
Since I am using recursion, If I can spawn a thread whenever a new directory is found I am assuming that the search would be faster..
Please correct me if I am wrong and it would be very helpful if you could guide me in some way as to how the search could be faster..
|
|
|
|
|
ptr2void wrote: Yes I am assuming that threqads would make it faster..
Am I wrong?
No you are not wrong, um Yes you are wrong. See it's just not that simple, threading never is and anyone who tells you different either doesn't know that they are talking about or is an absolute genius and therefore their experience does not apply to you and me.
Creating threads and switching context between them takes resources and processing cycles so technically can "slow down" a procedure. If the execution context ( hardware, running software ) provides a scenario where multiple processors are available and therefore can more efficiently execute your procedure then yes it could be faster (emphasis on "could" because multiple processors are not the only criteria in your case since there is still only one bus and one drive that you are accessing and therefore caching will come into play as well), otherwise it will just be slower. Now how do you determine if the execution context is favorable? There almost is no way. Also even when it is favorable, how much faster would it be? Don't know but in your case likely negligible.
This is really far more complex than I am qualified to explain but have I provided even a small explanation that helps?
led mike
|
|
|
|
|
Hi
How To using office Word 2003/2007 in Manage C++
|
|
|
|
|
Office Interop Library. Google for it and there is a lot on it...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Background: I'm trying to build a managed wrapper around a C library, using C++/CLI to build a DLL that will be referenced by a C# program. This is my first look to C++/CLI, so even little things seem really hard.
Now, my first problem. The C library has lots of parameters passed by pointers, e.g.:
void H5get_libversion(int * major, int * minor, int * release);
What I'd like to have is an equivalent method in C++/CLI, something that in C# would be:
void GetLibVersion(ref int major, ref int minor, ref int release);
The only way I found to achieve this is doing something like:
void HGlobals::GetLibVersion(unsigned int % major, unsigned int % minor, unsigned int % release)
{
unsigned int _major, _minor, _release;
H5get_libversion(&_major, &_minor, &_release);
major = _major;
minor = _minor;
release = _release;
}
Do I really have to do this manual "duplication"? Isn't there a better (shorter) way?
Thanks in advance
Luca
The Price of Freedom is Eternal Vigilance. -- Wing Commander IV
En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur.
(But the best thing God has created, is a New Day.)
-- Sigur Ròs - Viðrar vel til loftárása
|
|
|
|
|
Maybe try pinning those moveable managed "pointers" (tracking references)
void NativeFunc(int *a, int *b)
{
*a = 10;
*b = 20;
}
public ref class TestRefClass
{
public:
TestRefClass() {}
void TestMethod(Int32 %a, Int32 %b)
{
pin_ptr<Int32> pa = &a;
pin_ptr<Int32> pb = &b;
NativeFunc(pa, pb);
}
};
int _tmain()
{
int a = 3;
int b = 4;
TestRefClass obj;
obj.TestMethod(a, b);
return 0;
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|