Hello
,
Here My Problem:
I Have a ComboBox and implemented its OnChange Event:
procedure TFormSW.CmbOpeningChange(Sender: TObject);
begin
case CmbOpening.ItemIndex of
0: begin // volle Öffnung
Label46.Visible := True;
Label19.Visible := True;
Label20.Visible := True;
Label50.Visible := True;
Label51.Visible := True;
Command5.Visible := False;
Command6.Visible := False;
end;
1: begin // halbe Öffnung oben
Label46.Visible := True;
Label19.Visible := True;
Label20.Visible := True;
Label50.Visible := True;
Label51.Visible := True;
Command5.Visible := True;
Command6.Visible := True;
end;
2: begin // halbe Öffnung unten
Label46.Visible := True;
Label19.Visible := True;
Label20.Visible := True;
Label50.Visible := True;
Label51.Visible := True;
Command5.Visible := True;
Command6.Visible := True;
end;
3: begin // keine Öffnung
TxBtDp.Text:= '0';
Label46.Visible := False;
Label19.Visible := False;
Label20.Visible := False;
Label50.Visible := False;
Label51.Visible := False;
Command5.Visible := False;
Command6.Visible := False;
end;
end;
end;
and i Have another Class which is My Controller
procedure OeffnungChanged();
begin
Case OeffIND Of
0: CalcOpening0(KlapIND, AnordIND);
1: CalcOpening1(KlapIND, AnordIND);
2: CalcOpening2(KlapIND, AnordIND);
3: begin // keine Öffnung
KpX1:= 0;
KpX2:= 0;
KpY1:= 0;
KpY2:= 0;
KpZ1:= 0;
KpZ2:= 0;
end;
End;
end;
How do i Notify the Controller about the Changes ?
i currently do it like this:
Cntlr.OeffnungChanged; //Cntlr = Controller
Anyway this seems not that effective.
i tried to use Observers but thats still a bit too complex for me. Then i was trying to do it via TNotifyEvent, but i was also to stupid to understand how this will work.
Could Someone provide a Sollution how to hande this interface between this classes ?
I would like to achieve something similar to MVC or MVVM to make my code more readable and easier to use. Got a Model, View and Controller, but i don't realy know how to handle the Connections between them. I ask myself a lot how to pass Data, how to Notify any of those classes or how to access those classes. i always end up with the same messy Code.