Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [c++] Effettuare il login con windows form

    Salve a tutti ragazzi.
    Ho bisogno di un aiuto ad un problema che non riesco a risolvere
    Ho creato un file di nome Accesso.h in cui tramite il programma visual c++ 2008 express edition di microsoft ho creato due textbox con nomi rispettivamente username_txb e password txb.
    Il contenuto del file accesso.h è il seguente
    Codice PHP:
    #pragma once

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;


    namespace 
    ProgettodannoSDambra {

        
    /// <summary>
        /// Riepilogo per Accesso
        ///
        /// AVVISO: se si modifica il nome della classe, sarà necessario modificare la
        ///          proprietà 'Nome file di risorse' relativa allo strumento Compilatore di risorse gestite
        ///          associato a tutti i file RESX da cui dipende la classe. In caso contrario,
        ///          le finestre di progettazione non saranno in grado di interagire correttamente con le
        ///          risorse localizzate associate al form.
        /// </summary>
        
    public ref class Accesso : public System::Windows::Forms::Form
        
    {
        public:
            
    Accesso(void)
            {
                
    InitializeComponent();
                
    //
                //TODO: aggiungere qui il codice del costruttore.
                //
            
    }

        protected:
            
    /// <summary>
            /// Liberare le risorse in uso.
            /// </summary>
            
    ~Accesso()
            {
                if (
    components)
                {
                    
    delete components;
                }
            }
        private: 
    System::Windows::Forms::Button^  login;
        private: 
    System::Windows::Forms::Label^  username_lab;
        private: 
    System::Windows::Forms::Label^  password_lab;
        private: 
    System::Windows::Forms::Label^  explain_lab;
        private: 
    System::Windows::Forms::TextBox^  username_txb;
        private: 
    System::Windows::Forms::TextBox^  password_txb;
        protected: 

        protected: 

        private:
            
    /// <summary>
            /// Variabile di progettazione necessaria.
            /// </summary>
            
    System::ComponentModel::Container ^components;

    #pragma region Windows Form Designer generated code
            /// <summary>
            /// Metodo necessario per il supporto della finestra di progettazione. Non modificare
            /// il contenuto del metodo con l'editor di codice.
            /// </summary>
            
    void InitializeComponent(void)
            {
                
    this->login = (gcnew System::Windows::Forms::Button());
                
    this->username_lab = (gcnew System::Windows::Forms::Label());
                
    this->password_lab = (gcnew System::Windows::Forms::Label());
                
    this->explain_lab = (gcnew System::Windows::Forms::Label());
                
    this->username_txb = (gcnew System::Windows::Forms::TextBox());
                
    this->password_txb = (gcnew System::Windows::Forms::TextBox());
                
    this->SuspendLayout();
                
    // 
                // login
                // 
                
    this->login->Font = (gcnew System::Drawing::Font(L"Tahoma"9.75FSystem::Drawing::FontStyle::RegularSystem::Drawing::GraphicsUnit::Point
                    
    static_cast<System::Byte>(0)));
                
    this->login->Location System::Drawing::Point(102192);
                
    this->login->Name L"login";
                
    this->login->Size System::Drawing::Size(7523);
                
    this->login->TabIndex 0;
                
    this->login->Text L"Accedi";
                
    this->login->UseVisualStyleBackColor true;
                
    this->login->Click += gcnew System::EventHandler(this, &Accesso::login_Click);
                
    // 
                // username_lab
                // 
                
    this->username_lab->AutoSize true;
                
    this->username_lab->Font = (gcnew System::Drawing::Font(L"Tahoma"9.75FSystem::Drawing::FontStyle::RegularSystem::Drawing::GraphicsUnit::Point
                    
    static_cast<System::Byte>(0)));
                
    this->username_lab->Location System::Drawing::Point(4969);
                
    this->username_lab->Name L"username_lab";
                
    this->username_lab->Size System::Drawing::Size(6616);
                
    this->username_lab->TabIndex 1;
                
    this->username_lab->Text L"Username";
                
    // 
                // password_lab
                // 
                
    this->password_lab->AutoSize true;
                
    this->password_lab->Font = (gcnew System::Drawing::Font(L"Tahoma"9.75FSystem::Drawing::FontStyle::RegularSystem::Drawing::GraphicsUnit::Point
                    
    static_cast<System::Byte>(0)));
                
    this->password_lab->Location System::Drawing::Point(50113);
                
    this->password_lab->Name L"password_lab";
                
    this->password_lab->Size System::Drawing::Size(6316);
                
    this->password_lab->TabIndex 2;
                
    this->password_lab->Text L"Password";
                
    // 
                // explain_lab
                // 
                
    this->explain_lab->AutoSize true;
                
    this->explain_lab->Font = (gcnew System::Drawing::Font(L"Tahoma"9.75FSystem::Drawing::FontStyle::BoldSystem::Drawing::GraphicsUnit::Point
                    
    static_cast<System::Byte>(0)));
                
    this->explain_lab->Location System::Drawing::Point(115);
                
    this->explain_lab->Name L"explain_lab";
                
    this->explain_lab->Size System::Drawing::Size(28132);
                
    this->explain_lab->TabIndex 3;
                
    this->explain_lab->Text L"Inserisci user e password\r\nper poter utilizzare il pannello di controllo.";
                
    this->explain_lab->TextAlign System::Drawing::ContentAlignment::TopCenter;
                
    // 
                // username_txb
                // 
                
    this->username_txb->Font = (gcnew System::Drawing::Font(L"Tahoma"9.75FSystem::Drawing::FontStyle::RegularSystem::Drawing::GraphicsUnit::Point
                    
    static_cast<System::Byte>(0)));
                
    this->username_txb->Location System::Drawing::Point(13967);
                
    this->username_txb->Name L"username_txb";
                
    this->username_txb->Size System::Drawing::Size(10023);
                
    this->username_txb->TabIndex 4;
                
    // 
                // password_txb
                // 
                
    this->password_txb->Font = (gcnew System::Drawing::Font(L"Tahoma"9.75FSystem::Drawing::FontStyle::RegularSystem::Drawing::GraphicsUnit::Point
                    
    static_cast<System::Byte>(0)));
                
    this->password_txb->Location System::Drawing::Point(139111);
                
    this->password_txb->Name L"password_txb";
                
    this->password_txb->Size System::Drawing::Size(13323);
                
    this->password_txb->TabIndex 5;
                
    // 
                // Accesso
                // 
                
    this->AutoScaleDimensions System::Drawing::SizeF(613);
                
    this->AutoScaleMode System::Windows::Forms::AutoScaleMode::Font;
                
    this->ClientSize System::Drawing::Size(284262);
                
    this->Controls->Add(this->password_txb);
                
    this->Controls->Add(this->username_txb);
                
    this->Controls->Add(this->explain_lab);
                
    this->Controls->Add(this->password_lab);
                
    this->Controls->Add(this->username_lab);
                
    this->Controls->Add(this->login);
                
    this->Name L"Accesso";
                
    this->Text L"Accesso";
                
    this->ResumeLayout(false);
                
    this->PerformLayout();

            }
    #pragma endregion
        
    private: System::Void login_Click(System::Object^  senderSystem::EventArgs^  e) {
                     
    acquisisci();
                     
    password_txb->Clear();
                 }
                 
    };

    Facendo doppio clic sul bottone ho aggiunto la funzione acquisisci(); che ""dovrebbe"" permettermi di acquisire i dati di username e password.
    Successivamente creando il file Accesso.cpp ci ho scritto:
    Codice PHP:
    #include "Accesso.h"
    #include <iostream>
    #include <string>
    using namespace std;
    using namespace System::Runtime::InteropServices;
    void verifica_login::Accesso::acquisisci()
    {
    int login;
    string 'username';
    string 'password';
    username Convert::ToString(username_txb->Text);
    password Convert::ToString(password_txb->Text);
    username == "user" && password == "pass" login '1' login '0';

    Ho creato il file main.cpp con il seguente contenuto
    Codice PHP:
    #include "Accesso.h"
    #include <iostream>
    #include <string>
    using namespace std;
    int main() {
        
    verifica_login::Accesso START;
        
    START.ShowDialog();

    ORA:
    vorrei che quando il viene cliccato il pulsante Accedi il programma controllasse che l'user inserito e la password e in caso di risposta affermativa aprisse un altra windows form dal nome finestra_principale in cui è contenuto un menu e chiudesse quella del login. In caso di risposta negativa ricaricasse la form Accesso per permettere nuovamente l'inserimento di username e password.
    Se volete potete trovare QUI tutti i file di cui ho parlato.
    In particolare se utilizzate visual c++ express edition basta incollare la cartella nella sezione projects e avrete in pratica il progetto con gli stessi file a disposizione.
    Aspetto risposte!! Grazie in anticipo a chi mi aiuterà

  2. #2
    Ragazzi risolto: della serie che ho fatto tutto io (grazie ad un mio amico)!
    Se volete vi posto i files corretti

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.