Problem with static functions

Hi,
What I'm trying to do is recover information from a form in its parent class. Part of the code is shown below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//Some code before hand
frmRemove^ remove;
static System::Timers::Timer^ Timer;
static bool isAwaitingEvent = false;

static bool isAwaitingRemove = false;
static bool hasFinished;

static void Run(){
	Timer = gcnew System::Timers::Timer( 1000 );
	Timer->Elapsed += gcnew ElapsedEventHandler( OnTimedEvent );

	Timer->Enabled = true;
}
static void Stop(){
	Timer->Enabled = false;
}
static void OnTimedEvent( Object^ source, ElapsedEventArgs^ e ){
	if(isAwaitingEvent){
		if(isAwaitingRemove){
			hasFinished = remove->hasFinished;
		}
	}
// Remainder of code
}


Basically whats happening is that the main form has a button on it. Once the button is pressed, the main from is hidden and a child form is shown. The timer is started and there is a bool (hasFinished) that is set to true when the child form is hidden. The timer should then take that parameter into the parent form, but instead I get the error;

error C2227: left of '->hasFinished' must point to class/struct/union/generic type

I suspect it has something to do with the fact that the OnTimedEvent function is static because I can call the variable in other non-static functions, but I cant make OnTimedEvent non-static. Could anyone work out how to get around this?

Also, currently, Im trying to implement retrieving the information in a timer, but It would be preferable to be using an event instead, but Im not sure how to implement a custom event in that way. If anyone knows how to do so, I'd really appreciate the help.

Thanks in advance
Last edited on
Topic archived. No new replies allowed.