============================================================================= MsgInitMenu() - Handles WM_INITMENU
| 1591 | // |
| 1592 | // |
| 1593 | void MsgInitMenu ( HWND hwnd, WPARAM wParam, LPARAM lParam ) |
| 1594 | { |
| 1595 | int i, i2 , i3; |
| 1596 | HMENU hmenu = ( HMENU ) wParam; |
| 1597 | i = lstrlen ( szCurFile ); |
| 1598 | EnableCmd ( hmenu, IDM_FILE_REVERT, i ); |
| 1599 | EnableCmd ( hmenu, IDM_FILE_LAUNCH, i ); |
| 1600 | EnableCmd ( hmenu, IDM_FILE_PROPERTIES, i ); |
| 1601 | EnableCmd ( hmenu, IDM_FILE_CREATELINK, i ); |
| 1602 | EnableCmd ( hmenu, IDM_FILE_ADDTOFAV, i ); |
| 1603 | EnableCmd ( hmenu, IDM_FILE_READONLY, i ); |
| 1604 | CheckCmd ( hmenu, IDM_FILE_READONLY, bReadOnly ); |
| 1605 | //EnableCmd(hmenu,IDM_ENCODING_UNICODEREV,!bReadOnly); |
| 1606 | //EnableCmd(hmenu,IDM_ENCODING_UNICODE,!bReadOnly); |
| 1607 | //EnableCmd(hmenu,IDM_ENCODING_UTF8SIGN,!bReadOnly); |
| 1608 | //EnableCmd(hmenu,IDM_ENCODING_UTF8,!bReadOnly); |
| 1609 | //EnableCmd(hmenu,IDM_ENCODING_ANSI,!bReadOnly); |
| 1610 | //EnableCmd(hmenu,IDM_LINEENDINGS_CRLF,!bReadOnly); |
| 1611 | //EnableCmd(hmenu,IDM_LINEENDINGS_LF,!bReadOnly); |
| 1612 | //EnableCmd(hmenu,IDM_LINEENDINGS_CR,!bReadOnly); |
| 1613 | EnableCmd ( hmenu, IDM_ENCODING_RECODE, i ); |
| 1614 | if ( mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE ) { |
| 1615 | i = IDM_ENCODING_UNICODEREV; |
| 1616 | } else if ( mEncoding[iEncoding].uFlags & NCP_UNICODE ) { |
| 1617 | i = IDM_ENCODING_UNICODE; |
| 1618 | } else if ( mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN ) { |
| 1619 | i = IDM_ENCODING_UTF8SIGN; |
| 1620 | } else if ( mEncoding[iEncoding].uFlags & NCP_UTF8 ) { |
| 1621 | i = IDM_ENCODING_UTF8; |
| 1622 | } else if ( mEncoding[iEncoding].uFlags & NCP_DEFAULT ) { |
| 1623 | i = IDM_ENCODING_ANSI; |
| 1624 | } else { |
| 1625 | i = -1; |
| 1626 | } |
| 1627 | CheckMenuRadioItem ( hmenu, IDM_ENCODING_ANSI, IDM_ENCODING_UTF8SIGN, i, MF_BYCOMMAND ); |
| 1628 | if ( iEOLMode == SC_EOL_CRLF ) { |
| 1629 | i = IDM_LINEENDINGS_CRLF; |
| 1630 | } else if ( iEOLMode == SC_EOL_LF ) { |
| 1631 | i = IDM_LINEENDINGS_LF; |
| 1632 | } else { |
| 1633 | i = IDM_LINEENDINGS_CR; |
| 1634 | } |
| 1635 | CheckMenuRadioItem ( hmenu, IDM_LINEENDINGS_CRLF, IDM_LINEENDINGS_CR, i, MF_BYCOMMAND ); |
| 1636 | EnableCmd ( hmenu, IDM_FILE_RECENT, ( MRU_Enum ( pFileMRU, 0, NULL, 0 ) > 0 ) ); |
| 1637 | EnableCmd ( hmenu, IDM_EDIT_UNDO, SendMessage ( hwndEdit, SCI_CANUNDO, 0, 0 ) /*&& !bReadOnly*/ ); |
| 1638 | EnableCmd ( hmenu, IDM_EDIT_REDO, SendMessage ( hwndEdit, SCI_CANREDO, 0, 0 ) /*&& !bReadOnly*/ ); |
| 1639 | i = ( int ) SendMessage ( hwndEdit, SCI_GETSELECTIONEND, 0, 0 ) - ( int ) SendMessage ( hwndEdit, SCI_GETSELECTIONSTART, 0, 0 ); |
| 1640 | i2 = ( int ) SendMessage ( hwndEdit, SCI_CANPASTE, 0, 0 ); |
| 1641 | i3 = (int)SendMessage(hwndEdit, SCI_GETLENGTH, 0, 0); |
| 1642 | EnableCmd ( hmenu, IDM_EDIT_CUT, i /*&& !bReadOnly*/ ); |
| 1643 | EnableCmd ( hmenu, IDM_EDIT_COPY, i /*&& !bReadOnly*/ ); |
| 1644 | EnableCmd ( hmenu, IDM_EDIT_COPYALL, i3 /*&& !bReadOnly*/ ); |
| 1645 | EnableCmd ( hmenu, IDM_EDIT_COPYADD, i3 /*i*/ /*&& !bReadOnly*/ ); |
| 1646 | EnableCmd ( hmenu, IDM_EDIT_PASTE, i2 /*&& !bReadOnly*/ ); |
| 1647 | EnableCmd ( hmenu, IDM_EDIT_SWAP, i || i2 /*&& !bReadOnly*/ ); |
| 1648 | EnableCmd ( hmenu, IDM_EDIT_CLEAR, i /*&& !bReadOnly*/ ); |
| 1649 | OpenClipboard ( hwnd ); |
| 1650 | EnableCmd ( hmenu, IDM_EDIT_CLEARCLIPBOARD, CountClipboardFormats() ); |
no test coverage detected