Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable menu items with ShowMenu and with dialog menu bar
#1
Question 1
When I try to trigger a MessageBox on de-activation of the dialog-window, I get an '(RT)' error.
(see code below)
The error is almost the same as described here:
Dialog Box
I implemented the solution from that topic and it works, but when I try to do it on the de-activation of an dialogbox I get an RT error.


Question 2
Is there a way to gray-out and disable an menu item? (ghost an item)
Example of grayed out menu item.

I want to disable the left edit-field (see code below) called 'checked' when the checkbox is unchecked.
With 'disable' I mean, the object is grayed out (ghosted) but still visible and can't be activated when clicked on.

I found something here but I couldn't get the syntax right.
http://msdn.microsoft.com/en-us/library/aa931329.aspx
Disable File Menu Item

Question 3
Is it possible to catch/get the interface-object that loses it's focus.
For example, If I go from the left editfield to the right editfield I a want to get ID and contents of the object (left editfield) that loses it's focus.

I tried to implement the 'SETFOCUS' / 'KILLFOCUS' from MSDN, but I couldn't get the syntax right.
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

The code:

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


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000000 0x0 92 10 48 12 "Unchecked"
;4 Static 0x54000000 0x0 6 10 48 12 "Checked"
;5 Edit 0x54030080 0x200 6 30 46 14 "checked"
;6 Edit 0x54030080 0x200 92 30 48 14 "unchecked"
;7 Button 0x54012003 0x0 70 62 48 12 "Check"
;END DIALOG
;DIALOG EDITOR: "" 0x2030307 "" "" ""

ret

;messages
sel message
,case WM_INITDIALOG act id(6 hDlg)    
,case WM_DESTROY    
,case WM_ACTIVATE  goto messages2
,case WM_COMMAND goto messages2
,

ret
;messages2
sel wParam    
,case WA_INACTIVE
,,mes("Disabled!")
,case 7
,,int checked=but(7 hDlg)
,,,if(checked=1)act id(5 hDlg)
,,,if(checked=0)act id(6 hDlg)        
,case IDOK
,case IDCANCEL
ret 1



Macro tst_dlg
Code:
Copy      Help
str controls = "5 6 7"
str e5che e6unc c7Che
if(!ShowDialog("test_dlg" &test_dlg &controls)) ret
#2
WM_ACTIVATE/WA_INACTIVE is not a good place to show message box. Also goto messages2 can be used only with WM_COMMAND.
Code:
Copy      Help
,case WM_ACTIVATE
,sel wParam
,,case WA_INACTIVE
,,,;mes("Disabled!")
,,,if(!MessageBox(0 "Disabled!" "QM" MB_TOPMOST)) end ERR_FAILED ;;returns 0, then mes throws error

To disable popup menu items, use class MenuPopup instead of function ShowMenu:
Code:
Copy      Help
MenuPopup m.AddItems("1 Enabled[]2 Disabled[]3 Disabled[]4 Enabled[]5 Disabled")
m.DisableItems("2-3 5")
out m.Show
To disable items when using menu bar:
Function Dialog126
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

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

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Button 0x54032000 0x0 6 8 48 14 "Button"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030507 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,int hm=GetMenu(hDlg)
,EnableMenuItem hm 103 MF_ENABLED
,EnableMenuItem hm 104 MF_ENABLED
,EnableMenuItem hm 105 MF_GRAYED
,case IDOK
,case IDCANCEL
ret 1

;BEGIN MENU
;>&Edit
,;&Cut : 103 0 3
,;&Copy : 104 0 3
,;&Paste : 105
,;<
;END MENU

3. In dialog editor select an Edit control, click Events, EN_KILLFOCUS.
#3
Ok, thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)