{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
unit MainVolumeController;

interface

{$IFDEF KOL_MCK}
uses Windows, Messages, KOL, KOLMHTrackBar {$IFNDEF KOL_MCK}, mirror, Classes, Controls, mckControls, mckObjs, Graphics,  MCKMHTrackBar, mckCtrls {$ENDIF (place your units here->)}, VolumeController;
{$ELSE}
{$I uses.inc}
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
{$ENDIF}

type
  {$IFDEF KOL_MCK}
  {$I MCKfakeClasses.inc}
  {$IFDEF KOLCLASSES} {$I VolumeControllerFormclass.inc} {$ELSE OBJECTS} PVolumeControllerForm = ^TVolumeControllerForm; {$ENDIF CLASSES/OBJECTS}
  {$IFDEF KOLCLASSES}{$I TVolumeControllerForm.inc}{$ELSE} TVolumeControllerForm = object(TObj) {$ENDIF}
    Form: PControl;
  {$ELSE not_KOL_MCK}
  TVolumeControllerForm = class(TForm)
  {$ENDIF KOL_MCK}
    KOLProject: TKOLProject;
    KOLForm1: TKOLForm;
    tbVolume: TKOLMHTrackBar;
    tbBalance: TKOLMHTrackBar;
    cbMute: TKOLCheckBox;
    procedure KOLForm1FormCreate(Sender: PObj);
    procedure tbBalanceMouseMove(Sender: PControl;
      var Mouse: TMouseEventData);
    procedure tbVolumeMouseMove(Sender: PControl;
      var Mouse: TMouseEventData);
    procedure cbMuteClick(Sender: PObj);
  private
    VolumeController: TVolumeController;
  public
    { Public declarations }
  end;

var
  VolumeControllerForm {$IFDEF KOL_MCK} : PVolumeControllerForm {$ELSE} : TVolumeControllerForm {$ENDIF} ;

{$IFDEF KOL_MCK}
procedure NewVolumeControllerForm( var Result: PVolumeControllerForm; AParent: PControl );
{$ENDIF}

implementation

{$IFNDEF KOL_MCK} {$R *.DFM} {$ENDIF}

{$IFDEF KOL_MCK}
{$I MainVolumeController_1.inc}
{$ENDIF}

procedure TVolumeControllerForm.KOLForm1FormCreate(Sender: PObj);
begin
    VolumeController:= NewVolumeController;
    tbVolume.Max:= VolumeController.MaxVolume;
    tbVolume.Min:= VolumeController.MinVolume;
    tbVolume.Position:= tbVolume.Max - VolumeController.Volume;
    tbBalance.Position:= Round(VolumeController.Balance);
    cbMute.Checked:= VolumeController.Mute;
end;

procedure TVolumeControllerForm.tbBalanceMouseMove(Sender: PControl;
  var Mouse: TMouseEventData);
begin
    VolumeController.Balance:= tbBalance.Position;
end;

procedure TVolumeControllerForm.tbVolumeMouseMove(Sender: PControl;
  var Mouse: TMouseEventData);
begin
    VolumeController.Volume:= tbVolume.Max - tbVolume.Position;
end;

procedure TVolumeControllerForm.cbMuteClick(Sender: PObj);
begin
    VolumeController.Mute:= cbMute.Checked;
end;

end.



