Visual c, formulare und cosole... noobfrage



  • Also hab hier ein c programm mit visual c++ bearbeitet und erweitert,
    manche Dateien haben aber auch cpp als Endung.
    Das finde schon etwas merkwürdig. Egal...

    Das Programm läuft jetzt und gibt Dinge in der Konsole aus. Jetzt würde ich gerne ein Formular aufrufen können mitdem eingaben und Ausgaben gemacht werden können.

    Dieses würde ich dann auch gerne so bearbeiten können,
    wie man es bei visual gewöhnt ist....

    habe mir diesen threat mal angeschaut:
    http://www.c-plusplus.net/forum/viewtopic-var-p-is-57547.html

    Ich kann allerdings eine unit2.h nirgends auf meinem rechner finden.

    Hat jemand nen tipp für mich??

    thx 😃



  • Du bist bei deiner Suche in die Kategorie VCL gerutscht, war das Absicht? Für den Umstieg von C auf VC++ empfehle ich dir dringend ein Tutorial durchzuarbeiten, um die Grundlagen zu lernen. In den FAQ gibts hierzu einige Links.
    Des Weiteren stellt sich die Frage in welche Richtung du gehen willst: Windows Forms, MFC, VCL,... Das solltest du dir vorab gut überlegen. Hier im Forum gibt es auch dazu reichlich Tipps.



  • steffen$$ schrieb:

    manche Dateien haben aber auch cpp als Endung.
    Das finde schon etwas merkwürdig. Egal...

    Merkwürdig?! cpp steht für C++ (Zeh-Plus-Plus!) und ist die Standard-Erweiterung für C++-Code-Dateien... 🙄 .h-Dateien sidn übrigens Header...

    Erstelle einfach ein neues MFC-Projekt, dann hast du ja schon einen Dialog ud kannst darauf aufbauen. Dein Link bezieht sich übrigens nicht auf MFC, sondern auf VCL (C++ Builder). Das ist ein ganz anderes Gebiet.



  • sorry, wenn ich falsch gelandet bin...

    danke für den rat, allerdings wollte ich blos wissen, ob das generell möglich ist und welche Befehle ich dafür brauche.
    greetz



  • steffen$$ schrieb:

    sorry, wenn ich falsch gelandet bin...

    danke für den rat, allerdings wollte ich blos wissen, ob das generell möglich ist und welche Befehle ich dafür brauche.
    greetz

    Du erstellt ein neues MFC-Projekt (dialogfeldbasierend), so hast du schon mal einen ersten Dialog (mehr brauchst du erstmal nicht). Dann ziehst du ein paar Edit Controls (Eingabefelder) und Static Controls (reine Textfelder ohne Eingabemöglichkeit) per C&P auf den Dialog, und vielleicht noch 'nen Button. Der Benutzer kann dann was in die Edits eingeben. Das Eingegebene kannst du im Event-Handler deiner Wahl (z.B. auch Button-Klick) über verschiedene Funktionen holen (z.B. GetWindowText). Die Ausgabe machst du, indem du deinen Statics einen Text zuweist (z.B. SetWindowText). Soweit klar? Das sollten genug Stichwörter sein.



  • Ich hatte das auch schon so ähnlich probiert.
    allerdings hab ich den code der schon fertig ist nicht zum laufen bekommen.

    Kann ich nicht ein Formular aufrufen?
    In meinem Programm wird dies schon getan, allerdings vermute ich, dass der code in einer dll steckt.

    Diese funktion ruft ein Fenster auf, indem man etwas auswählen kann und schließt sich nach der Benutzereingabe (im hintergrund bleibt die konsole)

    void SelectDevice( BOOL fUserSelect )
    {
      HRESULT hResult; // error code
    
       (fUserSelect == FALSE)
      {
        HANDLE        hEnum;   // enumerator handle
        VCIDEVICEINFO sInfo;   // device info
    
        //
        // open the device list
        //
        hResult = vciEnumDeviceOpen(&hEnum);
    
        //
        // retrieve information about the first
        // device within the device list
        //
        if (hResult == VCI_OK)
        {
          hResult = vciEnumDeviceNext(hEnum, &sInfo);
        }
    
        //
        // close the device list (no longer needed)
        //
        vciEnumDeviceClose(hEnum);
    
        //
        // open the device
        //
        if (hResult == VCI_OK)
        {
          hResult = vciDeviceOpen(&sInfo.VciObjectId, &hDevice);
        }
    
        //
        // always select controller 0
        //
        lCtrlNo = 0;
      }
      else
      {
        //
        // open a device selected by the user
        //
        hResult = SocketSelectDlg(NULL, VCI_BUS_CAN, &hDevice, &lCtrlNo);
      }
    
      DisplayError(hResult);
    }
    


  • also, hab jetzt rausgefunden, dass über die Funktion vciEnumDeviceOpen(&hEnum) ein Dialogfenster geöffnet wird.
    Allerdings finde ich keinen Befehl, der mir erklärt wie das gemacht wurde...

    Da müsste es doch was geben um ein Dialogfenster zu öffnen!? 😕 😕 😕



  • Mach es doch so wie Matze meinte: neues Projekt erstellen und deine C-Funktionen integrieren.



  • gut, ich versuche das gerade.

    leider bekomme ich diese errors:

    VC\include\sal.h(226) : error C2598: linkage specification must be at global scope

    VC\include\vadefs.h(36) : error C2598: linkage specification must be at global scope

    VC\include\crtdefs.h(170) : error C2598: linkage specification must be at global scope

    VC\include\crtdefs.h(2042) : fatal error C1903: unable to recover from previous error(s); stopping compilation

    das hängt wohl irgendwie mit der mischung von c und c++ zusammen, aber was soll ich nun machen?





  • danke, auf der seite war ich auch schon, nur verstanden hab ich nichts.

    Ich kann doch nicht in den dateien rumbasteln, die includiere?!

    wo soll ich das denn global definieren?



  • Erstelle mal ein neues MFC-Projekt und kompiliere es. Das wird erwartungsgemäß klappen. Dann fügst du solange Schritt für Schritt einzelne Teile deines Codes ins Projekt ein und kompilierst das Ganze, bis der Fehler wieder auftritt. So kannst du den Fehler genau lokalisieren. Denn in MS-eigenen Headern wird wohl kaum ein solcher Fehler sein.

    Vielleicht ist es auch nur eine vergessene Klammer o.ä. ...



  • Also, der fehler kommt wohl von den includes.
    Wo soll ich die denn reinpacken?

    so kompiliert ers fehlerfrei, aber ob das auch richtig ist?!

    #pragma once
    
    #include <vcinpl.h>
    #include <process.h>
    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
    #include <stdlib.h>
    #include "select.hpp"
    
    namespace CANbootloader {
    
    	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::Button^  button1;
    	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->button1 = (gcnew System::Windows::Forms::Button());
    			this->SuspendLayout();
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(53, 203);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(75, 23);
    			this->button1->TabIndex = 0;
    			this->button1->Text = L"button1";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(631, 273);
    			this->Controls->Add(this->button1);
    			this->Name = L"Form1";
    			this->Text = L"Form1";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    
    		}
    #pragma endregion
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    
    			 }
    	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    			 }
    	};
    }
    

    btw: danke für deien mühe 😉



  • ich wieder...

    kann ich denn meinen code bei folgendem einfügen?

    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    
                 }
    

    müssen die variablen woanders deklariert werden? Ich bekomme nämlich jetzt diese fehler hier:

    warning C4101: 'i' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(135) : warning C4101: 'ptime_stamp' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(138) : warning C4101: 'num' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(134) : warning C4101: 'pmsgid' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(136) : warning C4101: 'temp' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(133) : warning C4101: 'pdata' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(140) : warning C4101: 'k' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(140) : warning C4101: 'c' : unreferenced local variable
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(131) : warning C4101: 'bChar' : unreferenced local variable
    Linking...

    dann folgen noch einige errors...



  • Hör mal, was du da machst, ist C++/CLI (managed C++). Das ist was anderes als VC++ mit MFC. Du solltest damit auch ins passende Board:

    http://www.c-plusplus.net/forum/viewforum-var-f-is-58.html

    Erst versuchst du, ein VCL-Beispiel umzusetzen, und dann kommt raus, dass du C++/CLI programmierst... und alles im MFC-Forum! 😉 Informier dich am besten mal über die verschiedenen Sprachen und Frameworks/Bibliotheken, die es so gibt. Sonst stolperst du immer wieder...

    Übrigens, warum postest du nur die Warnings und nicht die Fehler? Die Warnungen sagen einfach, dass du Variablen deklarierst, die du gar nicht benutzt. Zu unbekannten Fehlern kann ich natürlich nix sagen...



  • danke, dass du so geduldig bist 😃

    ne, mit diesem ganzen visual kram kenn ich mich nicht aus und ich hab (leider) auch nicht die zeit mich mit allem auseinander zu setzen. Ich muss allerdings damit was für die Arbeit schreiben, bzw. ein fertiges Programm ändern...
    Es soll nunmal jetzt eine graphische Oberfläche geben 🙄

    naja, mit den Fehlern kann ich mal so garnichts anfangen:

    CAN bootloader.obj : error LNK2028: unresolved token (0A00000E) "void __clrcall ReceiveThread(void *)" (?ReceiveThread@@$$FYMXPAX@Z) referenced in function "private: void __clrcall CANbootloader::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@CANbootloader@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    CAN bootloader.obj : error LNK2028: unresolved token (0A000010) "void __clrcall InitSocket(unsigned int)" (?InitSocket@@$$FYMXI@Z) referenced in function "private: void __clrcall CANbootloader::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@CANbootloader@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    CAN bootloader.obj : error LNK2028: unresolved token (0A000011) "void __clrcall SelectDevice(int)" (?SelectDevice@@$$FYMXH@Z) referenced in function "private: void __clrcall CANbootloader::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@CANbootloader@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    CAN bootloader.obj : error LNK2019: unresolved external symbol "void __clrcall ReceiveThread(void *)" (?ReceiveThread@@$$FYMXPAX@Z) referenced in function "private: void __clrcall CANbootloader::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@CANbootloader@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    CAN bootloader.obj : error LNK2019: unresolved external symbol "void __clrcall InitSocket(unsigned int)" (?InitSocket@@$$FYMXI@Z) referenced in function "private: void __clrcall CANbootloader::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@CANbootloader@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    CAN bootloader.obj : error LNK2019: unresolved external symbol "void __clrcall SelectDevice(int)" (?SelectDevice@@$$FYMXH@Z) referenced in function "private: void __clrcall CANbootloader::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@CANbootloader@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    D:\Programme\IXXAT\CAN_bootloader\CAN bootloader\Debug\CAN bootloader.exe : fatal error LNK1120: 6 unresolved externals
    


  • google ist mein freund...

    habs jetzt auf "no runtime linking" gestellt.
    neuer fehler 😃

    .\AssemblyInfo.cpp(3) : error C2871: 'System' : a namespace with this name does not exist
    .\AssemblyInfo.cpp(4) : error C2653: 'System' : is not a class or namespace name
    .\AssemblyInfo.cpp(4) : error C2871: 'Reflection' : a namespace with this name does not exist
    .\AssemblyInfo.cpp(5) : error C2653: 'System' : is not a class or namespace name
    .\AssemblyInfo.cpp(5) : error C2871: 'CompilerServices' : a namespace with this name does not exist
    .\AssemblyInfo.cpp(6) : error C2653: 'System' : is not a class or namespace name
    .\AssemblyInfo.cpp(6) : error C2871: 'InteropServices' : a namespace with this name does not exist
    .\AssemblyInfo.cpp(7) : error C2653: 'System' : is not a class or namespace name
    .\AssemblyInfo.cpp(7) : error C2871: 'Permissions' : a namespace with this name does not exist
    .\AssemblyInfo.cpp(14) : error C2337: 'AssemblyTitleAttribute' : attribute not found
    .\AssemblyInfo.cpp(15) : error C2337: 'AssemblyDescriptionAttribute' : attribute not found
    .\AssemblyInfo.cpp(16) : error C2337: 'AssemblyConfigurationAttribute' : attribute not found
    .\AssemblyInfo.cpp(17) : error C2337: 'AssemblyCompanyAttribute' : attribute not found
    .\AssemblyInfo.cpp(18) : error C2337: 'AssemblyProductAttribute' : attribute not found
    .\AssemblyInfo.cpp(19) : error C2337: 'AssemblyCopyrightAttribute' : attribute not found
    .\AssemblyInfo.cpp(20) : error C2337: 'AssemblyTrademarkAttribute' : attribute not found
    .\AssemblyInfo.cpp(21) : error C2337: 'AssemblyCultureAttribute' : attribute not found
    .\AssemblyInfo.cpp(34) : error C2337: 'AssemblyVersionAttribute' : attribute not found
    .\AssemblyInfo.cpp(36) : error C2337: 'ComVisible' : attribute not found
    .\AssemblyInfo.cpp(38) : error C2337: 'CLSCompliantAttribute' : attribute not found
    .\AssemblyInfo.cpp(40) : error C2337: 'SecurityPermission' : attribute not found
    .\AssemblyInfo.cpp(40) : error C2653: 'SecurityAction' : is not a class or namespace name
    .\AssemblyInfo.cpp(40) : error C2065: 'RequestMinimum' : undeclared identifier
            missing quotes ("") around 'RequestMinimum'?
    CAN bootloader.cpp
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(49) : error C2871: 'System' : a namespace with this name does not exist
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(50) : error C2653: 'System' : is not a class or namespace name
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(50) : error C2871: 'ComponentModel' : a namespace with this name does not exist
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(51) : error C2653: 'System' : is not a class or namespace name
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(51) : error C2871: 'Collections' : a namespace with this name does not exist
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(52) : error C2653: 'System' : is not a class or namespace name
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(52) : error C2871: 'Forms' : a namespace with this name does not exist
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(53) : error C2653: 'System' : is not a class or namespace name
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(53) : error C2871: 'Data' : a namespace with this name does not exist
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(54) : error C2653: 'System' : is not a class or namespace name
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(54) : error C2871: 'Drawing' : a namespace with this name does not exist
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(65) : error C2059: syntax error : 'public'
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(65) : error C2059: syntax error : 'public'
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(65) : error C2653: 'System' : is not a class or namespace name
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(66) : error C2143: syntax error : missing ';' before '{'
    d:\programme\ixxat\can_bootloader\can bootloader\can bootloader\Form1.h(66) : error C2447: '{' : missing function header (old-style formal list?)
    .\CAN bootloader.cpp(8) : error C2337: 'STAThreadAttribute' : attribute not found
    .\CAN bootloader.cpp(9) : error C2065: 'array' : undeclared identifier
    .\CAN bootloader.cpp(9) : error C2653: 'System' : is not a class or namespace name
    .\CAN bootloader.cpp(9) : error C2065: 'String' : undeclared identifier
    .\CAN bootloader.cpp(9) : error C2059: syntax error : '>'
    .\CAN bootloader.cpp(10) : error C2143: syntax error : missing ';' before '{'
    .\CAN bootloader.cpp(10) : error C2447: '{' : missing function header (old-style formal list?)
    


  • solangsam bekomme ich hier noch nen anfall 😡

    die lösung für den oberen fehler ist auf "common runtime support" umzustellen.
    dann hab ich aber wieder der fehler davor (der geht nur weg, wenn "NO common runtime support" eingestellt ist)
    WAS NUN?
    😡 😡 😡 😡 😡 😡


Anmelden zum Antworten