亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pianokeyboard.pas

?? Delphi鋼琴源碼
?? PAS
?? 第 1 頁 / 共 3 頁
字號:
    Parent := Self;
    Left := KeyBoardLeft + 5;
    Top := FKeyBoardTop;
    Width := 129;
    Height := 17;
    //Font := Self.Font;
    //Font.Color := clWhite;
    Visible := FShowGroup;
  end;
  GrpsList.AddObject('0', FGroupBox);
end;

procedure TPianoKeyboard.BuildPianokeyBoard;
var
  i, j, k: Integer;
  iGroupWidth: Integer;
  btnTemp: TPianoButton;
  grpTemp: TGroupBox;
begin
  Visible := False;

  iGroupWidth := 7 * (FPianoButton[2].Left - FPianoButton[0].Left);
  Width := FPianoButton[0].Left + FPianoGroup * iGroupWidth + FPianoButton[0].Left;
  SetAutoWidth(FAutoWidth); // Auto Size Form
  // Rebuild it.
  for j := 12 to BtnsList.Count - 1 do
  begin
    BtnsList.Objects[j].Free;
  end;
  BtnsList.Clear;

  for j := 0 to 11 do
  begin
    BtnsList.AddObject(IntToStr(j), FPianoButton[j]);
  end;

  // Build more keys
  for i := 1 to FPianoGroup - 1 do
  begin
    for j := 0 to 11 do
    begin
      k := 12 * i + j;
      btnTemp := TPianoButton.Create(Self);
      with btnTemp do
      begin
        Parent := Self;
        Name := 'FPianoButton' + IntToStr(k);
        Tag := k;
        // Looks
        BevelWidth := TPianoButton(BtnsList.Objects[j]).BevelWidth;
        // Position
        Top := TPianoButton(BtnsList.Objects[j]).Top;
        Left := TPianoButton(BtnsList.Objects[j]).Left + i * iGroupWidth;
      end;
      // Add to Object list
      BtnsList.AddObject(IntToStr(k), btnTemp);
    end;
  end;

  // Set button events
  for i := 0 to BtnsList.Count - 1 do
  begin
    btnTemp := TPianoButton(BtnsList.Objects[i]);
    with btnTemp do
    begin
      OnMouseDown := PianoMouseDown;
      OnMouseMove := PianoMouseMove;
      OnMouseUp := PianoMouseUp;
    end;
  end;
  SetButtonsColor(True, FPianoColor); // Set Buttons Bitmap

  // Rebuild it.
  for i := 1 to GrpsList.Count - 1 do
  begin
    GrpsList.Objects[i].Free;
  end;
  GrpsList.Clear;

  GrpsList.AddObject('0', FGroupBox);
  // Build more groups
  for i := 1 to FPianoGroup - 1 do
  begin
    grpTemp := TGroupBox.Create(Self);
    with grpTemp do
    begin
      Parent := Self;
      Name := 'FGroupBox' + IntToStr(i);
      Top := FGroupBox.Top;
      Left := FGroupBox.Left + i * iGroupWidth;
      Height := FGroupBox.Height;
      Width := FGroupBox.Width;
      Visible := FShowGroup;
    end;
    // Add to object list
    GrpsList.AddObject(IntToStr(i), grpTemp);
  end;
  SetGroupFontColor(FGroupFontColor);
  SetPianoGroupsMap; // Set Groups Caption and visible

  Visible := True;

  // Build Keys Map
  for i := 0 to CMaxKey do
  begin
    NotesList.Add(#0);
  end;
  for i := 0 to CLastKey - 1 do
  begin
    NotesList.Strings[Notes[i].iChar] := IntToStr(Notes[i].iNote);
  end;
end;

procedure TPianoKeyboard.SetButtonColor(bFirst: Boolean; pcColor: TPianoColor; pbButton: TPianoButton);
var
  ind: integer;
begin
  ind := Integer(pcColor) + 1;
  case pbButton.Tag mod 12 of
    0, 5:
      begin
        if bFirst then
          pbButton.Bitmap.LoadFromResourceName(HInstance, 'W0');
        FPianoWhiteImgList.GetBitmap(5 * ind + 0, pbButton.BitmapDown);
      end;
    2:
      begin
        if bFirst then
          pbButton.Bitmap.LoadFromResourceName(HInstance, 'W1');
        FPianoWhiteImgList.GetBitmap(5 * ind + 1, pbButton.BitmapDown);
      end;
    4, 11:
      begin
        if bFirst then
          pbButton.Bitmap.LoadFromResourceName(HInstance, 'W2');
        FPianoWhiteImgList.GetBitmap(5 * ind + 2, pbButton.BitmapDown);
      end;
    7:
      begin
        if bFirst then
          pbButton.Bitmap.LoadFromResourceName(HInstance, 'W3');
        FPianoWhiteImgList.GetBitmap(5 * ind + 3, pbButton.BitmapDown);
      end;
    9:
      begin
        if bFirst then
          pbButton.Bitmap.LoadFromResourceName(HInstance, 'W4');
        FPianoWhiteImgList.GetBitmap(5 * ind + 4, pbButton.BitmapDown);
      end;
    1, 3, 6, 8, 10:
      begin
        if bFirst then
          pbButton.Bitmap.LoadFromResourceName(HInstance, 'B0');
        FPianoBlackImgList.GetBitmap(ind + 0, pbButton.BitmapDown);
      end;
  end;
end;

procedure TPianoKeyboard.SetButtonsColor(bFirst: Boolean; pcColor: TPianoColor);
var
  i: integer;
begin
  for i := 0 to BtnsList.Count - 1 do
  begin
    SetButtonColor(bFirst, pcColor, TPianoButton(BtnsList.Objects[i]));
  end;
end;

procedure TPianoKeyboard.SetGroupFontColor(const Value: TColor);
var
  i: Integer;
begin
  FGroupFontColor := Value;
  for i := 0 to GrpsList.Count - 1 do
  begin
    TGroupBox(GrpsList.Objects[i]).Font.Color := FGroupFontColor;
  end;
end;

procedure TPianoKeyboard.SetPianoGroupsMap;
var
  i: Integer;
begin
  // Build Groups Map
  for i := 0 to GrpsList.Count - 1 do
  begin
    if (i + FPianoOctave) < CLastGroup then
    begin
      TGroupBox(GrpsList.Objects[i]).Visible := FShowGroup;
      TGroupBox(GrpsList.Objects[i]).Caption := Groups[i + FPianoOctave];
    end else
    begin
      TGroupBox(GrpsList.Objects[i]).Visible := False;
    end;
  end;
end;

constructor TPianoKeyboard.Create(AOwner: TComponent);
begin
  inherited;
  Height := 145;
  Width := 174;
  Color := CColor;
  FGroupFontColor := CFontColor;
  FKeyBoardTop := CKeyBoardTop;
  FKeyBoardLeft := CKeyBoardLeft;
  FPianoGroup := CPianoGroup;
  FPianoOctave := CPianoOctave;
  FPianoColor := pcGreen;
  FAutoWidth := CAutoWidth;
  FShowGroup := CShowGroup;

  FOwner := (AOwner as TWinControl);

  FPianoBlackImgList := TImageList.CreateSize(13, 73);
  FPianoWhiteImgList := TImageList.CreateSize(20, 104);
  GrpsList := TStringList.Create; // Hold Groups description
  BtnsList := TStringList.Create; // Hold Buttons for Piano
  NotesList := TStringList.Create; // Hold Keys Map of note

  InitPianoKeyboard;
  BuildPianokeyBoard;
end;

destructor TPianoKeyboard.Destroy;
begin
  FPianoBlackImgList := nil;
  FPianoWhiteImgList := nil;
  FreeAndNil(GrpsList);
  FreeAndNil(BtnsList);
  FreeAndNil(NotesList);
  inherited;
end;

procedure TPianoKeyboard.SetPianoGroup(const Value: Integer);
begin
  FPianoGroup := Value;
  BuildPianokeyBoard;
end;

procedure TPianoKeyboard.SetPianoColor(const Value: TPianoColor);
begin
  FPianoColor := Value;
  ResetPianoButtons;
  SetButtonsColor(False, FPianoColor);
end;

procedure TPianoKeyboard.SetPianoOctave(const Value: Byte);
begin
  FPianoOctave := Value;
  ResetPianoButtons;
  SetPianoGroupsMap;
end;

procedure TPianoKeyboard.SetKeyBoardLeft(const Value: Integer);
begin
  FKeyBoardLeft := Value;
  SetKeyBoardPos;
end;

procedure TPianoKeyboard.SetKeyBoardTop(const Value: Integer);
begin
  FKeyBoardTop := Value;
  SetKeyBoardPos;
end;

procedure TPianoKeyboard.SetKeyBoardPos;
var
  i: Integer;
  iLeft, iTop: Integer;
begin
  iLeft := FKeyBoardLeft - (FGroupBox.Left - 5);
  iTop := FKeyBoardTop - FGroupBox.Top;
  for i := 0 to BtnsList.Count - 1 do
  begin
    TPianoButton(BtnsList.Objects[i]).Left := TPianoButton(BtnsList.Objects[i]).Left + iLeft;
    TPianoButton(BtnsList.Objects[i]).Top := TPianoButton(BtnsList.Objects[i]).Top + iTop;
  end;
  for i := 0 to GrpsList.Count - 1 do
  begin
    TGroupBox(GrpsList.Objects[i]).Left := TGroupBox(GrpsList.Objects[i]).Left + iLeft;
    TGroupBox(GrpsList.Objects[i]).Top := TGroupBox(GrpsList.Objects[i]).Top + iTop;
  end;
end;

procedure TPianoKeyboard.SetAutoWidth(const Value: Boolean);
begin
  FAutoWidth := Value;
  if FAutoWidth then
    FOwner.Width := Width + 2 * Left;
end;

procedure TPianoKeyboard.SetShowGroup(const Value: Boolean);
begin
  FShowGroup := Value;
  SetPianoGroupsMap;
end;

procedure TPianoKeyboard.ResetPianoButtons;
var
  i: integer;
begin
  for i := 0 to BtnsList.Count - 1 do
  begin
    //SetButtonColor(False, FPianoColor, TPianoButton(BtnsList.Objects[i]));
    if TPianoButton(BtnsList.Objects[i]).State <> bsUP then
    begin
      TPianoButton(BtnsList.Objects[i]).State := bsUp;
    end;
  end;
end;

procedure TPianoKeyboard.DoMidiEvent(Event, data1, data2: Byte; pcColor: TPianoColor);
var
  iButton: Integer;
begin
  iButton := data1 - FPianoOctave * 12;
  case (event and $F0) of
    $90: // Note On
      begin
        if (iButton < BtnsList.Count) and (iButton >= 0) then
        begin
          if data2 <> 0 then
          begin
            if Integer(pcColor) <> -1 then
              DoPianoColor(iButton, pcColor);
            TPianoButton(BtnsList.Objects[iButton]).State := bsDown
          end else
          begin
            TPianoButton(BtnsList.Objects[iButton]).State := bsUp;
          end;
        end;
      end;
    $80: // Note Off
      begin
        if (iButton < BtnsList.Count) and (iButton >= 0) then
        begin
          TPianoButton(BtnsList.Objects[iButton]).State := bsUp;
        end;
      end;
    $B0: // Control change
      begin
        if data1 = $7E then
        begin
          ResetPianoButtons;
        end;
      end;
    $7B: // All notes off
      begin
        ResetPianoButtons;
      end;
  end;
end;

procedure SetMouseOctave(var iOctave: Integer; Shift: TShiftState);
begin
  if ssShift in Shift then Inc(iOctave);
  if ssCtrl in Shift then Dec(iOctave);
end;

procedure TPianoKeyboard.PianoMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  iOctave, iNote, iSpeed: Integer;
  ABtn: TPianoButton;
begin
//  if Assigned(FOnPianoMouseDown) then
//    FOnPianoMouseDown(Sender, Button, Shift, X, Y);

  if not (Sender is TPianoButton) then Exit;
  ABtn := Sender as TPianoButton;

  iOctave := FPianoOctave + ABtn.Tag div 12;
  SetMouseOctave(iOctave, Shift);
  iNote := ABtn.Tag mod 12;
  iSpeed := 64;
  ABtn.State := bsDown;

  if Assigned(FOnKeyboard) then
    FOnKeyboard($90, iOctave * 12 + iNote, iSpeed);
end;

procedure TPianoKeyboard.PianoMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
//  if Assigned(FOnPianoMouseMove) then
//    FOnPianoMouseMove(Sender, Shift, X, Y);
end;

procedure TPianoKeyboard.PianoMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  iOctave, iNote, iSpeed: Integer;
  ABtn: TPianoButton;
begin
//  if Assigned(FOnPianoMouseUp) then
//    FOnPianoMouseUp(Sender, Button, Shift, X, Y);

  if not (Sender is TPianoButton) then Exit;
  ABtn := Sender as TPianoButton;

  iOctave := FPianoOctave + ABtn.Tag div 12;
  SetMouseOctave(iOctave, Shift);
  iNote := ABtn.Tag mod 12;
  iSpeed := 64;
  ABtn.State := bsUp;

  if Assigned(FOnKeyboard) then
    FOnKeyboard($80, iOctave * 12 + iNote, iSpeed);
end;

procedure TPianoKeyboard.DoPianoColor(iNote: Byte; pcColor: TPianoColor);
begin
  if iNote >= BtnsList.Count then Exit;
  SetButtonColor(False, pcColor, TPianoButton(BtnsList.Objects[iNote]));
end;

procedure TPianoKeyboard.DoPianoShortCut(var Msg: TWMKey;
  var Handled: Boolean);
const
  KD31 = $40000000;
begin
  case Msg.Msg of
    CN_KEYDOWN:
      begin
        // this code is very useful to hanlde the system keydelay and keyrepeat.
        if (Msg.KeyData and KD31) <> 0 then
          Handled := True;
      end;
  end;
end;

procedure TPianoKeyboard.DoPianoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if NotesList[Key] = #0 then Exit;
  PianoMouseDown(BtnsList.Objects[StrToInt(NotesList.Strings[Key])], mbLeft, Shift, -1, -1);
end;

procedure TPianoKeyboard.DoPianoKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if NotesList[Key] = #0 then Exit;
  PianoMouseUp(BtnsList.Objects[StrToInt(NotesList.Strings[Key])], mbLeft, Shift, -1, -1);
end;

procedure Register;
begin
  RegisterComponents('Piano Suite', [TPianoKeyboard]);
end;

end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品福利一区二区三区| 久久婷婷国产综合国色天香| 精品在线播放免费| 另类综合日韩欧美亚洲| 国产精品视频一二三| 欧美美女一区二区| 99久久国产免费看| 精品一区二区免费看| 一级做a爱片久久| 国产精品视频你懂的| 精品成人在线观看| 欧美日韩中文一区| 99久久精品免费观看| 国产精品综合一区二区三区| 热久久免费视频| 一区二区三区自拍| 国产精品成人一区二区三区夜夜夜| 日韩欧美一卡二卡| 88在线观看91蜜桃国自产| av一区二区三区| 国产成人免费视频网站 | www成人在线观看| 欧美日韩国产在线观看| 成人av免费网站| 国产成人av电影在线播放| 久久精品av麻豆的观看方式| 亚洲成人动漫在线免费观看| 亚洲夂夂婷婷色拍ww47| 一区二区在线观看免费| 中文字幕一区免费在线观看| 国产农村妇女精品| 亚洲国产成人在线| 久久精品男人天堂av| 久久精品欧美一区二区三区麻豆| 日韩久久久精品| www久久精品| 久久久天堂av| 国产精品拍天天在线| 中文字幕在线视频一区| 日韩一区欧美小说| 亚洲视频在线一区| 亚洲激情男女视频| 亚洲高清视频中文字幕| 午夜av区久久| 美脚の诱脚舐め脚责91| 久久精品国产在热久久| 精品一区二区三区av| 国产成人精品一区二区三区四区 | 亚洲综合小说图片| 亚洲一区二区三区免费视频| 亚洲成人自拍网| 青青草国产成人av片免费| 蜜桃久久av一区| 国产精品一二三四五| 国产91富婆露脸刺激对白 | 91精品国产91综合久久蜜臀| 日韩美女在线视频| 精品国产污污免费网站入口 | 亚洲欧美日韩国产另类专区| 亚洲精品免费在线| 日日夜夜一区二区| 国产自产v一区二区三区c| 国产麻豆91精品| 欧美日韩在线综合| 狠狠色丁香婷婷综合| 国产乱妇无码大片在线观看| 大尺度一区二区| 在线观看欧美黄色| 日韩免费在线观看| 国产精品白丝在线| 日韩高清不卡一区二区| 国产福利不卡视频| 欧美视频一区二区三区| 精品国产一区二区在线观看| 国产欧美一区二区精品忘忧草| 中文字幕亚洲区| 日韩一区欧美二区| 不卡一区二区三区四区| 欧美精品乱码久久久久久| 久久精品一级爱片| 午夜免费久久看| 丁香亚洲综合激情啪啪综合| 欧美丝袜自拍制服另类| 久久先锋影音av| 国产在线精品免费| 一本高清dvd不卡在线观看 | 色8久久精品久久久久久蜜| 欧美日韩dvd在线观看| 国产偷国产偷亚洲高清人白洁| 一区二区三区日韩| 国产一区二区网址| 欧美午夜寂寞影院| 国产欧美va欧美不卡在线| 亚洲成人av福利| 不卡的av中国片| 精品区一区二区| 一区av在线播放| www.亚洲人| 久久女同精品一区二区| 日韩经典一区二区| 色婷婷亚洲精品| 国产精品视频第一区| 裸体一区二区三区| 欧美色图片你懂的| 国产精品九色蝌蚪自拍| 麻豆精品新av中文字幕| 在线观看精品一区| 中文字幕制服丝袜一区二区三区| 久久国产福利国产秒拍| 欧美人与性动xxxx| 亚洲一区二区三区在线看| a美女胸又www黄视频久久| 久久久久综合网| 麻豆成人久久精品二区三区小说| 欧美熟乱第一页| 亚洲私人影院在线观看| 成人性生交大片| 久久久久高清精品| 国产麻豆视频一区二区| 精品三级在线观看| 久久 天天综合| 91精品国产91久久久久久最新毛片| 亚洲免费观看高清完整版在线| 成人午夜又粗又硬又大| 国产日韩精品一区| 国产69精品久久99不卡| 久久久亚洲高清| 国产成人亚洲综合a∨婷婷| 精品久久国产老人久久综合| 麻豆91在线播放| 精品日韩一区二区三区| 免费高清不卡av| 亚洲同性同志一二三专区| 国产99精品在线观看| 国产欧美日韩综合精品一区二区| 国产精品一区久久久久| 国产亚洲综合av| 成人av电影免费观看| 1区2区3区国产精品| 日本丶国产丶欧美色综合| 亚洲夂夂婷婷色拍ww47| 欧美群妇大交群的观看方式| 日本麻豆一区二区三区视频| 日韩三级精品电影久久久| 麻豆精品一区二区三区| 国产无遮挡一区二区三区毛片日本| 国产精选一区二区三区| 国产精品成人在线观看| 在线视频欧美精品| 天涯成人国产亚洲精品一区av| 欧美一区二区在线视频| 国产在线国偷精品产拍免费yy| 久久精品欧美一区二区三区麻豆| 国产91丝袜在线18| 亚洲色图清纯唯美| 欧美巨大另类极品videosbest| 免费在线欧美视频| 日本一二三不卡| 91免费小视频| 日日欢夜夜爽一区| 久久噜噜亚洲综合| 91麻豆免费看| 蜜臀久久久久久久| 久久精品综合网| 欧美系列日韩一区| 久久99久久99精品免视看婷婷| 日本一区二区三区久久久久久久久不 | 一区二区中文字幕在线| 在线观看日韩电影| 久久99蜜桃精品| 亚洲天堂久久久久久久| 欧美一区二区三区思思人| 国产精品羞羞答答xxdd| 亚洲精品老司机| 精品欧美一区二区久久| 91麻豆swag| 久久99精品久久久久久国产越南 | 3atv一区二区三区| 国产91精品精华液一区二区三区| 一区二区三区欧美| www激情久久| 欧美图片一区二区三区| 国产成人精品亚洲777人妖| 亚洲国产sm捆绑调教视频| 国产三级欧美三级日产三级99 | 午夜精品久久久久久久 | 日本欧美加勒比视频| 国产精品日产欧美久久久久| 91精品国产欧美一区二区18| 99这里只有精品| 激情小说欧美图片| 亚洲一二三四久久| 中国色在线观看另类| 日韩精品中文字幕在线一区| 91网上在线视频| 国产米奇在线777精品观看| 日韩国产欧美一区二区三区| 亚洲精品国产一区二区三区四区在线 | 国产精品主播直播| 日韩成人一区二区|