Thread: I am trying to use .net and im having problems

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    3

    I am trying to use .net and im having problems

    Ok so what im trying to do is make an application that has a window with three input boxes and 1 buttons, two of the input boxes store data that input by the user and the other input box displays a sequence of random numbers and letters after the button is clicked..... i have the basic layout composed, attached is a screenshot of the basic layout, and here is my current code:



    My form code:
    Code:
    #pragma once
    
    
    namespace ExampleForSit {
    
    	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: System::Windows::Forms::TextBox^  textBox1;
    	private: System::Windows::Forms::TextBox^  textBox2;
    	private: System::Windows::Forms::TextBox^  textBox3;
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::Label^  label2;
    	private: System::Windows::Forms::Label^  label3;
    
    	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->textBox1 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->label3 = (gcnew System::Windows::Forms::Label());
    			this->SuspendLayout();
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(12, 94);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(110, 23);
    			this->button1->TabIndex = 0;
    			this->button1->Text = L"Generator Button";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    			// 
    			// textBox1
    			// 
    			this->textBox1->Location = System::Drawing::Point(128, 97);
    			this->textBox1->Name = L"textBox1";
    			this->textBox1->Size = System::Drawing::Size(152, 20);
    			this->textBox1->TabIndex = 1;
    			// 
    			// textBox2
    			// 
    			this->textBox2->Location = System::Drawing::Point(12, 68);
    			this->textBox2->Name = L"textBox2";
    			this->textBox2->Size = System::Drawing::Size(100, 20);
    			this->textBox2->TabIndex = 2;
    			// 
    			// textBox3
    			// 
    			this->textBox3->Location = System::Drawing::Point(12, 29);
    			this->textBox3->Name = L"textBox3";
    			this->textBox3->Size = System::Drawing::Size(100, 20);
    			this->textBox3->TabIndex = 3;
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(13, 13);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(58, 13);
    			this->label1->TabIndex = 4;
    			this->label1->Text = L"Input here:";
    			this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(13, 52);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(58, 13);
    			this->label2->TabIndex = 5;
    			this->label2->Text = L"Input here:";
    			// 
    			// label3
    			// 
    			this->label3->AutoSize = true;
    			this->label3->Location = System::Drawing::Point(128, 81);
    			this->label3->Name = L"label3";
    			this->label3->Size = System::Drawing::Size(152, 13);
    			this->label3->TabIndex = 6;
    			this->label3->Text = L"Randomly generated text here:";
    			this->label3->Click += gcnew System::EventHandler(this, &Form1::label3_Click);
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(292, 129);
    			this->Controls->Add(this->label3);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->label1);
    			this->Controls->Add(this->textBox3);
    			this->Controls->Add(this->textBox2);
    			this->Controls->Add(this->textBox1);
    			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);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    	private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
    			 }
    private: System::Void label3_Click(System::Object^  sender, System::EventArgs^  e) {
    		 }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    		 }
    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    		 }
    };
    }

    My Assembly Code:

    Code:
    #include "stdafx.h"
    
    using namespace System;
    using namespace System::Reflection;
    using namespace System::Runtime::CompilerServices;
    using namespace System::Runtime::InteropServices;
    using namespace System::Security::Permissions;
    
    //
    // General Information about an assembly is controlled through the following
    // set of attributes. Change these attribute values to modify the information
    // associated with an assembly.
    //
    [assembly:AssemblyTitleAttribute("ExampleForSit")];
    [assembly:AssemblyDescriptionAttribute("")];
    [assembly:AssemblyConfigurationAttribute("")];
    [assembly:AssemblyCompanyAttribute("")];
    [assembly:AssemblyProductAttribute("ExampleForSit")];
    [assembly:AssemblyCopyrightAttribute("Copyright (c)  2007")];
    [assembly:AssemblyTrademarkAttribute("")];
    [assembly:AssemblyCultureAttribute("")];
    
    //
    // Version information for an assembly consists of the following four values:
    //
    //      Major Version
    //      Minor Version
    //      Build Number
    //      Revision
    //
    // You can specify all the value or you can default the Revision and Build Numbers
    // by using the '*' as shown below:
    
    [assembly:AssemblyVersionAttribute("1.0.*")];
    
    [assembly:ComVisible(false)];
    
    [assembly:CLSCompliantAttribute(true)];
    
    [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];



    Finally my "Main" code:

    Code:
    // Example For Sit.cpp : main project file.
    
    #include "stdafx.h"
    #include "Form1.h"
    
    using namespace ExampleForSit;
    
    [STAThreadAttribute]
    int main(array<System::String ^> ^args)
    {
    	// Enabling Windows XP visual effects before any controls are created
    	Application::EnableVisualStyles();
    	Application::SetCompatibleTextRenderingDefault(false); 
    
    	// Create the main window and run it
    	Application::Run(gcnew Form1());
    	return 0;
    }
    Yea so thats what i want to do, if anyone else has a link to where a source code or tutorial of this is already posted then i would love some help.... and yes i know .net sometimes is veiwed as "evil" but it makes the best windows applications, so if u can tell me how to create a good looking windows app without using .net then also feel free. Finally if htere is any code i am missing or files that need to be included to help me out just tell me and i can upload them....

    Ty

    Fargs

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    That looks like C# or windows code. You may have better luck posting on either of those boards, from the output sample, i'm guessing windows
    Double Helix STL

  3. #3
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    Okay, so you dragged and dropped a UI, but if you take out the generated code from the dragging and dropping, you're basically giving us this and asking us to fill in the blanks:
    Code:
    int main() {
    }
    This probably sounds mean, but do you know anything about writing .NET programs? VS generated code with default control names, all empty events, and events that aren't needed makes me think that you can point and click but have no clue how to write code to make the UI actually work.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Moved to C#
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    But it's managed C++, not C#...

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    OK then, moved again to the windows programming board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Mar 2007
    Posts
    3
    Yeah, i know C++, but your right i am trying to devl into the realm of UI writing and making Apps rather than just the normal Prompt window for C++ codes.... and im not asking you to fill in the blanks, if there are tutorials out there i would prefer those... because then i would actually learn something but i want to learn how to do what i said above, (save info from and input box(define that input box as an input box) if needed, and have an even happen when a button is clicked, i know im a nub and don't know alot about UI coding and what not but i want to learn and anything that could point me in the right direction would be helpful, like you said
    Okay, so you dragged and dropped a UI
    yes i did drag and drop the UI but i want to know how to interact/program with the UI i dragged and dropped....

    Ty
    Fargs

Popular pages Recent additions subscribe to a feed