Курсовая работа: Проект текстового редактора
void Zamenit::OnDestroy()//Он дестрой---------------------------------------
{
CDialog::OnDestroy();
// Уничтожаем объект
delete this;
//OnCancel();
// Сбрасываем указатель на дочернее окно в родительском окне
//((CMenuDlg *)m_pParent)->m_ppereutiDlg = NULL;
//((CMenuDlg *)AfxGetMainWnd())->m_ppereutiDlg = NULL;
//CEdit *pEdit = (CEdit *)(((CMenuDlg *)AfxGetMainWnd())->GetDlgItem(IDC_EDIT1));
// Уничтожаем дочернее окно
//DestroyWindow();
}
void Zamenit::OnBnClickedCancel()//Выход---------------------------------
{
OnCancel();
// Сбрасываем указатель на дочернее окно в родительском окне
((CMenuDlg *)m_pParentz)->m_zamenitDlg = NULL;
//((CMenuDlg *)AfxGetMainWnd())->m_ppereutiDlg = NULL;
// Уничтожаем дочернее окно
DestroyWindow();}
Код модуля pereuty.cpp
// pereuti.cpp : implementation file
//
#include "stdafx.h"
#include "Menu.h"
#include "pereuti.h"
// pereuti dialog
IMPLEMENT_DYNAMIC(pereuti, CDialog)
pereuti::pereuti(CWnd* pParent /*=NULL*/)
: CDialog(pereuti::IDD, pParent)
, m_position(0)
{
}
pereuti::~pereuti()
{
}
void pereuti::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_position);
DDX_Control(pDX, IDC_EDIT1, m_edit_pereuti);
}
BEGIN_MESSAGE_MAP(pereuti, CDialog)
END_MESSAGE_MAP()
// pereuti message handlers
Код модуля MenuDlg.cpp(Основной)
// MenuDlg.cpp : implementation file **********************************************************************************
// Kamenev Alexej 40 01 02
// 417318 / 10
// MIDO BNTU
// Created by Keylo99er
//
//*********************************************************************************************************************
#include "stdafx.h"
#include "Menu.h"
#include "MenuDlg.h"
#include ".\menudlg.h"
#include "mein.h"
#include "m_nauti.h"
#include "Zamenit.h"
#include "pereuti.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define WM_TRAYICON (WM_APP + 1)
// CMenuDlg dialog
CMenuDlg::CMenuDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMenuDlg::IDD, pParent)
, m_pAddDlg(NULL)
, m_zamenitDlg(NULL)
, m_nTimer(0)
, m_uTimer(0)
, m_bFlag(false)
, m_bFlMenu(false)
, m_strPath(_T("Безымянный"))
, m_strFileName(_T("*.txt"))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMenuDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, m_Edit1);
}
BEGIN_MESSAGE_MAP(CMenuDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_COMMAND(ID_Sozdat, OnSozdat)
ON_COMMAND(ID_Wixod, OnWixod)
ON_COMMAND(ID_Otkrit, OnOtkrit)
ON_COMMAND(ID_Soxranit, OnSoxranit)
ON_COMMAND(ID_Soxranit_kak, OnSoxranitkak)
ON_COMMAND(ID_Wremja, OnWremja)
ON_COMMAND(ID_Widelit_wse, OnWidelitwse)
ON_COMMAND(ID_Shrift, OnShrift)
ON_WM_SIZE()
ON_COMMAND(ID_blokn, Onblokn)
ON_COMMAND(ID_Udalit, OnUdalit)
ON_COMMAND(ID_Wirezat, OnWirezat)
ON_COMMAND(ID_Kopirowat, OnKopirowat)
ON_COMMAND(ID_Wstawit, OnWstawit)
ON_COMMAND(ID_Otmenit, OnOtmenit)
ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
ON_WM_INITMENU()
ON_WM_CLOSE()
ON_COMMAND(ID_Sprawka_2, OnSprawka2)
ON_COMMAND(ID_Nauti, OnNauti)
ON_COMMAND(ID_Nauti_dalee, OnNautidalee)
ON_COMMAND(ID_Zamenit, OnZamenit)
ON_COMMAND(ID_T_, OnT)
ON_WM_TIMER()
ON_COMMAND(ID_TRAY_OPEN, OnTrayOpen)
ON_COMMAND(ID_TRAY_EXIT, OnTrayExit)
ON_MESSAGE(WM_TRAYICON, OnTrayIcon)
ON_COMMAND(ID_Trei, OnTrei)
ON_COMMAND(ID_Pereuti, OnPereuti)
ON_WM_INITMENUPOPUP()
END_MESSAGE_MAP()
// CMenuDlg message handlers
BOOL CMenuDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);// Set big icon
SetIcon(m_hIcon, FALSE);// Set small icon
// TODO: Add extra initialization here
// SetTimer(1,500,0);
//--------------------------------------------------
CRect rcClient;
GetClientRect(rcClient);
rcClient.InflateRect(-2, -2, -2, -20);
GetDlgItem(IDC_EDIT1)->MoveWindow(rcClient);
//------------------------------------------------
//Акселератор
m_hAccel = ::LoadAccelerators(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_ACCELERATOR1));
//----------------------------------------------------
// Инициализируем шрифт текста
CFont *pFontText = m_Edit1.GetFont();
LOGFONT lfText;
pFontText->GetLogFont(&lfText);
m_fontText.CreateFontIndirect(&lfText);
//m_editMain.m_menuPopup.LoadMenu(IDR_MENU_POPUP);
//----------------------------------------------------
//StatusBar
m_wndStatusBar.Create(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP,
CRect(0, 0, 0, 0), this, IDC_STATUS_BAR);
CRect rect;
m_wndStatusBar.GetClientRect(&rect);
int nParts[] = {rect.right - 200, - 1};
CString strPartsStatusBar;
strPartsStatusBar.Format(_T("Стр %d, стлб %d"), m_nStrStatusBar = 1, m_nStolbetsStatusBar= 1);
m_wndStatusBar.SetParts(sizeof(nParts)/sizeof(nParts[0]), nParts);
m_wndStatusBar.SetText(strPartsStatusBar, 1, 0);
m_nTimer = SetTimer(1, 100, NULL);
m_wndStatusBar.ShowWindow(SW_SHOW);
//-------------------------------------------------------
//tray
m_menuTray.LoadMenu(IDR_MENU2);
m_nidTray.cbSize = sizeof(NOTIFYICONDATA);
m_nidTray.hWnd = m_hWnd;
m_nidTray.uID = ID_TRAYICON;
m_nidTray.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_nidTray.hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
m_nidTray.uCallbackMessage = WM_TRAYICON;
_tcscpy(m_nidTray.szTip, _T("Блокнот Лехи Каменева"));
//--------------------------------------------------------
CMenu* MENU = GetMenu();
CMenu* sibmenu = MENU->GetSubMenu(1);
sibmenu->EnableMenuItem(ID_Otmenit, MF_BYCOMMAND | MF_GRAYED);
CMenu* MENU1 = GetMenu();
CMenu* submenu = MENU1->GetSubMenu(1);
submenu->EnableMenuItem(ID_Wirezat, MF_BYCOMMAND | MF_GRAYED);
CMenu* MENU2 = GetMenu();
CMenu* sebmenu = MENU2->GetSubMenu(1);
sebmenu->EnableMenuItem(ID_Kopirowat, MF_BYCOMMAND | MF_GRAYED);
CMenu* MENU3 = GetMenu();
CMenu* sobmenu = MENU3->GetSubMenu(1);
sobmenu->EnableMenuItem(ID_Udalit, MF_BYCOMMAND | MF_GRAYED);
//----------------------------------------------------------------
m_pAddDlg = NULL;
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMenuDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMenuDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CMenuDlg::OnSozdat()//Создать ------------------------------
{
CString str_77 , strText;
CString str_r;
m_Edit1.GetWindowText(str_r);
if (str_r == _T(""))
{
//Beep(1000,100);
}
else if (str_r != _T(""))
{
UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"),
_T("Блокнот(Alexa)"), MB_YESNOCANCEL | MB_ICONWARNING);
if (uRes == IDYES)
{
CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL);
if(fileDlg.DoModal() == IDOK)
{
CStdioFile f;
if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite))
{
MessageBox("Не могу сохранить файл");
return;
}
/*while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}*/
CString str;
m_Edit1.GetWindowText(str);
f.Write(str, str.GetLength());
f.Close();
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот(Alexa)"));
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->SetSel(0,-1);
mEdit->Clear();
//m_strPath = _T("Безымянный");
SetWindowText(_T("Безымянный-Блокнот(Alexa)"));
}
}
if (uRes == IDNO)
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->SetSel(0,-1);
mEdit->Clear();
//m_strPath = _T("Безымянный");
SetWindowText(_T("Безымянный-Блокнот(Alexa)"));
}
}
}
BOOL CMenuDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
return ::TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
void CMenuDlg::OnWixod()//Выход--------------------------------------------
{CString str_77, strText;
CString str_r;
CStdioFile f;
m_Edit1.GetWindowText(str_r);
if (str_r == _T(""))
{
EndDialog(0);
return;
}
else if (str_r != _T(""))
{
UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"),
_T("Блокнот"), MB_YESNOCANCEL | MB_ICONWARNING);
if (uRes == IDYES)
{
//CString path;
CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL);
if(fileDlg.DoModal() == IDOK)
{
//path = fdlg.GetPathName();
//CFile f;
if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite))
{
MessageBox("Не могу сохранить файл");
return;
}
while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот"));
}
}
if (uRes == IDNO)
{
EndDialog(0);
//CDialog::OnClose();
}
if (uRes == IDCANCEL)
{
}
}
}
void CMenuDlg::OnOtkrit()//Открыть----------------------------------------
{
CString str_77 , strText;
CStdioFile f;
CString str_r;
m_Edit1.GetWindowText(str_r);
if (str_r == _T(""))
{
CFileDialog fileDlg(TRUE, _T(".txt"), NULL,
OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST,
_T("All Files (*.*) |*.*| Text Files(*.txt) | *.txt| Word Files(*.doc) |*.doc|"));
if (fileDlg.DoModal() == IDOK)
{
if (!f.Open(fileDlg.GetPathName(), CFile::modeRead | CFile::typeText))
{
MessageBox("Не могу открыть файл");
return;
}
while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}
/*CString str;
m_Edit1.GetWindowText(str);
f.Write(str, str.GetLength());
f.Close();*/
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот"));
}
}
else if (str_r != _T(""))
{
UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"),
_T("Блокнот"), MB_YESNOCANCEL | MB_ICONWARNING);
if (uRes == IDYES)
{
//CString path;
CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL);
if(fileDlg.DoModal() == IDOK)
{
//path = fdlg.GetPathName();
//CFile f;
if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite))
{
MessageBox("Не могу сохранить файл");
return;
}
while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот"));
}
CFileDialog fileDlg1(TRUE, _T(".txt"), NULL,
OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST,
_T("All Files (*.*) |*.*| Text Files(*.txt) | *.txt| Word Files(*.doc) |*.doc|"));
if (fileDlg1.DoModal() == IDOK)
{
if (!f.Open(fileDlg1.GetPathName(), CFile::modeRead | CFile::typeText))
{
MessageBox("Не могу открыть файл");
return;
}
while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg1.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот"));
}
}
if (uRes == IDNO)
{
CFileDialog fileDlg(TRUE, _T(".txt"), NULL,
OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST,
_T("All Files (*.*) |*.*| Text Files(*.txt) | *.txt| Word Files(*.doc) |*.doc|"));
if (fileDlg.DoModal() == IDOK)
{
if (!f.Open(fileDlg.GetPathName(), CFile::modeRead | CFile::typeText))
{
MessageBox("Не могу открыть файл");
return;
}
while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот"));
}
}
}
}
void CMenuDlg::OnSoxranit()//Сохранить-------------------------------
{
if (m_strPath == _T("Безымянный") )
OnSoxranitkak();
else
{
CStdioFile file;
if (!file.Open(m_strFileName
, CFile::modeCreate | CFile::modeWrite | CFile::typeText))
{
AfxMessageBox(_T("Не могу открыть файл."));
return;
}
CEdit *pEditor = (CEdit *)GetDlgItem(IDC_EDIT1);
int nLines = pEditor->GetLineCount();
CString str;
for (int i = 0; i < nLines; i++)
{
int nLen = pEditor->LineLength(pEditor->LineIndex(i));
pEditor->GetLine(i, str.GetBuffer(nLen), nLen);
str.ReleaseBuffer(nLen);
if (i > 0)
str = _T("\n") + str;
file.WriteString(str);
}
}
}
void CMenuDlg::OnSoxranitkak()//Сохранить как------------------------
{
CString str_77, strText;
CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) | *.txt|",NULL);
if(fileDlg.DoModal() == IDOK)
{
//path = fileDlg.GetPathName();
CStdioFile f;
if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite))
{
MessageBox("Не могу сохранить файл");
return;
}
/*while (f.ReadString(str_77))
{
if (!strText.IsEmpty())
strText += "\r\n";
strText += str_77;
}
SetDlgItemText(IDC_EDIT1, strText);
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T("-Блокнот(Alexa)"));*/
CEdit *pEditor = (CEdit *)GetDlgItem(IDC_EDIT1);
int nLines = pEditor->GetLineCount();
CString str;
for (int i = 0; i < nLines; i++)
{
int nLen = pEditor->LineLength(pEditor->LineIndex(i));
pEditor->GetLine(i, str.GetBuffer(nLen), nLen);
str.ReleaseBuffer(nLen);
if (i > 0)
str = _T("\n") + str;
f.WriteString(str);
}
m_strPath = fileDlg.GetPathName();
m_strFileName = f.GetFileName();
SetWindowText(m_strFileName + _T(" - Блокнот"));
}
}
void CMenuDlg::OnWremja()//Время---------------------------------------
{
CEdit *pmyEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
CString str, str2, str3;
int nashalo, konec;
CTime time = CTime::GetCurrentTime();
UpdateData();
str = time.Format(_T("%H:%M %d.%m.%Y"));
pmyEdit->GetSel(nashalo, konec);
GetDlgItemText(IDC_EDIT1, str3);
str3.Insert(konec, str);
SetDlgItemText(IDC_EDIT1, str3);
pmyEdit->SetSel(nashalo + 17, konec + 17);
}
void CMenuDlg::OnWidelitwse()//Выделить все---------------------------
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->SetSel(0,-1);
mEdit->SetFocus();
}
void CMenuDlg::OnShrift() //Шрифт-----------------------------------------------
{
LOGFONT lfText;
m_fontText.GetLogFont(&lfText);
CFontDialog fontDlg(&lfText);
if (fontDlg.DoModal())
{fontDlg.GetCurrentFont(&lfText);
m_fontText.DeleteObject();
m_fontText.CreateFontIndirect(&lfText);
m_Edit1.SetFont(&m_fontText);}
}
void CMenuDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (IsWindow(m_wndStatusBar.m_hWnd))
{
m_wndStatusBar.MoveWindow(0, 0, 0, 0);
CRect rect;
m_wndStatusBar.GetClientRect(&rect);
int nParts[] = {rect.right - 200, - 1};
m_wndStatusBar.SetParts(sizeof(nParts)/sizeof(nParts[0]), nParts);
CString strPartsStatusBar;
strPartsStatusBar.Format(_T("Строка %d, столбец %d"), m_nStrStatusBar, m_nStolbetsStatusBar);
}
CWnd *pEdit = GetDlgItem(IDC_EDIT1);
if (pEdit != NULL)
{
CRect rcClient;
GetClientRect(rcClient);
rcClient.InflateRect(-2, -2, -2, -20);
pEdit->MoveWindow(rcClient);
if(IsWindow(m_Edit1.m_hWnd))
{
m_wndStatusBar.MoveWindow(0, 0, 0, 0);
CRect clientRect1;
CRect clientRStatusBar1;
GetClientRect(clientRect1);
m_wndStatusBar.GetClientRect(clientRStatusBar1);
CRect cx = clientRect1;
cx.bottom = clientRect1.bottom - clientRStatusBar1.Height();
m_Edit1.MoveWindow(cx);
}
CMenu* pMenu = GetMenu()->GetSubMenu(3);
UINT state = pMenu->GetMenuState(1, MF_BYPOSITION);
if (nType == SIZE_MINIMIZED && state & MF_CHECKED)
{
ShowWindow(SW_HIDE);
Shell_NotifyIcon(NIM_ADD, &m_nidTray);
//m_uTimer = SetTimer(1, 500, NULL);
nIcon = 0;
}/*
static UINT rgIconID[] =
{
IDI_ICON1, IDI_ICON2, IDI_ICON3, IDI_ICON4
};
nIcon++;
if (nIcon == 4) nIcon = 0;
m_nidTray.hIcon = AfxGetApp()->LoadIcon(rgIconID[nIcon]);
Shell_NotifyIcon(NIM_MODIFY, &m_nidTray);
*/
}
}
void CMenuDlg::Onblokn()//Модальное окно О блокноте---------------
{
mein dlg;
if (dlg.DoModal() == IDOK)
{
Beep(1500,300);
}
}
void CMenuDlg::OnUdalit()//Удалить---------------------------------------
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->Clear();
mEdit->SetFocus();
}
void CMenuDlg::OnWirezat()//Вырезать-----------------------------------
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->Cut();
mEdit->SetFocus();
}
void CMenuDlg::OnKopirowat()//Копировать--------------------------------
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->Copy();
mEdit->SetFocus();
}
void CMenuDlg::OnWstawit()//Вставить-------------------------------------
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->Paste();
mEdit->SetFocus();
}
Void CMenuDlg::OnOtmenit()//Отменить----------------------------------
{
CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
mEdit->Undo();
mEdit->SetFocus();
}
void CMenuDlg::OnEnChangeEdit1()//Едит------------------------------
{
//CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
//mEdit->SetSel(0, 0);
CString str_4;
m_Edit1.GetWindowText(str_4);
if (str_4 != _T(""))
MF_ENABLED );
/*else if(str_4 ==_T(""))
sibmenu->EnableMenuItem(ID_Otmenit,*/
/*
CString str_5;
m_Edit1.GetWindowText(str_5);
if (str_5 != _T(""))
else if(str_5 ==_T(""))
CString str_6;
m_Edit1.GetWindowText(str_6);
if (str_6 != _T(""))
GetMenu();
else if(str_5 ==_T(""))
MF_BYCOMMAND */
}
void CMenuDlg::OnInitMenu(CMenu* pMenu)
{
CDialog::OnInitMenu(pMenu);
}
void CMenuDlg::OnClose()//Закрытие-------------------------------------
{
CString str_r;
m_Edit1.GetWindowText(str_r);
if (str_r == _T(""))
{
EndDialog(0);
return;
}
else if (str_r != _T(""))
{
UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"),
_T("Блокнот"), MB_YESNOCANCEL | MB_ICONWARNING);
if (uRes == IDYES)
{
CString path;
CFileDialog fdlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL);
if(fdlg.DoModal() == IDOK)
{
path = fdlg.GetPathName();
CFile f;
if(!f.Open(path, CFile::modeCreate | CFile::modeWrite))
{
MessageBox("Не могу сохранить файл");
return;
}
CString str;
m_Edit1.GetWindowText(str);
f.Write(str, str.GetLength());
f.Close();
}
}
if (uRes == IDNO)
{
CDialog::OnClose();
}
if (uRes == IDCANCEL)
{}
}
KillTimer(m_uTimer);
KillTimer(m_nTimer);
//CDialog::OnClose();
}
void CMenuDlg::OnSprawka2()//Вызов справки----------------------------
void CMenuDlg::OnNauti()//Найти-------------------------------------------------
{
if (!m_pAddDlg)
{
m_pAddDlg = new m_nauti (this);
m_pAddDlg->Create(IDD_M_NAUTI);
}
m_pAddDlg->ShowWindow(SW_SHOW);
m_pAddDlg->SetForegroundWindow();
m_Find = TRUE;
}
void CMenuDlg::OnNautidalee()//Найти далее-------------------------------
{
OnNauti();
/*if (!m_Find)
OnEditMfind();
else
m_nauti->OnNauti();*/
}
void CMenuDlg::OnZamenit()//Заменить--------------------------------------
{
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
pEdit->SetSel(0, 0);
if (!m_zamenitDlg)
{
// Создаем объект дочернего окна
m_zamenitDlg = new Zamenit (this);
// Создаем дочернее окно
m_zamenitDlg->Create(IDD_ZAMENIT);
}
// Показываем дочернее окно
m_zamenitDlg->ShowWindow(SW_SHOW);
m_zamenitDlg->SetForegroundWindow();
//Zamenit dlg;
//if (dlg.DoModal() == IDCANCEL)
//{
////Beep(1500,300);
//}
}
void CMenuDlg::OnT()//строка состояние-------------------------------------
{
CMenu* pMenu = GetMenu()->GetSubMenu(3);
CWnd *pEdit = GetDlgItem(IDC_EDIT1);
CRect rcEditSize;
UINT state = pMenu->GetMenuState(0, MF_BYPOSITION);
if (state & MF_CHECKED)
//Beep(100,100);
else
}
void CMenuDlg::OnTimer(UINT nIDEvent)//Он таймер-------------------
{
CString strPartsStatusBar;
CEdit *pmyEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
int nStart, nEnd;
pmyEdit->GetSel(nStart, nEnd);
m_nStrStatusBar = pmyEdit->LineFromChar(nStart);
m_nStolbetsStatusBar = nEnd - pmyEdit->LineIndex(m_nStrStatusBar);
strPartsStatusBar.Format(_T("Стр %d, стлб %d"), m_nStrStatusBar + 1, m_nStolbetsStatusBar + 1);
m_wndStatusBar.SetText(strPartsStatusBar, 1, 0);
//m_wndStatusBar.ShowWindow(SW_SHOW);
CDialog::OnTimer(nIDEvent);
}
LRESULT CMenuDlg::OnTrayIcon(WPARAM wParam, LPARAM lParam)//Трай-----------------------
{
if (wParam != ID_TRAYICON || (lParam != WM_LBUTTONUP && lParam != WM_RBUTTONUP))
return 0L;
if (lParam == WM_LBUTTONUP)
{
OnTrayOpen();
}
else if (lParam == WM_RBUTTONUP)
return 0;
}
void CMenuDlg::OnTrayOpen()
{
ShowWindow(SW_RESTORE);
SetForegroundWindow();
Shell_NotifyIcon(NIM_DELETE, &m_nidTray);
}
void CMenuDlg::OnTrayExit()
{
Shell_NotifyIcon(NIM_DELETE, &m_nidTray);
EndDialog(0);
}
void CMenuDlg::OnTrei()
{
CMenu* pMenu = GetMenu()->GetSubMenu(3);
UINT state = pMenu->GetMenuState(1, MF_BYPOSITION);
if (state == MF_CHECKED)
else
}
void CMenuDlg::OnPereuti()//перейти-----------------------------------------
{
/*
pereuti move;
CString str,str1;
int index;
int lines;
//DWORD word;
lines = m_Edit1.GetLineCount();
str1 = _T("Столько строк нет!!! их всего: ");
str.Format(_T("%d"),lines);
str1 += str;
//word = m_Edit.GetSel();
index = m_Edit1.LineFromChar()+1;
//index = m_Edit1.GetLineCount();
move.m_position = index;
//move.Goto_Edit.SetSel(0, -1);
if(move.DoModal() == IDOK)
{
//move.m_edit_pereuti.SetSel(0, -1);
if(lines < m_Edit1.LineIndex(move.m_position+10))
AfxMessageBox(str1);
else
m_Edit1.SetSel(m_Edit1.LineIndex(move.m_position-1),
m_Edit1.LineIndex(move.m_position-1));
}*/
pereuti move;
CString str,str1;
int index;
int lines;
lines = m_Edit1.GetLineCount();
str1 = _T("Столько строк нет!!! их всего: ");
str.Format(_T("%d"),lines);
str1 += str;
index = m_Edit1.LineFromChar() + 1;
move.m_position = index;
if(move.DoModal() == IDOK)
{
//move.m_edit_pereuti.SetSel(0, -1);
if(index >= m_Edit1.LineIndex(move.m_position-1))
AfxMessageBox(str1);
else
m_Edit1.SetSel(m_Edit1.LineIndex(move.m_position-1),
m_Edit1.LineIndex(move.m_position-1));
}
}
void CMenuDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
BOOL