AGB  ·  Datenschutz  ·  Impressum  







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

OwnerDrwaMenu und Tastaturshortcuts

Ein Thema von Luckie · begonnen am 8. Aug 2005 · letzter Beitrag vom 8. Aug 2005
 
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#1

OwnerDrwaMenu und Tastaturshortcuts

  Alt 8. Aug 2005, 01:31
Ich zeichne meine Menüs selber, weil ich Bitmaps davor angezeigt haben will.
Delphi-Quellcode:
WM_MEASUREITEM:
      begin
        mi := PMEASUREITEMSTRUCT(lParam);
        case mi.CtlType of
          ODT_MENU:
            begin
              mi.itemWidth := 150;
              mi.itemHeight := 18;
            end
        end;
      end;
    WM_DRAWITEM:
      begin
        di := PDRAWITEMSTRUCT(lParam);
        case di.CtlType of
          ODT_MENU:
            begin
              SetBkMode(di.hDC, TRANSPARENT);
              if (di.itemState and ODS_SELECTED = ODS_SELECTED) then
              begin
                di.rcItem.Left := di.rcItem.left + 20;
                FillRect(di.hDC, di.rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
                SetTextColor(di.hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
                DrawText(di.hDC, PChar(di.itemData), lstrlen(PChar(di.itemData)), di.rcItem, DT_SINGLELINE or DT_LEFT or
                  DT_VCENTER);
              end
              else
              begin
                di.rcItem.Left := di.rcItem.left + 20;
                FillRect(di.hDC, di.rcItem, GetSysColorBrush(COLOR_MENU));
                SetTextColor(di.hDC, GetSysColor(COLOR_MENUTEXT));
                DrawText(di.hDC, PChar(di.itemData), lstrlen(PChar(di.itemData)), di.rcItem, DT_SINGLELINE or DT_LEFT or
                  DT_VCENTER);
              end;
              if (di.itemState and ODS_GRAYED = ODS_GRAYED) then
              begin
                FillRect(di.hDC, di.rcItem, GetSysColorBrush(COLOR_BTNFACE));
                SetTextColor(di.hDC, GetSysColor(COLOR_GRAYTEXT));
                DrawText(di.hDC, PChar(di.itemData), lstrlen(PChar(di.itemData)), di.rcItem, DT_SINGLELINE or DT_LEFT or
                  DT_VCENTER);
              end;
              di.rcItem.Left := di.rcItem.left - 20;
              MenuBmp(hDlg, di.rcItem, di.itemID, di.hDC);
            end;
        end;
      end;
Jetzt steht dazu im PSDK:
Zitat:
To get keyboard accelerators to work with bitmap or owner-drawn menu items, the owner of the menu must process the WM_MENUCHAR message. For more information, see Owner-Drawn Menus and the WM_MENUCHAR Message.
Sprich, ich muss die Nachricht WM_MENUCHAR selber behandeln. Im PSDK steht dazu:
Zitat:
An application that processes this message should return one of the following values in the high-order word of the return value.

MNC_IGNORE Informs the system that it should discard the character the user pressed and create a short beep on the system speaker.
MNC_CLOSE Informs the system that it should close the active menu.
MNC_EXECUTE Informs the system that it should choose the item specified in the low-order word of the return value. The owner window receives a WM_COMMAND message.
MNC_SELECT Informs the system that it should select the item specified in the low-order word of the return value.
Näheres im MSDN: http://msdn.microsoft.com/library/de...m_menuchar.asp

Da es sich bei mir um einen Dialog handelt, dachte ich, müsste es so aussehen:
Delphi-Quellcode:
    WM_MENUCHAR:
      begin
        SetWindowLong(hDlg, DWL_MSGRESULT, MakeLong(loword(wParam), MNC_SELECT));
      end;
Nur leider tut sich da nichts. Zur Erklärung was passieren sollte: Öffnet man ein Menü mit der Alt-Taste und dem unterstrichenen Buchstaben, kann man in dem dort aufklappenden Menü einen Item auswählen, in dem man den entsprechend unterstrichenen Buchstaben des Menüitems wählt. Zum Beispiel: Alt+D öffnet das Dateimenü und ein weiter Druck auf den Buchstaben 'S' wählt den Menüpunkt 'Speichern' aus.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
 


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 03:43 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz