{ ' UNIT uMain.pas
'--------------------------- uMain -----------------------------
' Sample for SKAero API Module.. Main Application
' Copyright © 2018 BrewIdeas@Emil Weiss, All Rights Reserved
'
' Author(s) of this Unit: Emil Weiss
'
'---------------------------------------------------------------------------- }
unit uMain;
interface
{$R '_resources\Mixer.res' '_resources\Mixer.rc'}
{$IFDEF WIN64}
{$R '_resources\Manifest64.res'}
{$ELSE}
{$R '_resources\Manifest.res'}
{$ENDIF}
{$REGION 'Uses'}
uses Classes, Windows, Messages, ShellApi, CommCtrl, StrUtils, ShlObj, SysUtils, SKAeroAPI,
ActiveX,
uGlobal, Graphics, uControls, uIni, Dialogs, mmsystem, AudioVolume, StdCtrls, MMDevice, Math,
SimpleAudioVolume, AudioSessionControl, AudioSessionControl2, ProcessList;
{$ENDREGION}
{$REGION 'Functions / Procedures'}
function WinMain(hInstance: HINST; hPrevInstance: HINST; lpCmdLine: PChar; nCmdShow: integer)
: LRESULT;
stdcall;
procedure DetectBackground;
function WndProc(WinHandle: HWND; Msg: UINT; wP: WParam; lP: LParam): LRESULT;
stdcall;
procedure PlaySoundSlide;
procedure PlaySoundPush;
procedure PlaySoundBlup;
// AudioVolume
{$ENDREGION}
// TMainClass
{$REGION 'TMainClass'}
type
TMainClass =
class
procedure MasterDefaultDeviceChange(NewDefaultDevice: TDeviceInfo);
procedure MasterDeviceStateChange(DeviceId:
string; NewDeviceState: Cardinal);
procedure MasterVolumeEvent(Volume: Single; Mute: Boolean);
procedure AudioVolumeInitialize;
function CreateHBitmapFromImg(Img: LONG_PTR;
var imgW, imgH: integer): HBitmap;
procedure CreateMasterIcon(x, y: integer; IconHandle: UINT = 0);
procedure CreateSessionIcon(
Index: integer; x, y: integer; IconHandle: UINT = 0);
function CreateImgFromIcon(wsFile: WideString; IconHandle: UINT = 0): LONG_PTR;
procedure CreateSession;
function GetHIconFromFile(AFileName:
String; ASmall: Boolean = false; AIndex: integer = 0)
: HICON;
procedure SessionCreated(
const NewSession: IAudioSessionControl);
procedure SessionDisconnectedEvent(Sender: TCustomAudioVolume; DisconnectReason: UINT);
procedure SessionStateEvent(Sender: TCustomAudioVolume; NewState: integer);
procedure SessionVolumeEvent(Sender: TCustomAudioVolume; Volume: Single; Mute: Boolean);
procedure PropertyIconChanged(IconPath:
string);
procedure ShowOutputAttribute;
procedure RemovefromList(DeviceId:
string);
private
OldMute: Boolean;
{ private-Deklarationen }
OldSessionMute: Boolean;
SimpleVolume: ISimpleAudioVolume;
tmpAudioVolume: TAudioVolume;
public
{ public-Deklarationen }
DeviceName:
string;
Hint: WideString;
end;
{$ENDREGION}
{$REGION 'Global Variable'}
var
MainClass: TMainClass;
// MyThread: TSessionThread;
bMyVolSet: BOOL;
bAttribute: BOOL;
AudioVolume1: TAudioVolume;
AudioVolumeArr:
array of TAudioVolume;
GotChannelCount: Boolean = false;
ChannelCount: UINT;
Peaks:
array of Single;
lRes: integer;
Restart: BOOL;
m_Initialize: BOOL;
Second: DWORD;
{$ENDREGION}
implementation
// Animation
{$REGION 'RenderClock'}
procedure RenderClock;
var
Tick: DWORD;
begin
Tick := GetTickCount;
if (Second = 0)
then
Second := Tick + 1000;
if (Tick > Second)
then
begin
Second := 0;
gSprBackground.GD_SetObjectTextEx(ID_TIME_FRONT, PWideChar(TimeToStr(Now)), true);
end;
end;
{$ENDREGION}
// Sound
{$REGION 'Sound'}