对话方块(六十)

2010-12-30 21:13:56 · 作者: · 浏览: 41381
;

case WM_INITMENUPOPUP:
switch (lParam)
{
case 1: // Edit menu

// Enable Undo if edit control can do it

EnableMenuItem ((HMENU) wParam, IDM_EDIT_UNDO,
SendMessage (hwndEdit, EM_CANUNDO, 0, 0L)
MF_ENABLED : MF_GRAYED) ;

// Enable Paste if text is in the clipboard

EnableMenuItem ((HMENU) wParam, IDM_EDIT_PASTE,
IsClipboardFormatAvailable (CF_TEXT)
MF_ENABLED : MF_GRAYED) ;

// Enable Cut, Copy, and Del if text is selected

SendMessage (hwndEdit, EM_GETSEL, (WPARAM) &iSelBeg,
(LPARAM) &iSelEnd) ;

iEnable = iSelBeg != iSelEnd MF_ENABLED : MF_GRAYED ;

EnableMenuItem ((HMENU) wParam, IDM_EDIT_CUT, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_COPY, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_CLEAR, iEnable) ;
break ;

case 2: // Search menu

// Enable Find, Next, and Replace if modeless
// dialogs are not already active

iEnable = hDlgModeless == NULL
MF_ENABLED : MF_GRAYED ;
EnableMenuItem ((HMENU) wParam, IDM_SEARCH_FIND, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_SEARCH_NEXT, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_S