2015-06-28 7 views
0

Я создал проект консоли Console Win32 в Visual Studio 2012 C++.Замена окна консоли Windows Forms

Как я могу заменить окно консоли более привлекательным графическим интерфейсом, например Windows Forms?

int32_t main(int32_t argc, char* argv[]) 
{ 
const char *date = "20150428_1\\"; 
int  mode=0; 
_CallServerPtr  pCallServer; 
uint32_t start_address_comp=0; 
uint32_t start_address_module=0; 
const char* xmlFile_tx_dbb="tx_dbb.xml";; 
char str[100] = "\0"; 
char localeStr[64]; 
memset(localeStr, 0, sizeof localeStr); 
const char *l_path = "..\\XERCES\\Configs\\"; 
std::string buf = ""; 
double Fsym_Hz=(1/1.15)*1e9; 
int selection=0; 
int user_selection=0; 


try 
{ 
    if (strlen(localeStr)) 
    { 
     XMLPlatformUtils::Initialize(localeStr); 
    } 
    else 
    { 
     XMLPlatformUtils::Initialize(); 
    } 
} 

catch (const XMLException& toCatch) 
{ 
    XERCES_STD_QUALIFIER cerr << "Error during initialization! :\n" 
      << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; 
} 


static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull }; 

DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS); 
DOMLSParser  *parser = ((DOMImplementationLS*)impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0); 
DOMConfiguration *config = parser->getDomConfig(); 
DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer(); 
DOMLSOutput  *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput(); 



config->setParameter(XMLUni::fgDOMDatatypeNormalization, true); 


DOMCountErrorHandler errorHandler; 
config->setParameter(XMLUni::fgDOMErrorHandler, &errorHandler); 
XERCES_STD_QUALIFIER ifstream fin; 

//reset error count first 
errorHandler.resetErrors();*/ 

// reset document pool 
parser->resetDocumentPool(); 


char* pszHostname = NULL; 
pSaIn = 0; 
pSaOut = 0; 

// Initialize the COM Library 
CoInitialize(NULL); 


    if (!pszHostname) 
    { 
     // Create the CallServer server object on the local computer 
     pCallServer.CreateInstance(CLSID_CallServer); 
    } 

    if (pCallServer == NULL) 
     throw "Failed to create the CallableVEE CallServer object"; 


// Load the VEE User Function library 
    char strpath[256]; 
    strcpy (strpath,reposity_path); 
    strcat (strpath,l_path_vee); 

    _bstr_t bstrLibPath(strpath); 
    LibraryPtr pLib = pCallServer->GetLibraries()->Load(bstrLibPath); 
    // Print out the names of the UserFunctions in this library. 
    UserFunctionsPtr pUserFuncColl = pLib->GetUserFunctions(); 

    VARIANT_BOOL bDebug = VARIANT_FALSE; 

    pCallServer->PutDebug(bDebug); 


    // Variables added by ivi 
    float *freq =(float *)_aligned_malloc(6,16); // Read frequency vector 
    // Previous variables 
    int32_t devIdx; 
    int32_t modeClock; 
    int32_t ifType; 
    const char *devType; 
    char fpga_device_type[32]; 
    int32_t rc; 
    int32_t ref_clk=0; 
    uint32_t carrier=0; 
    uint32_t odelay_dac0 = 0; 
    uint32_t odelay_dac1 = 0; 




    // Parse the application arguments 
    if(argc!=5) { 
      printf("Usage: FMCxxxApp.exe {interface type} {device type} {device index} {clock mode} \n\n"); 
      printf(" {interface type} can be either 0 (PCI) or 1 (Ethernet). At CEIT, we use 1 (Ethernet).\n"); 
      printf(" {device type} is a string defining the target hardware (VP680, ML605, ...). At CEIT, we use VC707.\n"); 
      printf(" {device index} is a PCI index or an Ethernet interface index. This value depends on the PC.\n"); 
      printf(" {clock mode} can be either 0 (Int. Clock) or 1 (Ext. Clock)\n"); 
      printf("\n"); 
      printf("\n"); 
      printf("Example: Fmc230APP.exe 1 VC707 0 0\n"); 
      printf("\n"); 
      printf("\n"); 
      printf(" List of NDIS interfaces found in the system {device index}:\n"); 
      printf(" -----------------------------------------------------------\n"); 
      if(sipif_getdeviceenumeration(API_ENUM_DISPLAY)!=SIPIF_ERR_OK) { 
        printf("Could not obtain NDIS(Ethernet) device enumeration...\n Check if the 4dspnet driver installed or if the service started?\n"); 
        printf("You can discard this error if you do not have any Ethernet based product in use."); 
      } 

      if(EXIT_IF_ERRORS) 
      { 
       sipif_free(); 
       system("pause"); 
       return -1; 
      } 
     ... 
    } 

ответ

1

Вы имеете в виду тот же код в окнах. Это не сработает. Команды printf и другие команды работают только в консольном приложении. Вы должны создать приложение формы Windows и переписать код для него. Вы должны переписать все команды, которые не работают в приложении формы Windows. Вероятно, существует приложение для конверсии, но для этого короткого кода я думаю, что его лучше переписать.

+0

спасибо. Я уже заменил все команды, которые, как я догадался, не будет работать («printf» в Message Boxes). Проблема в том, что когда я нажимаю кнопку, которая должна запускать функцию, которая использует некоторые из указанных выше переменных в качестве входных аргументов (представьте, что я хочу добавить два из них), я получаю сообщение об ошибке, что переменные не являются инициализируется. Где и как написать код выше, чтобы быть доступным для любой кнопки любой формы? – fjavier