Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enable/Disable/Rename
#1
I hate to ask but I have read and looked for a way to make this work.
When there is nothing to undo in an application the menu item edit undo is disabled and may say something like “nothing to undo” or you might have a redo menu item that will be enabled and have the undo disabled. How are both of these done?



Function DialogWithMenu
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str rea3
if(!ShowDialog("DialogWithMenu" &DialogWithMenu &controls 0 0 0 0 0 0 0 "dialog.ico" "DialogWithMenu")) ret

;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 294 190 "Dialog"
;3 RichEdit20A 0x54233044 0x101 0 0 294 190 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020009 "*" ""

ret
;messages
sel message
,case WM_INITDIALOG
,
,case WM_SIZE
,RECT r; GetClientRect(hDlg &r)
,siz r.right r.bottom id(3 hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,;menu items:
,case 101    ;; Menu File>>Open
,,str s fileTxt
,,if OpenSaveDialog(0 s "Text files[]*.txt[]Image files[]*.bmp;*.gif[]All Files[]*.*[]")
,,,fileTxt.getfile(s)
,,,fileTxt.setwintext(id(3 hDlg))
,case 103 out "Cut"
,case 104 out "Select All"
,case 105 out "Help"
,case 106 SendMessage(id(3 hDlg) WM_UNDO 0 0)

,case IDOK
,case IDCANCEL
ret 1

;BEGIN MENU
;>&File
,;&Open : 101 0 0 Co
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit
,;&Undo : 106 0 0 Cz
,;Cu&t : 103 0 0 Cx
,;-
,;Select &All : 104 0 0 Ca
,;<
;&Help : 105 0
;END MENU
#2
Function DialogWithMenu
Code:
Copy      Help
,;...
,case 110 ;;Enable Undo
,int hm=GetMenu(hDlg) ;;menu bar
,EnableMenuItem hm 106 0
,case 111 ;;Disable Undo
,hm=GetMenu(hDlg) ;;menu bar
,EnableMenuItem hm 106 MF_GRAYED
ret 1

;BEGIN MENU
;>&File
,;&Open : 101 0 0 Co
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit
,;&Undo : 106 0 1 Cz
,;Enable Undo : 110
,;Disable Undo : 111
,;Cu&t : 103 0 0 Cx
,;-
,;Select &All : 104 0 0 Ca
,;<
;&Help : 105 0
;END MENU

Menu functions are documented in MSDN library.
#3
So close but so far away. I forgot about GetMenu

Thank You
#4
I am trying to change the “Undo” to “Nothing to undo”. I believe that this has something to do with the MF_STRING however this part of the code will not accept strings. Am I missing something?

Function Function2
Code:
Copy      Help
;BEGIN MENU
;>&File
,;&Open : 101 0 0 Co
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit
,;&Undo : 106 0 1 Cz
,;Enable Undo : 110
,;Disable Undo : 111
,;Cu&t : 103 0 0 Cx
,;-
,;Select &All : 104 0 0 Ca
,;<
;&Help : 105 0
;END MENU
#5
QM 2.3.0 has functions MenuSetString and MenuGetString. Or use function ModifyMenu or SetMenuItemInfo.
#6
I have it working but I do not know if it is the correct way to do it.
I replaced

$s with “Nothing to Undo”

Is that Correct?
#7
Yes, $ is for lpstr.
#8
One last problem I noticed that no matter what I do the alignment of say “Ctrl+Z” is off.
   
How do I fix this?
#9
"can't undo[9]ctrl+t"
#10
Yet again perfect!
#11
Hi All,
Any suggestions on how to change the Font, size, color, background color of the menu items - top line and subitems?

Thanks!!,
Stuart
#12
Menu items must have MFT_OWNERDRAW type (0x100). The dialog must process WM_MEASUREITEM (calculate text width and height) and WM_DRAWITEM (completely draw the item - text, icon, state) messages. Read more in MSDN library.

code to start:
Function dlg_menu_draw
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_menu_draw" &dlg_menu_draw 0 0 0 0 0 0 0 0 0 "dlg_menu_draw")) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x203000C "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_MEASUREITEM
,MEASUREITEMSTRUCT& mi=+lParam
,out 1
,case WM_DRAWITEM
,DRAWITEMSTRUCT& di=+lParam
,out 2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

;BEGIN MENU
;>&File
,;&New : 100 0x100 0 Cn
,;&Open : 101 0x100 0 Co
,;&Save : 102 0x100 0 Cs
,;Save &As... : 103 0x100
,;-
,;>&Recent : 0 0x100
,,;not implemented : 190 0 1
,,;<
,;-
,;E&xit : 2 0x100 0 AF4
,;<
;&Help : 901 0
;END MENU


Forum Jump:


Users browsing this thread: 1 Guest(s)