Реферат: Проект текстового редактора

СОДЕРЖАНИЕ

Постановка задачи

Краткие теоретические сведения

Результаты выполнения программы

Заключение

Литература

Листинг программы

ПОСТАНОВКА ЗАДАЧИ

Составить Win32 App проект простейший текстовый редактор, который позволяет выполнять операции редактирование текста, копирование и вставку из одного окна проекта в другое окно проекта. Использовать вызов диалогов сохранения и открытия файла, а также диалог выбора шрифта. Все диалоги применяются к тексту в редакторе.

КРАТКИЕ ТЕОРЕТИЧЕСКИЕ СВЕДЕНИЯ

Работа с функциями вызова стандартных диалогов производится следующим образом:

1. Объявляются переменные соответствующих структур:

static COLORREF textColor;

// Переменные для стандартных диалогов "Open", "Save as"

static OPENFILENAME ofn;

static char szFile[MAX_PATH];

// Переменные для стандартного диалога «Color»

static CHOOSECOLOR cc; // common dialog box structure

static COLORREF acrCustClr[16]; // array of custom colors

// Переменные для стандартного диалога «Font»

static CHOOSEFONT chf;

static HFONT hFont;

static LOGFONT lf;

2. Инициализируются соответствующие структуры в обработчике события создания окна (окна диалога).

switch (uMsg)

{

case WM_CREATE:

// Инициализацияструктурыofn

ofn.lStructSize = sizeof(OPENFILENAME);

ofn.hwndOwner = hWnd;

ofn.lpstrFile = szFile;

ofn.nMaxFile = sizeof(szFile);

// Инициализация структуры cc

cc.lStructSize = sizeof(CHOOSECOLOR);

cc.hwndOwner = hWnd;

cc.lpCustColors = (LPDWORD) acrCustClr;

cc.Flags = CC_FULLOPEN | CC_RGBINIT;

// Инициализацияструктурыchf

chf.lStructSize = sizeof(CHOOSEFONT);

chf.hwndOwner = hWnd;

chf.lpLogFont = &lf;

chf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;

chf.nFontType = SIMULATED_FONTTYPE;

break;

}

3. Вызывается соответствующая функция в обработчике событий нажатия кнопки вызова соответствующего диалога.

case WM_COMMAND:

switch (LOWORD(wParam))

{

case IDM_OPEN:

strcpy(szFile, "");

success = GetOpenFileName(&ofn);

if (success)

MessageBox(hWnd, ofn.lpstrFile, "Открываетсяфайл:", MB_OK);

else

MessageBox(hWnd, ESC_OF«GetOpenFileName»,

«Отказ от выбора или ошибка», MB_ICONWARNING);

break;

case IDM_SAVE_AS:

strcpy(szFile, "");

success = GetSaveFileName(&ofn);

if (success)

MessageBox(hWnd, ofn.lpstrFile,

"Файлсохраняетсясименем:", MB_OK);

else

MessageBox(hWnd, ESC_OF«GetSaveFileName»,

«Отказ от выбора или ошибка», MB_ICONWARNING);

break;

case IDM_BKGR_COLOR:

if (ChooseColor(&cc))

SetClassLong(hWnd, GCL_HBRBACKGROUND,

(LONG)CreateSolidBrush(cc.rgbResult));

break;

case IDM_TEXT_COLOR:

if (ChooseColor(&cc)) textColor = cc.rgbResult;

break;

case IDM_CHOOSE_FONT:

if(ChooseFont(&chf)) hFont = CreateFontIndirect(chf.lpLogFont);

break;

РЕЗУЛЬТАТЫ ВЫПОЛНЕНИЯ ПРОГРАММЫ

/>

/>

/>

/>

ЗАКЛЮЧЕНИЕ

В процессе разработки программы использовался в большом объеме теоретический материал ВУЗа и материал по программированию из учебников, вспомогательных электронных средств и средств Интернета, что способствовало закреплению наработанных навыков и умений в этих интересных областях знаний.

Полное тестирование программы показало что, программа реализована в полном объеме в соответствии с заданными требованиями и поставленной задачей. Полностью отлажена и проработана. Поставленная задача выполнена.

Программа построена на классе MFC для Win 32 приложений.

ЛИТЕРАТУРА

--PAGE_BREAK--

Д.Рихтер Создание эффективных Win32 приложений.

П. В. Румянцев Азбука программирования в WIN 32 API.

Ч. Петзолд. Программирование для Windows 95. Том 1.

Архипова Е.Н. Электронный курс по WIN 32 API.

ЛИСТИНГ ПРОГРАММЫ

Код модуля mein.cpp

// mein.cpp: implementation file

//

#include «stdafx.h»

#include «Menu.h»

#include «mein.h»

// mein dialog

IMPLEMENT_DYNAMIC(mein, CDialog)

mein::mein(CWnd* pParent /*=NULL*/)

: CDialog(mein::IDD, pParent)

{

}

mein::~mein()

{

}

void mein::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(mein, CDialog)

END_MESSAGE_MAP()

// mein message handlers

Кодмодуляmenu.cpp

// Menu.cpp: Defines the class behaviors for the application.

//

#include «stdafx.h»

#include «Menu.h»

#include «MenuDlg.h»

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

// CMenuApp

BEGIN_MESSAGE_MAP(CMenuApp, CWinApp)

ON_COMMAND(ID_HELP, CWinApp::OnHelp)

END_MESSAGE_MAP()

// CMenuApp construction

CMenuApp::CMenuApp()

{

// TODO: add construction code here,

// Place all significant initialization in InitInstance

}

// The one and only CMenuApp object

CMenuApp theApp;

// CMenuApp initialization

BOOL CMenuApp::InitInstance()

{

// InitCommonControls() is required on Windows XP if an application

// manifest specifies use of ComCtl32.dll version 6 or later to enable

// visual styles. Otherwise, any window creation will fail.

InitCommonControls();

CWinApp::InitInstance();

// Standard initialization

// If you are not using these features and wish to reduce the size

// of your final executable, you should remove from the following

// the specific initialization routines you do not need

// Change the registry key under which our settings are stored

// TODO: You should modify this string to be something appropriate

// such as the name of your company or organization

SetRegistryKey(_T(«Local AppWizard-Generated Applications»));

CMenuDlg dlg;

m_pMainWnd = &dlg;

INT_PTR nResponse = dlg.DoModal();

if (nResponse == IDOK)

{

// TODO: Place code here to handle when the dialog is

// dismissed with OK

}

else if (nResponse == IDCANCEL)

{

// TODO: Place code here to handle when the dialog is

// dismissed with Cancel

}

// Since the dialog has been closed, return FALSE so that we exit the

// application, rather than start the application's message pump.

return FALSE; }

Кодмодуляnauti.cpp

// m_nauti.cpp: implementation file

//

#include «stdafx.h»

#include «Menu.h»

#include «m_nauti.h»

#include ".\m_nauti.h"

#include «MenuDlg.h»

#include <string>

using namespace std;

// m_nauti dialog

IMPLEMENT_DYNAMIC(m_nauti, CDialog)

m_nauti::m_nauti(CWnd* pParent /*=NULL*/)

: CDialog(m_nauti::IDD, pParent)

, m_pParent(pParent)

, m_nStartPos(0)

    продолжение
--PAGE_BREAK--

, strFind(_T(""))

, m_strText(_T(""))

, n_radio1(false)

, n_radio2(false)

, ddx_222(false)

{

}

m_nauti::~m_nauti()

{

}

void m_nauti::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

DDX_Control(pDX, IDC_EDIT11, edit);

DDX_Control(pDX, IDC_BUTTON1, nauti_dalee);

DDX_Control(pDX, IDC_RADIO1, ddx_radio);

DDX_Radio(pDX, IDC_RADIO2, ddx_222);

}

BEGIN_MESSAGE_MAP(m_nauti, CDialog)

ON_EN_CHANGE(IDC_EDIT11, OnEnChangeEdit11)

ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)

ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)

ON_WM_DESTROY()

END_MESSAGE_MAP()

BOOL m_nauti::OnInitDialog()

{

CDialog::OnInitDialog();

//CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT11);

//pEdit->SetFocus();

//SetFocus();

return TRUE; // return TRUE unless you set the focus to a control

// EXCEPTION: OCX Property Pages should return FALSE

}

// m_nauti message handlers

void m_nauti::OnEnChangeEdit11()// Едит---------------------------------

{

//CEdit *pmyEdit = (CEdit *)GetDlgItem(IDC_EDIT11);

//pmyEdit->SetFocus();

//SetFocus();

CString str;

edit.GetWindowText(str);

if(str.GetLength()>0)

{

nauti_dalee.ModifyStyle(WS_DISABLED,0);

nauti_dalee.Invalidate(FALSE);

}

else

{

nauti_dalee.ModifyStyle(0,WS_DISABLED);

nauti_dalee.Invalidate(FALSE);

}

}

void m_nauti::OnFind()//Галочкавниз--------------------------------------------

{

CButton *pBtnFind = (CButton *)GetDlgItem(IDC_BUTTON1);

// Получаемдоступкполямввода

CEdit *pEdit = (CEdit *)((CMenuDlg *)m_pParent)->GetDlgItem(IDC_EDIT1);

CEdit *pFind = (CEdit *)GetDlgItem(IDC_EDIT11);

// Получаем текст из полей ввода

pFind->GetWindowText(strFind);

if (!IsDlgButtonChecked(IDC_CHECK1))

{

m_strText.MakeLower();

strFind.MakeLower();

}

int nStart, nEnd;

int nFindPos;

pEdit->GetSel(nStart, nEnd);

m_nStartPos = nEnd;

if (n_radio2)

{

nFindPos = m_strText.Find(strFind);

n_radio2 = FALSE;

}

else

nFindPos = m_strText.Find(strFind, m_nStartPos);

if (nFindPos == -1)

{

if (!n_radio1)

MessageBox(_T(«Не удается найти \»") + strFind + _T("\"")

,_T("Блокнот"), MB_OK | MB_ICONINFORMATION);

}

else

{

// Нашли— выделяемнайденное

pEdit->SetSel(nFindPos, nFindPos + strFind.GetLength());

// Определяем позицию, с которой надо продолжать поиск

m_nStartPos = nFindPos + strFind.GetLength();

}

}

void m_nauti::OnBnClickedButton1()//Найтидалее---------------------------

{

CButton *pBtnFind = (CButton *)GetDlgItem(IDC_BUTTON1);

// Получаемдоступкполямввода

CEdit *pEdit = (CEdit *)((CMenuDlg *)m_pParent)->GetDlgItem(IDC_EDIT1);

CEdit *pFind = (CEdit *)GetDlgItem(IDC_EDIT11);

CString strFind;

    продолжение
--PAGE_BREAK--

pEdit->GetWindowText(m_strText);

pFind->GetWindowText(strFind);

int nStart, nEnd;

int nFindPos;

if (IsDlgButtonChecked(IDC_RADIO2))

OnFind();

if (IsDlgButtonChecked(IDC_RADIO1))

{

if (!IsDlgButtonChecked(IDC_CHECK1))

{

m_strText.MakeLower();

strFind.MakeLower();

}

n_radio1 = TRUE;

n_radio2 = TRUE;

pEdit->GetSel(nStart, nEnd);

CString sz;

int nCountText = m_strText.GetLength();

int nCountFind = strFind.GetLength();

int n = m_strText.Delete(nStart, nCountText);

string strTmp = m_strText;

static const basic_string <char>::size_type npos = -1;

size_t ind = strTmp.rfind (strFind);

if (ind != npos )

pEdit->SetSel((int)ind, ind + nCountFind);

else

MessageBox(_T("Неудаетсянайти\"") + strFind + _T("\"")

,_T("Блокнот"), MB_OK | MB_ICONINFORMATION);

n_radio1 = FALSE;

n_radio2 = FALSE;

}

GetDlgItem(IDC_EDIT11)->SetFocus();

}

void m_nauti::OnBnClickedCancel()//Выход------------------------------

{

OnCancel();

// Сбрасываем указатель на дочернее окно в родительском окне

((CMenuDlg *)m_pParent)->m_pAddDlg = NULL;

// Уничтожаемдочернееокно

DestroyWindow();

}

void m_nauti::OnDestroy()//ОНдестрой--------------------------------------

{

CDialog::OnDestroy();

// Уничтожаемобъект

delete this;

}

Код модуля zamenit.cpp

// Zamenit.cpp: implementation file

//

#include «stdafx.h»

#include «Menu.h»

#include «Zamenit.h»

#include ".\zamenit.h"

#include «MenuDlg.h»

// Zamenit dialog

IMPLEMENT_DYNAMIC(Zamenit, CDialog)

Zamenit::Zamenit(CWnd* pParent /*=NULL*/)

: CDialog(Zamenit::IDD, pParent)

, m_pParentz(pParent)

, m_nStartPosR(0)

, m_bFlagRepl(false)

, m_bFlagReplAll(false)

, strText(_T(""))

, strFind(_T(""))

{

}

Zamenit::~Zamenit()

{

//m_pParentz = pParent;

}

void Zamenit::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(Zamenit, CDialog)

ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)

ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)

ON_EN_CHANGE(IDC_EDIT22, OnEnChangeEdit22)

ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)

ON_WM_DESTROY()

ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)

END_MESSAGE_MAP()

// Zamenit message handlers

void Zamenit::OnBnClickedButton1()//Найтидалее----------------------------

{

// Получаемдоступкполямввода

CEdit *pEdit = (CEdit *)(((CMenuDlg *)AfxGetMainWnd())->GetDlgItem(IDC_EDIT1));

CEdit *pFind = (CEdit *)GetDlgItem(IDC_EDIT22);

// Получаем текст из полей ввода

//CString strText, strFind;

pEdit->GetWindowText(strText);

pFind->GetWindowText(strFind);

if (!IsDlgButtonChecked(IDC_CHECK1))

{

strText.MakeLower();

    продолжение
--PAGE_BREAK--

strFind.MakeLower();

}

int nStart, nEnd;

int nFindPos;

pEdit->GetSel(nStart, nEnd);

m_nStartPosR = nEnd;

nFindPos = strText.Find(strFind, m_nStartPosR);

if (nFindPos == -1 && !m_bFlagReplAll)

{

MessageBox(_T("Неудаетсянайти\"") + strFind + _T("\"")

,_T("Блокнот"), MB_OK | MB_ICONINFORMATION);

}

else

{

// Нашли— выделяемнайденное

pEdit->SetSel(nFindPos, nFindPos + strFind.GetLength());

// Определяем позицию, с которой надо продолжать поиск

m_nStartPosR = nFindPos + strFind.GetLength();

}

m_bFlagRepl = TRUE;

}

void Zamenit::OnBnClickedButton2()//Заменить---------------------------

{

int nStart, nEnd;

//CEdit *pEdit = (CEdit *)((CMenuDlg *)m_pParent)->GetDlgItem(IDC_EDIT1);

//CEdit *pEdit = (CEdit *)(CMenuDlg *)GetDlgItem(IDC_EDIT1);

CEdit *pEdit = (CEdit *)(((CMenuDlg *)AfxGetMainWnd())->GetDlgItem(IDC_EDIT1));

pEdit->GetSel(nStart, nEnd);

if (!m_bFlagRepl)

{

OnBnClickedButton1();

m_bFlagRepl = TRUE;

}

else if (m_bFlagRepl && (nStart != nEnd))

{

//CEdit *pEdit = (CEdit *)((CMenuDlg *)m_pParent)->GetDlgItem(IDC_EDIT1);

CEdit *pEdit = (CEdit *)(((CMenuDlg *)AfxGetMainWnd())->GetDlgItem(IDC_EDIT1));

CEdit *pSours = (CEdit *)GetDlgItem(IDC_EDIT2);

CString strSours;

pSours->GetWindowText(strSours);

pEdit->ReplaceSel(strSours);

OnBnClickedButton1();

}

}

void Zamenit::OnEnChangeEdit22()

{

CString strFind1;

GetDlgItemText(IDC_EDIT22, strFind1);

CButton *p1 = (CButton *)GetDlgItem(IDC_BUTTON1);

CButton *p2 = (CButton *)GetDlgItem(IDC_BUTTON2);

CButton *p3 = (CButton *)GetDlgItem(IDC_BUTTON3);

if (strFind1 != _T(""))

{

p1->EnableWindow(TRUE);

p2->EnableWindow(TRUE);

p3->EnableWindow(TRUE);

}

else

{

p1->EnableWindow(FALSE);

p2->EnableWindow(FALSE);

p3->EnableWindow(FALSE);

}

}

void Zamenit::OnBnClickedButton3()//Заменитьвсе---------------------------

{

// Получаемдоступкполямввода

//CEdit *pEdit = (CEdit *)((CMenuDlg *)m_pParent)->GetDlgItem(IDC_EDIT1);

//CEdit *pEdit = (CEdit *)(CMenuDlg *)GetDlgItem(IDC_EDIT1);

CEdit *pEdit = (CEdit *)(((CMenuDlg *)AfxGetMainWnd())->GetDlgItem(IDC_EDIT1));

CEdit *pFind = (CEdit *)GetDlgItem(IDC_EDIT22);

//pEdit->SetSel(0, 0);

// Получаем текст из полей ввода

//CString strText, strFind;

pEdit->GetWindowText(strText);

pFind->GetWindowText(strFind);

int nStart, nEnd;

int nFindPos;

pEdit->GetSel(nStart, nEnd);

m_nStartPosR = nEnd;

nFindPos = strText.Find(strFind, m_nStartPosR);

m_nStartPosR = nFindPos + strFind.GetLength();

m_bFlagReplAll = TRUE;

int nCountText = strText.GetLength();

while (nCountText)

{

OnBnClickedButton2();

nCountText--;

}

pEdit->SetSel(0, 0);

m_bFlagReplAll = FALSE;

}

void Zamenit::OnDestroy()//Ондестрой---------------------------------------

{

CDialog::OnDestroy();

// Уничтожаемобъект

    продолжение
--PAGE_BREAK--

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)

    продолжение
--PAGE_BREAK--

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())

{

    продолжение
--PAGE_BREAK--

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 Сохранить изменение?»),

    продолжение
--PAGE_BREAK--

_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,

    продолжение
--PAGE_BREAK--

_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;

    продолжение
--PAGE_BREAK--

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()//МодальноеокноОблокноте---------------

    продолжение
--PAGE_BREAK--

{

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(""))

{

CMenu* MENU = GetMenu();

CMenu* sibmenu = MENU->GetSubMenu(1);

sibmenu->EnableMenuItem(ID_Otmenit, MF_BYCOMMAND | MF_ENABLED );

}

/*else if(str_4 ==_T(""))

{

CMenu* MENU = GetMenu();

CMenu* sibmenu = MENU->GetSubMenu(1);

sibmenu->EnableMenuItem(ID_Otmenit, MF_BYCOMMAND | MF_GRAYED);

}*/

/*

CString str_5;

m_Edit1.GetWindowText(str_5);

if (str_5 != _T(""))

{

CMenu* MENU2 = GetMenu();

CMenu* sebmenu = MENU2->GetSubMenu(1);

sebmenu->EnableMenuItem(ID_Wirezat, MF_BYCOMMAND | MF_ENABLED );

}

else if(str_5 ==_T(""))

{

CMenu* MENU2 = GetMenu();

CMenu* sebmenu = MENU2->GetSubMenu(1);

sebmenu->EnableMenuItem(ID_Wirezat, MF_BYCOMMAND | MF_GRAYED);

}

CString str_6;

m_Edit1.GetWindowText(str_6);

if (str_6 != _T(""))

{

CMenu* MENU2 = GetMenu();

CMenu* sebmenu = MENU2->GetSubMenu(1);

sebmenu->EnableMenuItem(ID_Udalit, MF_BYCOMMAND | MF_ENABLED );

}

else if(str_5 ==_T(""))

{

CMenu* MENU2 = GetMenu();

CMenu* sebmenu = MENU2->GetSubMenu(1);

sebmenu->EnableMenuItem(ID_Udalit, MF_BYCOMMAND | MF_GRAYED);

}*/

}

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(""))

    продолжение
--PAGE_BREAK--

{

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()//Вызовсправки----------------------------

{

MessageBox(_T(«Самопал от Лехи „) ,

_T(“Блокнот»), MB_OK | MB_ICONINFORMATION);

}

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);

/*Beep(200,100);Beep(300,100);Beep(400,100);Beep(500,100);Beep(600,100);

Beep(700,100);Beep(800,100);Beep(900,100);Beep(1000,100);Beep(1100,100);

Beep(1200,100);Beep(1300,100);Beep(1400,100);Beep(1500,100);Beep(1600,100);

Beep(1700,100);Beep(1800,100);Beep(1900,100);Beep(2000,100);Beep(2100,100);

Beep(2500,500);Beep(1900,100);Beep(1800,100);Beep(1700,100);Beep(1600,100);

Beep(1500,100);Beep(1400,100);Beep(1300,100);Beep(1200,100);Beep(1100,100);

Beep(1000,100);Beep(900,100);Beep(800,100);Beep(700,100);Beep(600,100);

Beep(500,100);Beep(400,100);Beep(300,100);Beep(200,100);Beep(100,500);*/

pMenu->CheckMenuItem(0, MF_UNCHECKED | MF_BYPOSITION);

m_wndStatusBar.ShowWindow(SW_HIDE);

GetClientRect(rcEditSize);

    продолжение
--PAGE_BREAK--

rcEditSize.InflateRect(-2, -2);

pEdit->MoveWindow(rcEditSize);

m_bFlMenu = FALSE;

}

else

{

pMenu->CheckMenuItem(0, MF_CHECKED | MF_BYPOSITION);

m_wndStatusBar.ShowWindow(SW_SHOW);

GetClientRect(rcEditSize);

rcEditSize.InflateRect(-2, -2, -2, -20);

pEdit->MoveWindow(rcEditSize);

m_bFlMenu = TRUE;

}

}

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)

{

CPoint pt;

GetCursorPos(&pt);

CMenu *pTrayMenu = m_menuTray.GetSubMenu(0);

// Исправляем баг с контекстным меню (см. MSDN Knowledge Base: 135788)

SetForegroundWindow();

pTrayMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this);

// Исправляем баг с контекстным меню (см. MSDN Knowledge Base: 135788)

PostMessage(WM_NULL, 0, 0);

}

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)

{

pMenu->CheckMenuItem(1, MF_UNCHECKED | MF_BYPOSITION);

}

else

{

pMenu->CheckMenuItem(1, MF_CHECKED | MF_BYPOSITION);

}

}

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;

    продолжение
--PAGE_BREAK--

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)

{

CDialog::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);

CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT1);

int nFerstChar, nSecondChar;

CString strEdit;

pEdit->GetSel(nFerstChar, nSecondChar);

pEdit->GetWindowText(strEdit);

UINT format = CF_TEXT;

BOOL bClipboard = IsClipboardFormatAvailable(format);

//pPopupMenu->EnableMenuItem(ID_Otmenit,

//MF_BYCOMMAND | (bClipboard == FALSE? MF_GRAYED: MF_ENABLED));

//pPopupMenu->EnableMenuItem(ID_Otmenit,

//MF_BYCOMMAND | (m_bFlag == FALSE? MF_GRAYED: MF_ENABLED));

pPopupMenu->EnableMenuItem(ID_Wirezat,

MF_BYCOMMAND | (nFerstChar == nSecondChar? MF_GRAYED: MF_ENABLED));

pPopupMenu->EnableMenuItem(ID_Kopirowat,

MF_BYCOMMAND | (nFerstChar == nSecondChar? MF_GRAYED: MF_ENABLED));

pPopupMenu->EnableMenuItem(ID_Udalit,

MF_BYCOMMAND | (nFerstChar == nSecondChar? MF_GRAYED: MF_ENABLED));

pPopupMenu->EnableMenuItem(ID_Nauti,

MF_BYCOMMAND | (strEdit == _T("")? MF_GRAYED: MF_ENABLED));

pPopupMenu->EnableMenuItem(ID_Zamenit,

MF_BYCOMMAND | (strEdit == _T("")? MF_GRAYED: MF_ENABLED));

pPopupMenu->EnableMenuItem(ID_Nauti_dalee,

MF_BYCOMMAND | (strEdit == _T("")? MF_GRAYED: MF_ENABLED));

}


еще рефераты
Еще работы по информатике