Results 1 to 6 of 6

Thread: [C++ 2008] Debugging Project

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    [C++ 2008] Debugging Project

    Hi!
    I recently upgraded a project from VS C++ 2003 (could be 2002, don't remember).
    So i got a lot of errors on the upgrade which i dont know how to resolve.

    I've just started learning C++ and i dont really understand this error.
    If someone could help me, i'd really appreciate it!

    error:
    error C3867: 'GUI::Form1::notifyIcon_MouseDown': function call missing argument list; use '&GUI::Form1::notifyIcon_MouseDown' to create a pointer to member f:\mina dokument\source code\gui\Form1.h 112 GUI
    code:
    cpp Code:
    1. this->notifyIcon_MouseDown += new System::Windows::Forms::MouseEventHandler(this, notifyIcon_MouseDown)

    Thanks in advance!
    //Zeelia
    Last edited by Zeelia; Jun 29th, 2009 at 04:49 PM.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [C++ 2008] Debugging Project

    The second argument in the MouseEventHandler constructor should be a pointer to the handling method. So it should look like this:
    Code:
    this->notifyIcon_MouseDown += new System::Windows::Forms::MouseEventHandler(this, &GUI::Form1::notifyIcon_MouseDown)
    Try and see if that works better.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: [C++ 2008] Debugging Project

    Actually that would have worked indeed so thanks for the reply!
    But i noticed that since i upgraded a project from 2003 to 2008, the CLR setting was set to oldSyntax.

    So since i want to push this project forward and not stick with all the old programming, i decided to change the setting into CLR (clr), the normal/default setting.

    So what i got now is an error with an array, they are too different from 2003 and i just have some problems with converting variables.

    cpp Code:
    1. ListViewItem^ item1 = gcnew ListViewItem((String^)msg);
    2.             item1->SubItems->Add((String^)message);
    3.             ListViewItem^ temp1 [] = {item1};
    4.             listView1->Items->AddRange(temp1);

    I get this error:
    Line 1 - error C2440: 'type cast' : cannot convert from 'char [260]' to 'System::String ^'
    Line 2 - error C2440: 'type cast' : cannot convert from 'char *' to 'System::String ^'
    Line 3 - error C2728: 'System::Windows::Forms::ListViewItem ^' : a native array cannot contain this managed type
    Line 4 - error C2664: 'void System::Windows::Forms::ListView::ListViewItemCollection::AddRange(cli::array<Type,dimension> ^)' : cannot convert parameter 1 from 'System::Windows::Forms::ListViewItem ^[1]' to 'cli::array<Type,dimension> ^'

    (Line 4 error was caused by line 3 and note on line 3, its supposed to be [] instead of &91;])

    The msg variable is char and the message variable is char*.
    The code needs the variables in string. There aren't any .ToString() functions like in Visual Basic haha.

    So i really need some help, guys.
    Any ideas?
    //Zeelia

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [C++ 2008] Debugging Project

    unmanaged char arrays can not be directly converted to managed strings. You can however create a new String instance and pass the array to it in the constructor:
    Code:
    ListViewItem^ item1 = gcnew ListViewItem(gcnew String(msg));
    The same thing goes for trying to convert a char* to a String^.

    Unmanaged arrays are declared the way you would normally declare an array in C++, namely the way you've done in your code snippet:
    Code:
    int myIntArray[128];
    However these unmanaged arrays can not hold managed types, and so you need to declare a managed array to hold managed types:
    Code:
    array<ListViewItem^>^ temp1 = {item1};
    There are ToString methods in the managed extensions for C++ aswell, but not for the unmanaged types such as char[] or char*
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: [C++ 2008] Debugging Project

    Hi Atheist!
    Thanks for the significant help!
    You've helped me to reduce my errors from 164 to 27. I'm really grateful.

    I can't solve all these errors which I have left so i hope you can help me, i have some big problems and some small:
    cplus Code:
    1. protected:
    2.         void Dispose(Boolean disposing)
    3.         {
    4.             if (disposing && components)
    5.             {
    6.                 components->Dispose();
    7.             }
    8.             __super::Dispose(disposing);
    9.         }
    Line 6: error C2039: 'Dispose' : is not a member of 'System::ComponentModel::Container' f:\mina dokument\gui new_syntax\main1.h
    Line 8: error C2794: 'Dispose' : is not a member of any direct or indirect base class of 'GUI_New::main' f:\mina dokument\gui new_syntax\main1.h

    ~I really dont understand this error, the first error is totally false, Dispose IS a member of the referred class.

    cplus Code:
    1. if ( (myStream = saveFileDialog1->OpenFile()) != NULL )
    error C2446: '!=' : no conversion from 'int' to 'System::IO::Stream ^' f:\mina dokument\gui new_syntax\main1.h

    ~Conversion error again... i was thinking about doing the same solution as before (gcnew ~) but i didn't know how or where to write what code.

    cplus Code:
    1. before:
    2.                     path = saveFileDialog1->get_FileName();
    3. after:
    4.                     path = saveFileDialog1->FileName();
    i tried changing the before into after but without success, i got this error:
    error C2064: term does not evaluate to a function taking 0 arguments f:\mina dokument\gui new_syntax\main1.h

    i have some more errors but i hope you can help me bring some light to this project.
    Thanks!
    //Zeelia

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [C++ 2008] Debugging Project

    The Dispose method(s) of the System::ComponentModel::Container class is virtual, meaning that they are not implemented, but should be implemented in all derived classes. Thats why you can not call its Dispose method.

    I cant really say why you're getting the same error on the GUI_New::main class. Does it have a public (or atleast protected) Dispose method that accepts a boolean argument?

    NULL is a constant defined as 0, which is why you're getting the error about trying to compare an int with a Stream^. Use the keyword nullptr, which is the NULL equivalent for the managed extensions, instead of NULL.

    SaveFileDialog->FileName is a property. Two parentheses after a member name denotes a call, and properties can not be called. Just remove the parentheses
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width