AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Automatisierung

Ein Thema von EWeiss · begonnen am 4. Sep 2017 · letzter Beitrag vom 6. Sep 2017
Thema geschlossen
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.074 Beiträge
 
Delphi 10.4 Sydney
 
#1

AW: Automatisierung

  Alt 5. Sep 2017, 08:48
Zeig doch mal die Stelle, wo du CreateMyPopupMenu aufrufst. (Ist es eigentlich gewollt, dass zwar WinHandle übergeben, aber auf das globale MainHandle zugegriffen wird?)
Ich nehme an, dass geschieht in der Botschaftsbehandlung für WM_RBUTTONDOWN bzw -UP?

Geändert von TiGü ( 5. Sep 2017 um 08:50 Uhr)
 
EWeiss
(Gast)

n/a Beiträge
 
#2

AW: Automatisierung

  Alt 5. Sep 2017, 09:04
Zeig doch mal die Stelle, wo du CreateMyPopupMenu aufrufst.
Ich nehme an, dass geschieht in der Botschaftsbehandlung für WM_RBUTTONDOWN bzw -UP?
Nicht ganz.

Main WinProc.
Delphi-Quellcode:
    WM_NCRBUTTONDOWN:
      begin
          if gPMenu.bPopupMenu then
          begin
            gPMenu.bPopupMenu := false;
            PopUpMenu.DestroyWindow;
          end;

          CreatePopupMenu(Prop.MainHandle);

          GetCursorPos(P);
          GetWindowRect(gPMenu.PopUpMenu, rc);
          ClientToScreen(gPMenu.PopUpMenu, P);

          PopUpMenu.MoveWindow(gPMenu.PopUpMenu, P.X, (P.Y - rc.Bottom), rc.Right,
            rc.Bottom);

          PopupMenu.Show;

          while GetMessage(_Msg, 0, 0, 0) do
          begin
            TranslateMessage(_Msg);
            DispatchMessage(_Msg);
          end;

          if OnExit then
            PostMessage(WinHandle, WM_DESTROY, 0, 0);
      end;
Delphi-Quellcode:
    WM_NCLBUTTONDOWN:
      begin
        IsMoving := true;
        if gPMenu.bPopupMenu then
        begin
          PopUpMenu.DestroyWindow;
          gPMenu.bPopupMenu := false;
        end;
      end;
MovieProc
Delphi-Quellcode:
    WM_RBUTTONDOWN:
      SendMessageW(Prop.MainHandle, WM_NCRBUTTONDOWN, wP, LP);

    WM_LBUTTONDOWN:
      SendMessageW(Prop.MainHandle, WM_NCLBUTTONDOWN, wP, LP);
Zitat:
(Ist es eigentlich gewollt, dass zwar WinHandle übergeben, aber auf das globale MainHandle zugegriffen wird?)
Wo siehst du das?


gruss
 
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: Automatisierung

  Alt 5. Sep 2017, 09:09
Zitat:
(Ist es eigentlich gewollt, dass zwar WinHandle übergeben, aber auf das globale MainHandle zugegriffen wird?)
Wo siehst du das?
Delphi-Quellcode:
procedure CreateMyPopUpMenu(WinHandle: HWND);
begin
  // ...
  gPMenu.hPopUpHandle := PopUpMenu.CreatePopUpMenu(MainHandle);
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
 
EWeiss
(Gast)

n/a Beiträge
 
#4

AW: Automatisierung

  Alt 5. Sep 2017, 09:18
Zitat:
(Ist es eigentlich gewollt, dass zwar WinHandle übergeben, aber auf das globale MainHandle zugegriffen wird?)
Wo siehst du das?
Delphi-Quellcode:
procedure CreateMyPopUpMenu(WinHandle: HWND);
begin
  // ...
  gPMenu.hPopUpHandle := PopUpMenu.CreatePopUpMenu(MainHandle);
Ahh danke
Nein das soll nicht so sein habe es behoben. Danke
Auch in WM_NCRBUTTONDOWN:

gruss

Geändert von EWeiss ( 5. Sep 2017 um 09:22 Uhr)
 
Benutzerbild von Sherlock
Sherlock
Online

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.811 Beiträge
 
Delphi 12 Athens
 
#5

AW: Automatisierung

  Alt 5. Sep 2017, 13:34
Leicht OT: Codereviews sind schon geil! Wäre es nicht schön/sinnvoll ein entsprechendes Unterforum zu haben? ICh würde da auch ein bis zwei Dinge reinstellen können .

Sherlock
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
 
EWeiss
(Gast)

n/a Beiträge
 
#6

AW: Automatisierung

  Alt 5. Sep 2017, 14:10
Habe es jetzt erst mal noch etwas angepasst damit es sich mehr an das normale Menu orientiert.

Delphi-Quellcode:
procedure AppendMenu(WinHandle: HWND);
var
  Enabled: BOOL;
  Color: COLORREF;
begin

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

   if gPMenu.hPopUpHandle <> 0 then
  begin
    // About
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_About.ico';
    PopUpMenu.ItemToolTip := 'Oops...' + CHR(13) + 'Are they in the wrong place?';
    PopUpMenu.ItemHiliteColor := SKAERO_POPMENUHILITE;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 2;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW, IDM_About, 'About');

    // Seperator
    PopUpMenu.ItemHiliteColor := SKAERO_ACTIVECAPTION;
    PopUpMenu.ItemTextAlligment := Center;
    PopUpMenu.ItemEnabled := False;
    PopUpMenu.ItemTop := 22;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_SEPARATOR, IDM_SEPERATOR, '-Appearance-');

    // Skins
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_SkinFolder.ico';
    PopUpMenu.ItemHiliteColor := SKAERO_POPMENUHILITE;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 42;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_SKIN, 'Skins');

    // Seperator
    PopUpMenu.ItemHiliteColor := SKAERO_ACTIVECAPTION;
    PopUpMenu.ItemTextAlligment := Center;
    PopUpMenu.ItemEnabled := False;
    PopUpMenu.ItemTop := 62;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_SEPARATOR, IDM_SEPERATOR1, '-VideoFilter-');

    // Filter
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Filter.ico';
    PopUpMenu.ItemHiliteColor := SKAERO_POPMENUHILITE;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 82;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_FILTER, 'Filter');

    // LAV Filter Configuration
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Filter.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 102;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_LAVFILTERCONFIG, 'LAV Filter Configuration');

    // Seperator
    PopUpMenu.ItemHiliteColor := SKAERO_ACTIVECAPTION;
    PopUpMenu.ItemTextAlligment := Center;
    PopUpMenu.ItemEnabled := False;
    PopUpMenu.ItemTop := 122;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_SEPARATOR, IDM_SEPERATOR2, '-File Dependencies-');

    // Add File
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_File.ico';
    PopUpMenu.ItemHiliteColor := SKAERO_POPMENUHILITE;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 142;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW, IDM_ADDFILE, 'Add File');

    // Seperator
    PopUpMenu.ItemHiliteColor := SKAERO_ACTIVECAPTION;
    PopUpMenu.ItemTextAlligment := Center;
    PopUpMenu.ItemEnabled := False;
    PopUpMenu.ItemTop := 162;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_SEPARATOR, IDM_SEPERATOR3, '-Options-');

    // Settings
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Option.ico';
    PopUpMenu.ItemHiliteColor := SKAERO_POPMENUHILITE;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 182;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_OPTION, 'Settings');

    // SubTitle Config
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_SubTitlecfg.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.ItemTop := 202;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW, IDM_SUBTITLECONFIG, 'SubTitle Config');

    // Show MediaFile Property
    if (KVideo_MediaInfoServiceReady) then
    begin
      if not(KVideo_GetMediaProperty(aMediaProperty)) then
      begin
        Enabled := false;
        Color := $FF737373;
      end else
      begin
        Enabled := True;
        Color := SKAERO_POPMENUHILITE;
      end;
    end else
    begin
      Enabled := false;
      Color := $FF737373;
    end;
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Info.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.ItemTop := 222;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW, IDM_MEDIAFILEPROPERTYS, 'Show MediaFile Property');

    // Select Video Track
    if (aMediaProperty.NumVideoStream = 0) then
    begin
      Enabled := false;
      Color := $FF737373;
    end else
    begin
      Enabled := True;
      Color := SKAERO_POPMENUHILITE;
    end;
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Video.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.ItemTop := 242;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_VIDEOSTREAM, 'Select Video Track');

    // Select Audio Track
    if (aMediaProperty.NumAudioStream = 0) then
    begin
      Enabled := false;
      Color := $FF737373;
    end else
    begin
      Enabled := True;
      Color := SKAERO_POPMENUHILITE;
    end;
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Audio.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.ItemTop := 262;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_AUDIOSTREAM, 'Select Audio Track');

    // Select SubTitle Track
    if (aMediaProperty.NumSubTitleStream = 0) then
    begin
      Enabled := false;
      Color := $FF737373;
    end else
    begin
      Enabled := True;
      Color := SKAERO_POPMENUHILITE;
    end;
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_SubTitle.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.ItemTop := 282;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_SUBTITLETRACK, 'Select SubTitle Track');

    // Chapter
    if (aMediaProperty.NumChapter = 0) then
    begin
      Enabled := false;
      Color := $FF737373;
    end else
    begin
      Enabled := True;
      Color := SKAERO_POPMENUHILITE;
    end;
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Chapter.ico';
    PopUpMenu.ItemHiliteColor := Color;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemEnabled := Enabled;
    PopUpMenu.ItemTop := 302;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_CHAPTER, 'Chapter');

    // Seperator
    PopUpMenu.ItemHiliteColor := SKAERO_ACTIVECAPTION;
    PopUpMenu.ItemTextAlligment := Center;
    PopUpMenu.ItemEnabled := False;
    PopUpMenu.ItemTop := 322;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_SEPARATOR, IDM_SEPERATOR4, '-Application-');

    // Close
    PopUpMenu.ItemIconPath := SKAERO_CONFIG_GetSkinFolder + 'Menu\MEN_Close.ico';
    PopUpMenu.ItemToolTip := 'Bye, Bye';
    PopUpMenu.ItemHiliteColor := SKAERO_POPMENUHILITE;
    PopUpMenu.ItemTextAlligment := Left;
    PopUpMenu.ItemTop := 342;
    PopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW, IDM_CLOSE, 'Close');
  end;

end;
gruss
 
bra

Registriert seit: 20. Jan 2015
711 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#7

AW: Automatisierung

  Alt 5. Sep 2017, 14:36
Wenn du die einzelnen Aufrufe in einer Funktion verpackst, schrumpft der Code um ein Vielfaches:

Code ist unvollständig und die Parameter müssen ggf. noch ergänzt werden.

Delphi-Quellcode:
procedure AppendEntry(APopUpMenu, AIconPath, AHiliteColor, ATextAlignment, AEnabled, ATop, ACaption);
begin
    APopUpMenu.ItemIconPath := AIconPath;
    APopUpMenu.ItemHiliteColor := AHiliteColor;
    APopUpMenu.ItemTextAlligment := ATextAlignment;
    APopUpMenu.ItemEnabled := AEnabled;
    APopUpMenu.ItemTop := ATop;
    APopUpMenu.AppendMenu(PopUpMenu.Handle, MF_OWNERDRAW or MF_POPUP, IDM_CHAPTER, ACaption);
end;
 
Thema geschlossen


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:40 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz