procedure CreateVolumeCtrl(Index: Integer; UseFont: string; x1, y1, w, h: Integer; FontSize: Integer;
Color: COLORREF; UseText: PWideChar);
var
x, y: Integer;
nX, nY: Integer;
hBmp, hThumb: HBitmap;
bmW, bmH: cardinal;
IbmW, IbmH: Integer;
ID: Integer;
begin
// Hintergrund
hBmp := gSprCtrl.GI_CreateBitmapFromFile(PWideChar(SpriteResPath + 'LBottom.png'), bmW, bmH);
if (hBmp <> 0) then
begin
ParentWidth := bmW;
ParentHeight := bmH;
ID := ID_BVOLUME + Index;
gSprCtrl.GD_DrawBitmapToCtrl(HSprCtrl, x1, y1, hBmp, gSprCtrl.GD_ColorARGB(255, 0), ID, GS_VISIBLE);
gSprCtrl.GD_SetObjectLinked(ID, ID);
gSprCtrl.GD_SetObjectLocked(ID, true);
// Vordergrund
hBmp := gSprCtrl.GI_CreateBitmapFromFile(PWideChar(SpriteResPath + 'LTop.png'), bmW, bmH);
if (hBmp <> 0) then
begin
ID := ID_TVOLUME + Index;
gSprCtrl.GD_DrawBitmapToCtrl(HSprCtrl, x1, y1, hBmp, gSprCtrl.GD_ColorARGB(255, 0),
ID, GS_VISIBLE);
gSprCtrl.GD_SetObjectLinked(ID, (ID_BVOLUME + Index));
gSprCtrl.GD_SetObjectLocked(ID, true);
// LCD vertikaler Slider Value
x := x1 + 30;
y := y1 + 74;
if not Assigned(TTFLcd) then
GDIP_LoadPrivateFontCollection(UseFont, TTFLcd, LcdFontName);
ID := ID_SLIDER_LED + Index;
gSprCtrl.GD_DrawTextToCtrlEx(HSprCtrl, UseText, x, y + 1, w, h, Color, PWideChar(LcdFontName)
, TTFLcd, FontSize, ID, GS_VISIBLE, 0, Ord(StringAlignmentFar));
gSprCtrl.GD_SetObjectLinked(ID, (ID_BVOLUME + Index));
gSprCtrl.GD_SetObjectLocked(ID, true);
GDIP_GetTextBound(MainClass.DeviceName, FontName, 13, bw, bh, nil, GD_TextHorzUp);
// DeviceName
x := x1 + ((ParentWidth - bw) div 2);
y := 208;
// Keinen privaten Font verwenden weil text sich zur Laufzeit ändern kann.
ID := ID_DEVICENAME + Index;
gSprCtrl.GD_DrawTextToCtrl(HSprCtrl, PWideChar(MainClass.DeviceName), x, y, gSprCtrl.GD_ARGB
(255, 255, 255, 255), PWideChar(FontName), nil, 13, ID, GS_VISIBLE, 1, Ord
(StringAlignmentNear));
gSprCtrl.GD_SetObjectLinked(ID, (ID_BVOLUME + Index));
gSprCtrl.GD_SetObjectLocked(ID, true);
// vertikaler slider
nX := x1 + 36;
nY := y1 + 112;
hBmp := gSprCtrl.GI_CreateBitmapFromFile(PWideChar(SpriteResPath + 'slideV.png'), bmW, bmH);
if (hBmp <> 0) then
begin
hThumb := gSprCtrl.GI_CreateBitmapFromFile
(PWideChar(SpriteResPath + 'thumbV.png'), bmW, bmH);
if (hThumb <> 0) then
begin
gSprCtrl.GI_GetBitmapSize(hBmp, IbmW, IbmH);
x := nX;
y := nY;
ID := ID_SLIDER_VERT + Index;
gSprCtrl.GD_DrawBitmapToCtrl(HSprCtrl, x, y, hBmp, OPAQUEIMAGE, ID, GS_VISIBLE);
gSprCtrl.GD_SetObjectLinked(ID, (ID_BVOLUME + Index));
gSprCtrl.GD_SetObjectLocked(ID, true);
y := nY + (IbmH div 2);
gSprCtrl.GI_GetBitmapSize(hThumb, IbmW, IbmH);
x := nX;
y := y - (IbmH div 2 - 1);
ID := ID_THUMB_VERT + Index;
gSprCtrl.GD_DrawBitmapToCtrl(HSprCtrl, x, y, hThumb, OPAQUEIMAGE, ID, GS_VISIBLE);
gSprCtrl.GD_SetObjectLinked(ID, (ID_BVOLUME + Index));
gSprCtrl.GD_SetObjectLocked(ID, true);
// Mute
hBmp := gSprCtrl.GI_CreateBitmapFromFile(PWideChar(SpriteResPath + 'vSwitch.png'), bmW,
bmH);
x := x1 + (ParentWidth - Integer(bmW) div 2) - 23;
y := y1 + ParentHeight - Integer(bmH);
ID := ID_SWITCH + Index;
gSprCtrl.GI_GetBitmapSize(hBmp, IbmW, IbmH);
gSprCtrl.GD_DrawBitmapToCtrl(HSprCtrl, x, y, hBmp, $FFFFFFFF, ID, GS_VISIBLE);
gSprCtrl.GD_SetObjectLinked(ID, (ID_BVOLUME + Index));
gSprCtrl.GD_SetObjectFrameCount(ID, 2);
gSprCtrl.GD_SetObjectFrameToUse(ID, 1);
gSprCtrl.GD_SetObjectLocked(ID, true);
// Anchor
gSprCtrl.GD_SetObjectAnchorMode((ID_SLIDER_LED + Index), ANCHOR_CENTER);
gSprCtrl.GD_SetObjectAnchorMode((ID_SLIDER_VERT + Index), ANCHOR_CENTER);
gSprCtrl.GD_SetObjectAnchorMode((ID_THUMB_VERT + Index), ANCHOR_CENTER);
gSprCtrl.GD_SetObjectAnchorMode((ID_SWITCH + Index), ANCHOR_CENTER);
gSprCtrl.GD_SetObjectAnchorMode((ID_DEVICENAME + Index), ANCHOR_CENTER);
end;
end;
end;
end;
end;