Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi nonVCL - PopUp Menue erstellen (https://www.delphipraxis.net/53807-nonvcl-popup-menue-erstellen.html)

turboPASCAL 22. Sep 2005 19:40


nonVCL - PopUp Menue erstellen
 
Hi,

ich habe ein kleines Problem beim mit einem PopUp-Menue was nicht angezeigt wird.

Delphi-Quellcode:
function DlgFunc(hw: hWnd; uMsg: DWORD; wParam: wParam; lParam: lParam): bool; stdcall;
var
  hMenue: HMENU;
  p: TPoint;
begin
  Result := True;
  case uMsg of
    WM_INITDIALOG:
      begin
        hMenue := CreatePopUpMenu;
 
        // Menüs mit Einträgen füllen
        AppendMenu(hMenue, MF_STRING, IDM_ITEM1, '1');
        AppendMenu(hMenue, MF_STRING, IDM_ITEM2, '2');

        // SetMenu(hW, hMenue);
      end;

    WM_CONTEXTMENU:
    begin
        GetCursorPos(p);
        TrackPopupMenu(hMenue, TPM_RIGHTALIGN or TPM_RIGHTBUTTON, p.x, p.y, 0, hW, nil);

        {$IFDEF DEBUG} showmessage(format('%d, %d ', [p.x,p.y])); {$ENDIF}
    end;

    //...

    WM_DESTROY:
      begin
        DestroyMenu(hMenue);
        PostQuitMessage(0);
      end;
  else
    result := false;
  end;
end;

BEGIN
  InitCommonControls;
  hdlg := DialogBoxParam(HInstance, MAKEINTRESOURCE(100), 0, @DlgFunc, 0);
END.
Was ist daran falsch ?

turboPASCAL 22. Sep 2005 19:57

Re: nonVCL - PopUp Menue erstellen
 
Delphi-Quellcode:
var
  hMenue: HMENU; // <---<<

function DlgFunc(hw: hWnd; uMsg: DWORD; wParam: wParam; lParam: lParam): bool; stdcall;
  p: TPoint;
begin
  //...
Ok. Sollte man doch als globale Variable setzen. :wall:

Olli 23. Sep 2005 12:58

Re: nonVCL - PopUp Menue erstellen
 
Zitat:

Zitat von turboPASCAL
Ok. Sollte man doch als globale Variable setzen. :wall:

Oder als Property: MSDN-Library durchsuchenSetProp und MSDN-Library durchsuchenGetProp


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:58 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