I have got the code below to work using Visual C# 2005 Express Beta 2 but would liek to change it to Visual C++ using Visual C++ 2005 Express Beta 2 as I am told (please correct me if necessary!) that with Visual C++ 2005 Express and Windows SDK I can write a Win32 app which would then not require the large .NET Framework software when installing on another PC...my app being very small it seems foolish to have to add the .NET Framework ...
Are there better ways to create a small app like mine Would VB5 or 6 be better The main thing for me is that I need an IDE where I can drag and drop a slider/trackbar etc...Visual C# 2005 Express Beta 2 made this quite easy.
Any thoughts
Cheers
Geoff
------------- C# code -----------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace slider3
{
public partial class Form1 : Form
{
private string[] LHSquestions;
private string[] RHSquestions;
private int qnumber = 0;
private string[] results;
private int count = 0;
public Form1()
{
InitializeComponent();
LHSquestions = new string[]{"question 1","question 2"};
RHSquestions = new string[]{"question 1","question 2"};
results = new string[LHSquestions.Length];
this.label1.Text = LHSquestions[qnumber];
this.label2.Text = RHSquestions[qnumber];
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
}
private void button1_MouseClick(object sender, MouseEventArgs e)
{
results[qnumber] = trackBar1.Value.ToString();
++qnumber;
if (qnumber == LHSquestions.Length)
{
endMessage();
}
else
{
this.label1.Text = LHSquestions[qnumber];
this.label2.Text = RHSquestions[qnumber];
}
}
private void endMessage()
{
this.label1.Text = "Finished!";
this.label2.Text = "Thank you";
this.button1.Visible = false;
TextWriter tw = new StreamWriter("d:\\a-temp1\\data.txt");
for (count = 0; count < LHSquestions.Length; count++)
{
tw.WriteLine("q" + (count+1) + " = " + results[count]);
}
tw.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}

change Visual C# code to C++ ?
Thomas Weiss
But, then you lose all the advantages of the .NET Framework. Instead of starting with a prebuilt Form class from the Framework and just overriding the methods you want to handle you have to build up the form from scratch (well with the help of a wizard and IDE).
Normally a C++ Win32 app that did UI would use MFC but I'm not sure that the Express edition supports MFC. You could look in New projects and see if MFC Application is one of the choices (sorry I don't have Express installed anywhere). If it does, create an MFC project and see how many files are created. Compare that with your current C# project. Also, MFC is not for the faint hearted. Here for example is the slider control from MFC. There isn't really a good event model like there is in .NET.
http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_CSliderCtrl.asp
Certainly redistributing the Framework is a royal pain, but more and more systems will just have the Framework present. Vista will ship with it, Windows Server 2003 shipped with the 1.1 Framework. Anyone who visits Windows Update gets encouraged to install the 1.1 Framework. I have no idea what ratio of Framework to non-Framework systems is but I'd guess that the number of systems with the Framework installed is growing all the time. When 2.0 ships, we'll go through the whole cycle again. How quickly the installed base will get up to 2.0 I have no idea, but if it goes relatively quickly then you don't really need to avoid using the Framework.
That depends on your criteria for "better". C# made your task easy because a great deal of the "plumbing" was already implemented for you in the .NET framework. Even down to things like being able to convert an integer to a string using ToString(). If you don't want the Framework then you lose all that plumbing and then you have to do more work in your program yourself.
You could use Java but then you just substitute the Java Runtime Environment for the .NET framework and have the same problem with large redistributable to accompany small program.
You could use Visual Basic 6. It does give you the drag-n-drop form designer IDE and it does avoid the Framework redistributable issue. But VB6 is a product approaching the end of its life. I'm not sure the Framework issue is so awful that it makes VB6 attractive. But there are a lot of VB6 fans out in the world who would strongly disagree with me so perhaps I'm just showing my own anti-VB6 bias.
http://msdn.microsoft.com/vbasic/support/vb6.aspx
AMGOT
Many thanks for your reply. Very helpful. Apologies for the delay in responding, I have been using the new Languages Forum..
Cheers
Geoff