Modyfikacja zmiennych z innych plików

0

Witam, mam mały problem z modyfikacją zmiennych z innego pliku.
Chodzi mi oto aby z pliku funkcja.h była możliwość modyfikowania zmiennej ProgressBaru

this->progressBar1->Value = 100; 

Kod Programu

Form1

 
#pragma once
#include "funkcja.h"

namespace T1 {

	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
	/// </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;
			}
		}
	public: System::Windows::Forms::ProgressBar^  progressBar1;
	protected: 

	protected: 
	private: System::Windows::Forms::Button^  OK;

	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->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
			this->OK = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// progressBar1
			// 
			this->progressBar1->Location = System::Drawing::Point(68, 71);
			this->progressBar1->Name = L"progressBar1";
			this->progressBar1->Size = System::Drawing::Size(367, 30);
			this->progressBar1->TabIndex = 0;
			this->progressBar1->Value = 1;
			// 
			// OK
			// 
			this->OK->Location = System::Drawing::Point(191, 148);
			this->OK->Name = L"OK";
			this->OK->Size = System::Drawing::Size(124, 21);
			this->OK->TabIndex = 1;
			this->OK->Text = L"OK";
			this->OK->UseVisualStyleBackColor = true;
			this->OK->Click += gcnew System::EventHandler(this, &Form1::OK_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(500, 197);
			this->Controls->Add(this->OK);
			this->Controls->Add(this->progressBar1);
			this->Name = L"Form1";
			this->Text = L"Program";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void OK_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 Check(1);
			 }
	};
}


funkcja.h

int Check(int a)
{

if(a == 1)
{
Form1->progressBar1->Value = 100;
return 1;
}
return 0;

}
 

Oczywiście zmienne progressbaru są na typie public:
Gdzie popełniłem błąd?

Proszę o pomoc.

0

Zapominałem dodać error:

 1>------ Build started: Project: T1, Configuration: Debug Win32 ------
1>  T1.cpp
1>c:\users\piotrek\documents\visual studio 2010\projects\t1\t1\funkcja.h(6): error C2065: 'Form1' : undeclared identifier
1>c:\users\piotrek\documents\visual studio 2010\projects\t1\t1\funkcja.h(6): error C2227: left of '->progressBar1' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>c:\users\piotrek\documents\visual studio 2010\projects\t1\t1\funkcja.h(6): error C2227: left of '->Value' must point to class/struct/union/generic type
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0

Form1 to typ danych, musisz do tej funkcji przekazać wskaźnik lub referencje do konkretnego obiektu typu Form1.

0

Czyli jak to zrobić?

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