[英]How Can I call a C++ Win32 DLL from another C++ win32 Console Application
[英]How can I convert project win32 console application into C++ Windows Form?
如何將項目win32控制台應用程序轉換為C ++ Windows窗體? 這是我的win32控制台代碼,但我想用C ++ Windows窗體轉換它。
#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();
}
如何將項目win32控制台應用程序轉換為C ++ Windows窗體? 這是我的win32控制台代碼,但我想用C ++ Windows窗體轉換它。
我認為這可能有效:
右鍵單擊項目,屬性,鏈接器,系統,更改子系統設置。 您還必須將main()方法更改為WinMain()。 你最好創造一些窗戶,或者沒有太多可看的東西。
您可以使用C ++ / CLI
創建一個CLR空項目。 在MyForm.cpp中添加一個名為MyForm add的新項目Visual C ++ / UI / Windows Form
int main()
{
Project1::MyForm^ dlg = gcnew Project1::MyForm;
dlg->ShowDialog();
}
然后通過添加用於輸入的文本框,用於評估內容的按鈕和用於顯示結果的標簽來設計UI。
為按鈕添加事件處理程序,當您按下按鈕時,讀取文本框的內容並將結果顯示在標簽框中。
這將為您提供一個准系統程序,但至少它為您提供了一個快速框架。
我建議你使用更多的C ++方式來指定關鍵字,例如使用std :: vector或std :: map - 使事情變得更加容易。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.