CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2001
    Posts
    31

    from vc++ 6.0 to vc++ 2008

    Hi,

    I was using vc++ 6.0 long time ago and downloaded the 2008 express recently. When I tried to write a new MFC program, I found that the structure was changed a lot.

    1. For example, function codes of OK_Click(when "ok" button is clicked) was move from .cpp to .h. Therefore i am not sure whether I should declare the global variables. Should I place them in location 1 or 2 (highlighted in green below)?

    2. When I tried to declare an array with defined structure (highlighted in red below), it doesn't work! I have searched some posts in the net and tried syntax like array<route_data^>^route=gcnew array<route_data^> (100); but still failed. What I want is to build an array with 100 blank entries of several fileds named "type","name"...and will be filled with data after user click the "ok" button.


    Please kindly help! Thank you.

    --------------------------------------------
    Code:
    #pragma once
    namespace TrafficReport
    {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    	using namespace System::Text;
    
    
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    
    <location 1>
    public: Form1(void) { InitializeComponent(); } protected: ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ EXIT; protected: private: System::Windows::Forms::Button^ OK; private: System::Windows::Forms::Label^ label4; ........ private: /// Required designer variable.
    <location 2>
    String^ path; String^ initPath; String^ msg; ref struct route_data { String^ MSC; String^ Type; String^ Dir; String^ Name; int dev; float cap; String^ Date; String^ Hr; float Erl; float Loading; } route[100]; System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code void InitializeComponent(void) { this->EXIT = (gcnew System::Windows::Forms::Button()); this->OK = (gcnew System::Windows::Forms::Button()); this->label4 = (gcnew System::Windows::Forms::Label()); .... } #pragma endregion private: System::Void OK_Click(System::Object^ sender, System::EventArgs^ e) { ... } }; }
    Last edited by Cassie Tsui; May 25th, 2009 at 02:05 AM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: from vc++ 6.0 to vc++ 2008

    Quote Originally Posted by Cassie Tsui View Post
    Hi,

    I was using vc++ 6.0 long time ago and downloaded the 2008 express recently. When I tried to write a new MFC program, I found that the structure was changed a lot.
    That is because you didn't choose the right project type.

    The code you posted is not C++, it is "Managed C++". This forum is dedicated to traditional C++ programming using Visual C++. The Managed C++ forum is dedicated to Managed C++.

    So either change your project to use traditiional C++ programming, or go to the Managed C++ forum to ask questions pertaining to Managed C++.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Oct 2001
    Posts
    31

    Re: from vc++ 6.0 to vc++ 2008

    Oh! I chose file -> new -> project-> CLR -> windows form application, am i wrong? I just remember I used something like "single dialog" in VC 6.0. What should i choose to create a form like application and can use previous syntax like CString?
    Last edited by Cassie Tsui; May 25th, 2009 at 02:26 AM.

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: from vc++ 6.0 to vc++ 2008

    Quote Originally Posted by Cassie Tsui View Post
    Oh! I chose file -> new -> project-> CLR -> windows form application, am i wrong?
    Yes. Do not choose CLR. Once you do that, you are no longer in the C++ world (or at least, in the world that is recognized in this forum).

    Do you have the choice of Win32 project or MFC project?

    I just remember I used something like "single dialog" in VC 6.0. What should i choose to create a form like application and can use previous syntax like CString?
    If you're going from Visual C++ 6.0 to VC 2008, you don't want to do "forms". You want to continue to use MFC. Using "forms" means that you are going down a different path, and that path leads you to a different language known as Managed C++.

    The C++ language knows nothing about things like this:
    Code:
    String^ path;
    This is gibberish to C++.

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Oct 2001
    Posts
    31

    Re: from vc++ 6.0 to vc++ 2008

    There is choice for win32 project, but the checked box for MFC is disabled. I think it is excluded from the express version. I think I have to stay on my old 6.0, anyway thank you for your help.

  6. #6
    Join Date
    Apr 2009
    Posts
    57

    Re: from vc++ 6.0 to vc++ 2008

    Quote Originally Posted by Cassie Tsui View Post
    There is choice for win32 project, but the checked box for MFC is disabled. I think it is excluded from the express version. I think I have to stay on my old 6.0, anyway thank you for your help.
    Oh, you didn't know.

    The Express Edition doesn't support MFC but it does support WIN32 API. Winforms is part of .NET and not MFC.

    Unfortionatly, you had to learn the hard way.

    But if you want to get a taste for MFC in a 2008 environment you can download one of the VS2008 trial editions and evaluate it for 3 mo. ... then you can do all the MFC you want.

  7. #7
    Join Date
    Oct 2001
    Posts
    31

    How to declare and initialize a global variable?

    Hi,

    I was using vc++ 6.0 long time ago and new in CLI. When I tried to write a "form" like application, I found that the structure is quite different from MFC in VC 6.

    1. For example, function codes of OK_Click(when "ok" button is clicked) was move from .cpp to .h. Therefore I am not sure whether I should declare the global variables. Should I place them in location 1 or 2 (highlighted in green below)?

    2. On the other hand, how can I declare and initialize a global variable? When I tried to declare an array with defined structure (highlighted in red below), it doesn't work! What I want is to build an array with 100 blank entries of several fileds named "type","name"...and will be filled with data later. Even simple initialization like String ^a=”hello” is not work if I don’t put them inside a function.

    Please kindly help! Thank you.

    --------------------------------------------
    Code:
    #pragma once
    namespace TrafficReport
    {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    	using namespace System::Text;
    
    
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    
    <location 1>
    public: Form1(void) { InitializeComponent(); } protected: ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ EXIT; protected: private: System::Windows::Forms::Button^ OK; private: System::Windows::Forms::Label^ label4; ........ private: /// Required designer variable.
    <location 2>
    String^ path; String^ initPath; String^ msg; [COLOR="Red"]ref struct route_data { String^ MSC; String^ Type; String^ Dir; String^ Name; int dev; float cap; String^ Date; String^ Hr; float Erl; float Loading; }; array<route_data^>^route=gcnew array<route_data^> (100) System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code void InitializeComponent(void) { this->EXIT = (gcnew System::Windows::Forms::Button()); this->OK = (gcnew System::Windows::Forms::Button()); this->label4 = (gcnew System::Windows::Forms::Label()); .... } #pragma endregion private: System::Void OK_Click(System::Object^ sender, System::EventArgs^ e) { ... } }; }

  8. #8
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: from vc++ 6.0 to vc++ 2008

    [ redirected & merged ]
    Last edited by cilu; May 26th, 2009 at 07:20 AM.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

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

Featured