What project type is best for this application?

I have the source for an old SSI emulator for website development. It is written in C using Visual studio 6. I want to convert it to C++ Visual Studio 2008.

I started using a Windows Forms Application, but I’m not sure that was the best approach. Here is basically how I expect the process to run.

The process starts by reading in an INI file that has a list of websites and associated directories. At the top of the page/form is a dropdown box where you chose from the list of previously worked on websites, or select “New Site”. New Site should pop up a window that allows you to chose a name for the site and also browse to the Directory where the site exists on your PC. When the pop-up closes, if the name already exists, a new pop up displays the old and new directories and asks if you want to change the directory associated with the name, or change the name.

You use whatever web editing software you prefer to change a few pages, and when done, click the “Update” button on the new program and it will extract the SSI files from whatever files you edited and copy the changes to all of the other files. There is a lot more to it, but you get the drift.

There is also a large feedback text box to display what was done during the update operation.

So, I tried creating the process as a form, but can’t figure out how to have the form pop up a menu, and also the correct way to initialize the process. I add code to the form1.h file, then every time I make a change to the form1.h [Design], all of my changes are destroyed.

I’ve looked for tutorials on line, but can’t seem to find any that go beyond creating a basically empty project. I know C and C++. I’ve written a lot of behind the scene programs that run as services and console aps. It’s the GUI that has me baffled.

Any advice would be welcomed.

Recommended Answers

All 4 Replies

If the old code has ANY C++ (or MFC in it) and if you don't need to change how the program works, just compile the old source code with the new compiler. Of course, you will need to change all .c file extensions to .cpp and make a few adjustments.

Be sure to change the character set from "Unicode" to "Multi-Byte".

If it really won't convert and compile (maybe it had NO C++ already in it), then you'll need to decide if you're more comfortable making it a WinForms app or a WPF app (if you want it to look the same and pretty-much work the same).

The current project is a console ap, written in C.

I want to bring it into a GUI instead of a command line type interface. I'll most likely re-write most of it, but I do know how to use extern "C" in case I have to bring forward any of the logic.

My problem is which GUI is easier to work with? Where are there some good tutorials, video preferably, which go into more detail on GUIs. Most of what I've seen merely go into creating them with the File / New Project ... Then compile them and see them run.

I need to see how to work with the various tools from outside the code created by the new project automation.

I would suggest starting with a WinForm app and then (maybe on another project) moving to WPF.

If you ever dealt with with MFC GUIs back with Visual C++ 6, you'll catch on to WinForms quickly.

You could look at something like this:
http://www.programminghelp.com/programming/dotnet/c-and-my-first-winforms-application/


If you are unfamiliar with the new C++ syntax, YOU COULD ALSO just (first) re-write it as a Console Application (using the new C++) and separate your logic into modules that are not display dependent -- then make a GUI.

Thanks thines, I think I will stick with the Windows Form ap for this one.

I’m having problems referencing the form outside the .h file. I added a combo box with a list and tried to use the Selected Index property to have it initialize with a non-blank display. Worked fine until I changed the form again. VS rebuilt the form1.h file and deleted my changes.

What is the correct way to reference the form outside the .h file?

// HowToInit.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace HowToInit;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());


	// I want to replace the previous line with somethign like this
	class MainForm = gcnew Form1();
	MainForm -> ->comboBox1 -> SelectedIndex = 2;
	Application::Run(MainForm);



	return 0;
}

But the new code does not compile -- Is this the right way not to lose changes? If so, what is the proper coding?

#pragma once


namespace HowToInit {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::ComboBox^  comboBox1;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
			this->SuspendLayout();
			// 
			// comboBox1
			// 
			this->comboBox1->FormattingEnabled = true;
			this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"Item 1", L"Item 2", L"Item 3", L"New Item"});
			this->comboBox1->Location = System::Drawing::Point(120, 129);
			this->comboBox1->Name = L"comboBox1";
			this->comboBox1->Size = System::Drawing::Size(121, 21);
			this->comboBox1->TabIndex = 0;
			this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(292, 270);
			this->Controls->Add(this->comboBox1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
			 }
	};
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.