Uruchomienie funkcji w klasie aplikacji

0

Witam. Chciałbym uruchomić funkcję "Start" znajdującą się w pliku .h z poziomu pliku .cpp, lecz mój sposób nie działa. Macie jakieś propozycje jak to zrobić ?

plik .h

#pragma once

namespace AppTest {
   
    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>
    /// Podsumowanie informacji o Formatka
    /// </summary>
   
    public ref class Formatka
: public System::Windows::Forms::Form
    {
    public:
        Formatka( void )
        {
            InitializeComponent();
            //
            //TODO: W tym miejscu dodaj kod konstruktora
            //
        }
       
    protected:
        /// <summary>
        /// Wyczyść wszystkie używane zasoby.
        /// </summary>
        ~Formatka()
        {
            if( components )
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Label ^ labelzegar;
    protected:
    private: System::Windows::Forms::Timer ^ timer1;
    private: System::Windows::Forms::Label ^ labeldeff;
       
    private: System::ComponentModel::IContainer ^ components;
       
       
    protected:
       
       
    protected:
       
    private:
        /// <summary>
        /// Wymagana zmienna projektanta.
        /// </summary>
       
       
        #pragma region Windows Form Designer generated code
        /// <summary>
        /// Metoda wymagana do obsługi projektanta — nie należy modyfikować
        /// jej zawartości w edytorze kodu.
        /// </summary>
        void InitializeComponent( void )
        {
            this->components =( gcnew System::ComponentModel::Container() );
            this->labelzegar =( gcnew System::Windows::Forms::Label() );
            this->timer1 =( gcnew System::Windows::Forms::Timer( this->components ) );
            this->labeldeff =( gcnew System::Windows::Forms::Label() );
            this->SuspendLayout();
            //
            // labelzegar
            //
            this->labelzegar->AutoSize = true;
            this->labelzegar->BackColor = System::Drawing::Color::Transparent;
            this->labelzegar->Font =( gcnew System::Drawing::Font( L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
            static_cast < System::Byte >( 238 ) ) );
            this->labelzegar->ForeColor = System::Drawing::Color::Red;
            this->labelzegar->Location = System::Drawing::Point( 4, 0 );
            this->labelzegar->Name = L"labelzegar";
            this->labelzegar->Size = System::Drawing::Size( 46, 13 );
            this->labelzegar->TabIndex = 0;
            this->labelzegar->Text = L"45.000";
            //
            // timer1
            //
            this->timer1->Interval = 50;
            this->timer1->Tick += gcnew System::EventHandler( this, & Formatka::timer1_Tick );
            //
            // labeldeff
            //
            this->labeldeff->AutoSize = true;
            this->labeldeff->BackColor = System::Drawing::Color::Transparent;
            this->labeldeff->Font =( gcnew System::Drawing::Font( L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
            static_cast < System::Byte >( 238 ) ) );
            this->labeldeff->ForeColor = System::Drawing::Color::FromArgb( static_cast < System::Int32 >( static_cast < System::Byte >( 0 ) ), static_cast < System::Int32 >( static_cast < System::Byte >( 0 ) ),
            static_cast < System::Int32 >( static_cast < System::Byte >( 192 ) ) );
            this->labeldeff->Location = System::Drawing::Point( 79, 0 );
            this->labeldeff->Name = L"labeldeff";
            this->labeldeff->Size = System::Drawing::Size( 31, 13 );
            this->labeldeff->TabIndex = 2;
            this->labeldeff->Text = L"      ";
            //
            // Formatka
            //
            this->AutoScaleDimensions = System::Drawing::SizeF( 6, 13 );
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size( 116, 13 );
            this->Controls->Add( this->labeldeff );
            this->Controls->Add( this->labelzegar );
            this->Name = L"Formatka";
            this->Text = L"Formatka";
            this->Load += gcnew System::EventHandler( this, & Formatka::Formatka_Load );
            this->ResumeLayout( false );
            this->PerformLayout();
           
        }
        #pragma endregion
       
    public:
       
        double czas, zapisanyczas;
       
    public:
       
        void Start()
        {
            czas = 45.000;
            timer1->Enabled = true;
            //labelzegar->Text = Convert::ToString(czas);
            //labeldeff->Text = Convert::ToString(zapisanyczas);
        }
       
    private: System::Void timer1_Tick( System::Object ^ sender, System::EventArgs ^ e )
        {
            czas -= 0.05;
            labelzegar->Text = Convert::ToString( czas );
        }
    private: System::Void Formatka_Load( System::Object ^ sender, System::EventArgs ^ e )
        {
        }
    };
}

Plik .cpp

#include "Formatka.h"

using namespace System;
using namespace System::Windows::Forms;

[ STAThread ]

void Main()
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault( false );
    AppTest::Formatka form;
    Application::Run( % form );
    form.Start(); // Start Timera (Nie dziala)
}
0

Z tego co pamiętam to timer uruchamiało się metodą "Start" timer1->Start(); , chociaż było to dawno temu i mogło się coś zmienić w tym względzie.

0

Nie. Tutaj jest funkcja, która jest wywoływana po odpaleniu timera

    private: System::Void timer1_Tick( System::Object ^ sender, System::EventArgs ^ e )
        {
            czas -= 0.05;
            labelzegar->Text = Convert::ToString( czas );
        }

1 użytkowników online, w tym zalogowanych: 0, gości: 1