1

How can I convert project win32 console application into C++ Windows Form? This is my win32 console code but I want to convert it in C++ Windows Form.

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<string>
#include<iostream>

using namespace std;

const char TAB='\t';
char varlook;
char s[100];
char name[10];




char str[100],str1[100],str2[100],str3[100],str4[100],var[100];
    int i=0,l,l1,j=0,k=0,d=0;   
    int m=0;
    char keyword[100][100]={"int","float","char","double","if","else","for","while","do","auto","break","case","const",
                            "switch","continue","enum","extern","goto","short","register","return","sizeof","static",
                            "struct","typedef","union","void","while","signed","unsigned","default"};
void main(void)
{
gets(str);
while(str[i]!='\0')
{
while(isspace(str[i]))
i++;
if(isalpha(str[i]))
{
k=0;
while(isalnum(str[i]))
{
str1[k]=str[i];
i++;
k++;
}
str1[k]='\0';
l=0;
while(j<100)
{
if (strcmp(str1,keyword[j])==0)
{
l=1;
break;
}
j++;
}
if(l==1)
{
printf("\n   %s    ERROR- it is keyword ",str1);
break;
}
else
{
printf("\n   %s    Valid Identifier ",str1);
break;
l=0;
while(str1[l]!='\0')
{
var[m++]=str1[l++];
}
}
}
else if (isdigit(str[i]))
{
k=0;
while(isalnum(str[i]) || str[i]=='.')
{
if(str[i]=='.')
d++;
str2[k++]=str[i++];
}
printf("\n   %s    ERROR- it is digit ",str2);
break;
}
}

getche();
}

How can I convert project win32 console application into C++ Windows Form? This is my win32 console code but I want to convert it in C++ Windows Form.

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
Badsector
  • 21
  • 1
  • 5
  • 1
    You are having two different approaches of user interfaces. What makes You think,there can be a easy way to convert between them? The key-hitting interception is completely different than console, the output will need You to decide,how You want to have messages ( Popup, EditText Field,RichText, direct drawing on form .Let me summarize : You have two different approaches of inputting and outputting stuff. Input is made via some thing called message or messsagequeue in "windows-windows". Output also is done via this. Intercepting the right message and react to it is Your way. – icbytes Nov 13 '13 at 11:52
  • 2
    Pickup a book on it and learn. This is far too broad a subject for one question. – The Forest And The Trees Nov 13 '13 at 11:53
  • Your code (looks more like c than c++) will have to be totally rewritten to be used as a windows form. I would start clean and not even use this code as a guide. – drescherjm Nov 13 '13 at 14:09

1 Answers1

1

You can utilize C++/CLI

Create a CLR empty project. Add a new item Visual C++ / UI / Windows Form called MyForm add in MyForm.cpp

int main()
{
  Project1::MyForm^ dlg = gcnew Project1::MyForm;
  dlg->ShowDialog();
}

Then go and design your UI by adding a textbox for input, a button to evaluate the content and a label to show the result.

Add an event handler for the button, when you press the button read the contents of the textbox and display the result by putting it in the label box.

This will give you a barebone program but at least it gives you a quick framework.

I would suggest you use a more C++ way of specifying keywords e.g. with a std::vector or std::map - makes things so much easier.

AndersK
  • 35,813
  • 6
  • 60
  • 86