Subroutine MenuCorrect allows to right justify a part of menu in DDT + to make bold font.
Thanks to MSDN http://support.microsoft.com/support.../Q216/1/89.ASP
and Eric Pearson, who found this nice sample.
[This message has been edited by Semen Matusovski (edited March 07, 2000).]
Thanks to MSDN http://support.microsoft.com/support.../Q216/1/89.ASP
and Eric Pearson, who found this nice sample.
Code:
#Compile Exe #Register None #Dim All #Include "WIN32API.INC" '**************************************************************** ' NumRs - order no. (positive - Right-justify; negative - Bold) Sub MenuCorrect (hMenu As Long, NumRs As Long) %MAXLENGTHOFMENUTEXT = 40 Dim mnuItemInfo As MENUITEMINFO Dim BuffStr As Asciiz * (%MAXLENGTHOFMENUTEXT * 2 + 1) mnuItemInfo.cbSize = Len(mnuItemInfo) mnuItemInfo.dwTypeData = VarPtr(BuffStr) mnuItemInfo.cch = %MAXLENGTHOFMENUTEXT * 2 mnuItemInfo.fMask = %MIIM_ID Or %MIIM_DATA Or %MIIM_TYPE Or %MIIM_SUBMENU Or %MIIM_STATE GetMenuItemInfo hMenu, Abs(NumRs) - 1, %True, mnuItemInfo If NumRs < 0 Then mnuItemInfo.fState = mnuItemInfo.fState Or &H1000 Else _ mnuItemInfo.fType = mnuItemInfo.fType Or %MF_HELP SetMenuItemInfo hMenu, Abs(NumRs) - 1, %True, mnuItemInfo End Sub '**************************************************************** CallBack Function DlgProc() If CbMsg = %WM_COMMAND Then If CbCtl => 1001 And CbCtl <= 1100 Then MsgBox "WM_COMMAND received from a menu item!" End If End If End Function Function PbMain () As Long Local hDlg As Long Local result As Long Local hMenu As Long Local hPopup As Long Menu New Bar To hMenu Menu New Popup To hPopup Menu Add String, hPopup, "&Open", 1001, %MF_ENABLED Menu Add String, hPopup, "&Exit", 1002, %MF_ENABLED Menu Add Popup, hMenu, "&File", hPopup, %MF_ENABLED Menu New Popup To hPopup Menu Add String, hPopup, "C&ut", 1003, %MF_ENABLED Menu Add String, hPopup, "&Copy", 1004, %MF_ENABLED '*********************************** MenuCorrect hPopup, -1 '*********************************** Menu Add Popup, hMenu, "&Edit", hPopup, %MF_ENABLED '*********************************** MenuCorrect hMenu, -2 '*********************************** Menu New Popup To hPopup Menu Add String, hPopup, "&Horizontal", 1005, %MF_ENABLED Menu Add String, hPopup, "&Vertical", 1006, %MF_ENABLED '*********************************** MenuCorrect hPopup, -2 '*********************************** Menu Add Popup, hMenu, "&Window", hPopup, &H0 Menu New Popup To hPopup Menu Add String, hPopup, "&Help", 1005, %MF_ENABLED Menu Add String, hPopup, "&About", 1006, %MF_ENABLED Menu Add Popup, hMenu, "&Help", hPopup, %MF_ENABLED ' ** Create a new dialog template Dialog New 0, " What is your name?", ,, 160, 80, %WS_SYSMENU To hDlg ' ** Add controls to it Control Add TextBox, hDlg, 101, "", 14, 12, 134, 12, 0 Control Add Button, hDlg, %IDOK, "OK", 34, 32, 40, 14, %BS_DEFAULT Control Add Button, hDlg, %IDCANCEL, "Cancel", 84, 32, 40, 14, 0 '*********************************** MenuCorrect hMenu, 3 '*********************************** Menu Attach hMenu, hDlg ' ** Display the dialog Dialog Show Modal hDlg, Call DlgProc To result End Function