Ejemplo n.º 1
0
BOOL CEditViewDlg::PreTranslateMessage(MSG* pMsg) {

	if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 's' || pMsg->wParam == 'S') && GetAsyncKeyState(VK_CONTROL) & 0x8000) {
		OnBnClickedButtonSave();
		return TRUE;
	}

	if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 'o' || pMsg->wParam == 'O') && GetAsyncKeyState(VK_CONTROL) & 0x8000) {
		OnBnClickedButtonOpen();
		return TRUE;
	}

	if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 'f' || pMsg->wParam == 'F') && GetAsyncKeyState(VK_CONTROL) & 0x8000) {
		ShowFindDlg();
		return TRUE;
	}

	if (pMsg->hwnd == editInfo.GetSafeHwnd() && (pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_TAB)) {
		// get the char index of the caret position
		int nPos = LOWORD(editInfo.CharFromPos(editInfo.GetCaretPos()));
		// select zero chars
		editInfo.SetSel(nPos, nPos);
		// then replace that selection with a TAB
		editInfo.ReplaceSel("\t", TRUE);
		return TRUE;
	} 

	return CDialog::PreTranslateMessage(pMsg);
}
Ejemplo n.º 2
0
//
//	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;
	}
}