Thema: Delphi Automatisierung

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#1

Automatisierung

  Alt 4. Sep 2017, 18:07
Ich habe doch noch leichte Probleme mit dem Grund Menu.
Benötige da noch ein paar Ideen oder Hilfestellungen.

Es geht mir vor allem um die Automatisierung das Fenster dynamisch zu zerstören wenn es nicht mehr gebraucht wird.
Im Moment muss ich an vielen Positionen PopUpMenu.DestroyWindow aufrufen um das Fenster zu schließen.

Hat jemand eine Idee wie man das machen könnte das es dynamisch\Automatisiert abläuft oder es an nur einer stelle geschieht?
Wie macht das denn ein normales Menu denn da muss man nicht jedes Mal eine Funktion aufrufen welche das Fenster zerstört.

Alleine das erstellen ist schon aufwendig.
Hier mal der Code! (Nicht kopiert selbst erstellt) LOL!

Delphi-Quellcode:
procedure CreateMyPopUpMenu(WinHandle: HWND);
var
  PrivateFont: PWideChar;
begin
  PopUpMenu := CTRL_PopUpMenuCreate;
  PopUpMenu.Width := 215;
  PopUpMenu.Height := 366;
  PopUpMenu.SkinConfigFile := PWideChar(DefSkin);
  PopUpMenu.UseVistaCrystal := CheckCrystal.GetCheckButtonStatus(CheckCrystal.Handle);
  PopUpMenu.UseVistaBlur := CheckAeroBlur.GetCheckButtonStatus(CheckAeroBlur.Handle);
  PopUpMenu.SideBarCaption := 'KVideo Player';
  PopUpMenu.SideBarCaptionLeft := 5;
  PopUpMenu.SideBarCaptionTop := 245;

  gPMenu.hPopUpHandle := PopUpMenu.CreatePopUpMenu(MainHandle);
  if gPMenu.hPopUpHandle <> 0 then
  begin
    AddPopUpControls(gPMenu.hPopUpHandle);

    PrivateFont := PWideChar(SKAERO_FOLDER + 'Menu\SideBar.ttf');
    PopUpMenu.FontName := 'Nasalization Free';
    PopUpMenu.FontSize := 14;
    PopUpMenu.CreatePrivateFont(PrivateFont);

    gPMenu.PopUpMenu := gPMenu.hPopUpHandle;
    gPMenu.bPopupMenu := True;
  end;
end;
Delphi-Quellcode:
procedure AddPopUpControls(WinHandle: HWND);
var
  ImagePathSid: WideString;
  ImagePathSel: WideString;
  ImagePathSep: WideString;
  IconPath: WideString;
  IconArrowPath: WideString;
  Enabled: BOOL;
  Color: COLORREF;
begin
  // Icon Pfade
  ImagePathSel := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Select.png';
  ImagePathSep := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Seperator.png';
  ImagePathSid := SKAERO_CONFIG_GetSkinFolder + 'Menu\SideBar.png';
  IconArrowPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\Arrow.ico';

  // Aktiven Status prüfen und Farbe zuweisen
  Enabled := (KVideo_GetPlayerState <> psNotReady);
  if Enabled then
     Color := SKAERO_POPMENUHILITE
  else
  Color := $FF737373;

  // SeitenBar
  PopUpMenu.AddSideBar(WinHandle, IDM_SIDEBARFRAME, ImagePathSid,
    2, 2, 21, 362, 0, false, true);

  // About
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_About.ico';
  PopUpMenu.AddButton(WinHandle, IDM_ABOUT, ImagePathSel, IconPath, 'About',
    24, 2, 189, 20, SKAERO_POPMENUHILITE, 1, 0, Left, 20,
    'Oops...' + CHR(13) + 'Are they in the wrong place?');

  // Seperator
  PopUpMenu.AddButton(WinHandle, IDM_SEPERATOR, ImagePathSep, '', '-Appearance-',
    24, 22, 189, 20, SKAERO_ACTIVECAPTION, 1, 0, Center, 20, '',false);

  // Skins
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_SkinFolder.ico';
  PopUpMenu.AddButton(WinHandle, IDM_SKIN, ImagePathSel, IconPath, 'Skins',
    24, 42, 189, 20, SKAERO_POPMENUHILITE, 1, 0, Left, 20, '', true, IconArrowPath);

  // Seperator
  PopUpMenu.AddButton(WinHandle, IDM_SEPERATOR1, ImagePathSep, '', '-VideoFilter-',
    24, 62, 189, 20, SKAERO_ACTIVECAPTION, 1, 0, Center, 20, '', false);

  // Filter
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Filter.ico';
  PopUpMenu.AddButton(WinHandle, IDM_FILTER, ImagePathSel, IconPath, 'Filter',
    24, 82, 189, 20, SKAERO_POPMENUHILITE, 1, 0, Left, 20, '', true, IconArrowPath);

  // LAV Filter Configuration
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Filter.ico';
  PopUpMenu.AddButton(WinHandle, IDM_LAVFILTERCONFIG, ImagePathSel, IconPath,
    'LAV Filter Configuration', 24, 102, 189, 20, Color, 1, 0, Left, 20, '', Enabled,
    IconArrowPath);

  // Seperator
  PopUpMenu.AddButton(WinHandle, IDM_SEPERATOR2, ImagePathSep, '', '-File Dependencies-',
    24, 122, 189, 20, SKAERO_ACTIVECAPTION, 1, 0, Center, 20, '', false);

  // Add File
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_File.ico';
  PopUpMenu.AddButton(WinHandle, IDM_ADDFILE, ImagePathSel, IconPath, 'Add File',
    24, 142, 189, 20, SKAERO_POPMENUHILITE, 1, 0, Left, 20, '');

  // Seperator
  PopUpMenu.AddButton(WinHandle, IDM_SEPERATOR3, ImagePathSep, '', '-Options-',
    24, 162, 189, 20, SKAERO_ACTIVECAPTION, 1, 0, Center, 20, '', false);

  // Settings
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Option.ico';
  PopUpMenu.AddButton(WinHandle, IDM_OPTION, ImagePathSel, IconPath, 'Settings',
    24, 182, 189, 20, SKAERO_POPMENUHILITE, 1, 0, Left, 20, '', true, IconArrowPath);

  // SubTitle Config
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_SubTitlecfg.ico';
  PopUpMenu.AddButton(WinHandle, IDM_SUBTITLECONFIG, ImagePathSel, IconPath, 'SubTitle Config',
    24, 202, 189, 20, Color, 1, 0, Left, 20, '', Enabled);

  // Show MediaFile Property
  if (KVideo_MediaInfoServiceReady) then
  begin
    Enabled := True;
    Color := SKAERO_POPMENUHILITE;
  end else
  if not(KVideo_GetMediaProperty(aMediaProperty)) then
  begin
    Enabled := false;
    Color := $FF737373;
  end;
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Info.ico';
  PopUpMenu.AddButton(WinHandle, IDM_MEDIAFILEPROPERTYS, ImagePathSel, IconPath,
    'Show MediaFile Property', 24, 222, 189, 20, Color, 1, 0, Left, 20, '', Enabled);

  // Select Video Track
  if (aMediaProperty.NumVideoStream = 0) then
  begin
    Enabled := false;
    Color := $FF737373;
  end else
  begin
    Enabled := True;
    Color := SKAERO_POPMENUHILITE;
  end;
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Video.ico';
  PopUpMenu.AddButton(WinHandle, IDM_VIDEOSTREAM, ImagePathSel, IconPath, 'Select Video Track',
    24, 242, 189, 20, Color, 1, 0, Left, 20, '', Enabled, IconArrowPath);

  // Select Audio Track
  if (aMediaProperty.NumAudioStream = 0) then
  begin
    Enabled := false;
    Color := $FF737373;
  end else
  begin
    Enabled := True;
    Color := SKAERO_POPMENUHILITE;
  end;
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Audio.ico';
  PopUpMenu.AddButton(WinHandle, IDM_AUDIOSTREAM, ImagePathSel, IconPath, 'Select Audio Track',
    24, 262, 189, 20, Color, 1, 0, Left, 20, '', Enabled, IconArrowPath);

  // Select SubTitle Track
  if (aMediaProperty.NumSubTitleStream = 0) then
  begin
    Enabled := false;
    Color := $FF737373;
  end else
  begin
    Enabled := True;
    Color := SKAERO_POPMENUHILITE;
  end;
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_SubTitle.ico';
  PopUpMenu.AddButton(WinHandle, IDM_SUBTITLETRACK, ImagePathSel, IconPath,
    'Select SubTitle Track', 24, 282, 189, 20, Color, 1, 0, Left, 20, '', Enabled, IconArrowPath);

  // Chapter
  if (aMediaProperty.NumChapter = 0) then
  begin
    Enabled := false;
    Color := $FF737373;
  end else
  begin
    Enabled := True;
    Color := SKAERO_POPMENUHILITE;
  end;
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Chapter.ico';
  PopUpMenu.AddButton(WinHandle, IDM_CHAPTER, ImagePathSel, IconPath, 'Chapter',
    24, 302, 189, 20, Color, 1, 0, Left, 20, '', Enabled, IconArrowPath);

  // Seperator
  PopUpMenu.AddButton(WinHandle, IDM_SEPERATOR4, ImagePathSep, '', '-Application-',
    24, 322, 189, 20, SKAERO_ACTIVECAPTION, 1, 0, Center, 20, '', false);

  // Close
  IconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Close.ico';
  PopUpMenu.AddButton(WinHandle, IDM_CLOSE, ImagePathSel, IconPath, 'Close',
    24, 342, 189, 20, SKAERO_POPMENUHILITE, 1, 0, Left, 20, 'Bye, Bye');

end;
gruss