void ApplyRegSettings() { int i; if(g_hFont) DeleteObject(g_hFont); g_hFont = EasyCreateFont(g_nFontSize, g_fFontBold, g_nFontSmoothing, g_szFontName); TextView_SetLineSpacing(g_hwndTextView, g_nPaddingAbove, g_nPaddingBelow); TextView_SetStyleBool(g_hwndTextView, TXS_SELMARGIN, g_fSelMargin); TextView_SetStyleBool(g_hwndTextView, TXS_LINENUMBERS, g_fLineNumbers); TextView_SetStyleBool(g_hwndTextView, TXS_LONGLINES, g_fLongLines); TextView_SetStyleBool(g_hwndTextView, TXS_HIGHLIGHTCURLINE, g_nHLCurLine); TextView_SetCaretWidth(g_hwndTextView, 2); TextView_SetLongLine(g_hwndTextView, g_nLongLineLimit); SendMessage(g_hwndTextView, WM_SETFONT, (WPARAM)g_hFont, 0); for(i = 0; i < TXC_MAX_COLOURS; i++) { TextView_SetColor(g_hwndTextView, i, g_rgbColourList[i]); } // // System-wide options require Administrator access. On Vista we // need to elevate using the UAC prompt. Only do this if the settings have actually // changed // //SetExplorerContextMenu(g_fAddToExplorerContextMenu); //SetImageFileExecutionOptions(g_fReplaceNotepad); }
// // WM_COMMAND message handler for main window // UINT CommandHandler(HWND hwnd, UINT nCtrlId, UINT nCtrlCode, HWND hwndFrom) { RECT rect; switch(nCtrlId) { case IDM_FILE_NEW: // reset to an empty file SetWindowFileName(hwnd, _T("Untitled"), FALSE); TextView_Clear(g_hwndTextView); g_szFileTitle[0] = '\0'; g_fFileChanged = FALSE; return 0; case IDM_FILE_OPEN: // get a filename to open if(ShowOpenFileDlg(hwnd, g_szFileName, g_szFileTitle)) { DoOpenFile(hwnd, g_szFileName, g_szFileTitle); } return 0; case IDM_FILE_SAVE: MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION); return 0; case IDM_FILE_SAVEAS: // does nothing yet if(ShowSaveFileDlg(hwnd, g_szFileName, g_szFileTitle)) { MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION); } return 0; case IDM_FILE_PRINT: DeleteDC( ShowPrintDlg(hwnd) ); return 0; case IDM_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; case IDM_EDIT_UNDO: case WM_UNDO: SendMessage(g_hwndTextView, WM_UNDO, 0, 0); return 0; case IDM_EDIT_REDO: SendMessage(g_hwndTextView, TXM_REDO, 0, 0); return 0; case IDM_EDIT_COPY: case WM_COPY: SendMessage(g_hwndTextView, WM_COPY, 0, 0); return 0; case IDM_EDIT_CUT: case WM_CUT: SendMessage(g_hwndTextView, WM_CUT, 0, 0); return 0; case IDM_EDIT_PASTE: case WM_PASTE: SendMessage(g_hwndTextView, WM_PASTE, 0, 0); return 0; case IDM_EDIT_DELETE: case WM_CLEAR: SendMessage(g_hwndTextView, WM_CLEAR, 0, 0); return 0; case IDM_EDIT_FIND: ShowFindDlg(hwnd, FIND_PAGE); return 0; case IDM_EDIT_REPLACE: ShowFindDlg(hwnd, REPLACE_PAGE); return 0; case IDM_EDIT_GOTO: ShowFindDlg(hwnd, GOTO_PAGE); return 0; case IDM_EDIT_SELECTALL: TextView_SelectAll(g_hwndTextView); return 0; case IDM_VIEW_OPTIONS: ShowOptions(hwnd); return 0; case IDM_VIEW_LINENUMBERS: g_fLineNumbers = !g_fLineNumbers; TextView_SetStyleBool(g_hwndTextView, TXS_LINENUMBERS, g_fLineNumbers); return 0; case IDM_VIEW_LONGLINES: g_fLongLines = !g_fLongLines; TextView_SetStyleBool(g_hwndTextView, TXS_LONGLINES, g_fLongLines); return 0; case IDM_VIEW_STATUSBAR: g_fShowStatusbar = !g_fShowStatusbar; ShowWindow(g_hwndStatusbar, SW_HIDE); GetClientRect(hwnd, &rect); PostMessage(hwnd, WM_SIZE, 0, MAKEWPARAM(rect.right, rect.bottom)); return 0; case IDM_VIEW_SAVEEXIT: g_fSaveOnExit = !g_fSaveOnExit; return 0; case IDM_VIEW_SAVENOW: SaveRegSettings(); return 0; case IDM_HELP_ABOUT: ShowAboutDlg(hwnd); return 0; default: return 0; } }