Announcement

Collapse
No announcement yet.

Menu problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Menu problem

    Good morning,
    I have a problem with the command accelerator of menu. In the little example below, the Alt-T hot-key don't works and I'm not able to understand were I'm wrong.

    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "win32api.inc"
    
    %ID_ITEM1 = 401
    %ID_ITEM2 = 402
    
    CALLBACK FUNCTION DlgProc () AS LONG
    
      SELECT CASE CBMSG
      CASE %WM_COMMAND
        SELECT CASE CBCTL
        CASE %IDCANCEL
          IF CBCTLMSG = %BN_CLICKED THEN
            DIALOG END CBHNDL
          END IF
        CASE %ID_ITEM1
          MSGBOX "Menu item 1"
        CASE %ID_ITEM2
          MSGBOX "Menu item 2"
        END SELECT
      END SELECT
    
    END FUNCTION
    
    
    
    FUNCTION PBMAIN () AS LONG
    
        LOCAL hDlg    AS DWORD
        LOCAL Result  AS LONG
        LOCAL hMenu   AS DWORD
        LOCAL hPopup AS DWORD
        LOCAL dlgStyle AS LONG
    
        dlgStyle = %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU
        DIALOG NEW 0, "Menu test", , , 400, 300, dlgStyle, 0 TO hDlg
    
        MENU NEW BAR TO hMenu
        MENU NEW POPUP TO hPopup
        MENU ADD POPUP, hMenu, "&Title", hPopup, %MF_ENABLED
        MENU ADD STRING, hPopup, "&Item1", %ID_ITEM1, %MF_ENABLED
        MENU ADD STRING, hPopup, "I&tem2", %ID_ITEM2, %MF_ENABLED
        MENU ATTACH hMenu, hDlg
    
        DIALOG SHOW MODAL hDlg, CALL DlgProc TO Result
    
    END FUNCTION
    Any suggestions?
    Thanks

    Sergio

  • #2
    You need real accelerators

    Search for accel in the helpfile.
    Btw your alt- keycode is not useful with those, Use Ctrl+.. instead.
    See notepad for suggestions.
    hellobasic

    Comment


    • #3
      See this post http://www.powerbasic.com/support/fo...ML/012769.html

      Seems that you need at least one control on your dialog ..
      Rgds, Dave

      Comment


      • #4
        Sergio, Try adding a control to the dialog.

        Even if it's a label with nothing in it. that should enable the alt+T.

        CONTROL ADD LABEL,hDLG,101,"Hello",10,10,50,12
        Last edited by Fred Buffington; 21 Nov 2007, 01:27 PM.
        Client Writeup for the CPA

        buffs.proboards2.com

        Links Page

        Comment


        • #5
          Many thanks to all for the replies.
          The empty label trick works fine.

          Thanks!

          Sergio

          Comment

          Working...
          X